-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(manifest): support feature-documentation in manifests
#17447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2396,6 +2396,26 @@ foo = { enables = [] } | |
| This is equivalent to the array-of-strings syntax. | ||
| Support for other keys should be added later. | ||
|
|
||
| ### feature-documentation | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I've added a subsection. It's not added to the ToC at the beginning of the page as
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we make the subsection sounds more like a sub-feature udner feature-metadata rather than a separate feature being misplaced at a h3 heading? |
||
|
|
||
| * Tracking Issue: [#17445](https://github.com/rust-lang/cargo/issues/17445) | ||
| * RFC: [#3485](https://github.com/rust-lang/rfcs/blob/master/text/3485-feature-documentation.md) | ||
|
|
||
| This allows providing documentation for the feature inside the table introduced by | ||
| [`feature-metadata`](#feature-metadata): | ||
|
|
||
| ```toml | ||
| [features.serde] | ||
| enables = [] | ||
| doc = "Enables support for serialization and deserialization via serde." | ||
|
weihanglo marked this conversation as resolved.
|
||
| ``` | ||
|
|
||
| The documentation can be consumed and displayed by tools. | ||
| It can be a multi-line TOML string, contain multiple paragraphs, and use Markdown markup, | ||
| similarly to Rust doc comments. | ||
| Tools may only display the first paragraph in some contexts, which should therefore be | ||
| relatively short and make sense without the rest of the description. | ||
|
|
||
| ## lockfile-path | ||
|
|
||
| Support for `resolver.lockfile-path` config field has been stabilized in Rust 1.97.0. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2681,3 +2681,65 @@ c = [ | |
| [("Cargo.toml", normalized_manifest)], | ||
| ); | ||
| } | ||
|
|
||
| #[cargo_test] | ||
| fn feature_documentation_is_unstable() { | ||
| let p = project() | ||
| .file( | ||
| "Cargo.toml", | ||
| r#" | ||
| [package] | ||
| name = "foo" | ||
| edition = "2015" | ||
|
|
||
| [features] | ||
| foo = { enables = [], doc = "Enables foo." } | ||
| "#, | ||
| ) | ||
| .file("src/main.rs", "fn main() {}") | ||
| .build(); | ||
|
|
||
| p.cargo("check") | ||
| .with_status(101) | ||
| .with_stderr_data(str![[r#" | ||
| [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` | ||
|
|
||
| Caused by: | ||
| feature `feature-metadata` is required | ||
|
|
||
| The package requires the Cargo feature called `feature-metadata`, but that feature is not stabilized in this version of Cargo ([..]). | ||
| Consider trying a newer version of Cargo (this may require the nightly release). | ||
| See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#feature_metadata for more information about the status of this feature. | ||
|
|
||
| "#]]) | ||
| .run(); | ||
| } | ||
|
|
||
| #[cargo_test] | ||
| fn feature_has_documentation() { | ||
| let p = project() | ||
| .file( | ||
| "Cargo.toml", | ||
| r#" | ||
| cargo-features = ["feature-metadata"] | ||
|
|
||
| [package] | ||
| name = "foo" | ||
| edition = "2015" | ||
|
|
||
| [features] | ||
| foo = { enables = [], doc = "Enables foo." } | ||
|
weihanglo marked this conversation as resolved.
|
||
| "#, | ||
| ) | ||
| .file("src/main.rs", "fn main() {}") | ||
| .build(); | ||
|
|
||
| p.cargo("check") | ||
| .masquerade_as_nightly_cargo(&["feature-metadata"]) | ||
| .with_stderr_data(str![[r#" | ||
| [CHECKING] foo v0.0.0 ([ROOT]/foo) | ||
| [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s | ||
|
|
||
| "#]]) | ||
| .run(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should there be a check of the new key being parsed?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this can similarily be split into two (test, fix) commits, so that we don't need a verification but the test diff showing that it was an unused manifest key.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we had a Or we can also add cargo-info integration for feature metadata in a follow-up as part of the verification. @0xPoe any opinion on this? I am not sure whether it should be behind a unstable flag though, given cargo-info is purely for human not programmable.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I've split the PR: the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds interesting. I believe docs may also be helpful for human use. However, the biggest challenge would be the UI design. In the current cargo-info output, it is difficult to display the documents directly within the existing layout. |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.