Skip to content

Commit d00c0fe

Browse files
authored
feat: Support categories and keywords in forc manifest (#6974)
## Description Related FuelLabs/forc.pub#30 ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers.
1 parent d7f9b62 commit d00c0fe

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

docs/book/src/forc/manifest_reference.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The `Forc.toml` (the _manifest_ file) is a compulsory file for each package and
1212
* `homepage` — URL of the project homepage.
1313
* `repository` — URL of the project source repository.
1414
* `documentation` — URL of the project documentation.
15+
* `categories` — Categories of the project.
16+
* `keywords` — Keywords the project.
1517
* `entry` — The entry point for the compiler to start parsing from.
1618
* For the recommended way of selecting an entry point of large libraries please take a look at: [Libraries](./../sway-program-types/libraries.md)
1719
* `implicit-std` - Controls whether provided `std` version (with the current `forc` version) will get added as a dependency _implicitly_. _Unless you know what you are doing, leave this as default._
@@ -39,6 +41,8 @@ An example `Forc.toml` is shown below. Under `[project]` the following fields ar
3941
* `homepage`
4042
* `repository`
4143
* `documentation`
44+
* `categories`
45+
* `keywords`
4246

4347
Also for the following fields, a default value is provided so omitting them is allowed:
4448

@@ -57,6 +61,8 @@ documentation = "https://example.com/"
5761
organization = "Fuel_Labs"
5862
license = "Apache-2.0"
5963
name = "wallet_contract"
64+
categories = ["example"]
65+
keywords = ["example"]
6066

6167
[project.metadata]
6268
indexing = { namespace = "counter-contract", schema_path = "out/release/counter-contract-abi.json" }

forc-pkg/src/manifest/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ pub struct Project {
204204
pub homepage: Option<Url>,
205205
pub repository: Option<Url>,
206206
pub documentation: Option<Url>,
207+
pub categories: Option<Vec<String>>,
208+
pub keywords: Option<Vec<String>>,
207209
#[serde(default = "default_entry")]
208210
pub entry: String,
209211
pub implicit_std: Option<bool>,
@@ -1399,6 +1401,8 @@ mod tests {
13991401
description: Some("test description".to_string()),
14001402
homepage: None,
14011403
documentation: None,
1404+
categories: None,
1405+
keywords: None,
14021406
repository: None,
14031407
organization: None,
14041408
license: "Apache-2.0".to_string(),
@@ -1425,6 +1429,8 @@ mod tests {
14251429
description: Some("test description".to_string()),
14261430
homepage: Some(Url::parse("https://example.com").unwrap()),
14271431
documentation: Some(Url::parse("https://docs.example.com").unwrap()),
1432+
categories: Some(vec!["test-category".to_string()]),
1433+
keywords: Some(vec!["test-keyword".to_string()]),
14281434
repository: Some(Url::parse("https://example.com").unwrap()),
14291435
organization: None,
14301436
license: "Apache-2.0".to_string(),
@@ -1446,6 +1452,8 @@ mod tests {
14461452
assert_eq!(project.repository, deserialized.repository);
14471453
assert_eq!(project.metadata, deserialized.metadata);
14481454
assert_eq!(project.metadata, None);
1455+
assert_eq!(project.categories, deserialized.categories);
1456+
assert_eq!(project.keywords, deserialized.keywords);
14491457
}
14501458

14511459
#[test]
@@ -1457,11 +1465,11 @@ mod tests {
14571465
authors = ["Test Author"]
14581466
description = "A test project"
14591467
version = "1.0.0"
1468+
keywords = ["test", "project"]
1469+
categories = ["test"]
14601470
14611471
[metadata]
14621472
mykey = "https://example.com"
1463-
keywords = ["test", "project"]
1464-
categories = ["test"]
14651473
"#;
14661474

14671475
let project: Project = toml::from_str(toml_str).unwrap();
@@ -1474,10 +1482,6 @@ mod tests {
14741482
table.get("mykey").unwrap().as_str().unwrap(),
14751483
"https://example.com"
14761484
);
1477-
1478-
let keywords = table.get("keywords").unwrap().as_array().unwrap();
1479-
assert_eq!(keywords[0].as_str().unwrap(), "test");
1480-
assert_eq!(keywords[1].as_str().unwrap(), "project");
14811485
}
14821486

14831487
#[test]

0 commit comments

Comments
 (0)