feat(manifest): support feature-documentation in manifests - #17447
feat(manifest): support feature-documentation in manifests#17447AudaciousAxiom wants to merge 2 commits into
feature-documentation in manifests#17447Conversation
|
|
||
| p.cargo("check") | ||
| .masquerade_as_nightly_cargo(&["feature-metadata"]) | ||
| .run(); |
There was a problem hiding this comment.
Should there be a check of the new key being parsed?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
If we had a cargo metadata integration, then we'll have a verification for the consumption side (yeah we should continue the design discussion).
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.
There was a problem hiding this comment.
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.
I've split the PR: the feature_has_documentation test case is now introduced in the first commit, triggers the "unused key" warning, which then disappears in the second commit as support for the key is added.
There was a problem hiding this comment.
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.
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.
| edition = "2015" | ||
|
|
||
| [features] | ||
| foo = { enables = [], doc = "Enables foo." } |
There was a problem hiding this comment.
I think it's still a bit unclear what the style of these should be: should these be capitalized and terminated with a period? I suppose this also depends on whether cargo add (and others) apply any transformation to these.
There was a problem hiding this comment.
IMHO it should follow what rustdoc suggesting: https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html. Strip trailing periods sounds a future problem and also is human-eye-pleasing so we can change whenever needed.
e5b1573 to
0baabe5
Compare
|
The CI failure seems unrelated. |
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
Thanks!
Could you expand https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#feature-metadata a bit? Perhaps with a subsection linking to feature-documentation RFC and tracking issue.
(Also just noticed that we forgot to put feature-metadata RFC link there)
| /// Features that this feature enables. | ||
| pub enables: Vec<String>, | ||
|
|
||
| /// Unstable feature `feature-documentation`. Documentation for the feature. |
There was a problem hiding this comment.
| /// Unstable feature `feature-documentation`. Documentation for the feature. | |
| /// Documentation for the feature. |
I think this should be sufficient?
|
|
||
| p.cargo("check") | ||
| .masquerade_as_nightly_cargo(&["feature-metadata"]) | ||
| .run(); |
There was a problem hiding this comment.
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.
|
|
||
| p.cargo("check") | ||
| .masquerade_as_nightly_cargo(&["feature-metadata"]) | ||
| .run(); |
There was a problem hiding this comment.
If we had a cargo metadata integration, then we'll have a verification for the consumption side (yeah we should continue the design discussion).
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.
| edition = "2015" | ||
|
|
||
| [features] | ||
| foo = { enables = [], doc = "Enables foo." } |
There was a problem hiding this comment.
IMHO it should follow what rustdoc suggesting: https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation.html. Strip trailing periods sounds a future problem and also is human-eye-pleasing so we can change whenever needed.
0baabe5 to
5d1f882
Compare
5d1f882 to
9199a6e
Compare
| This is equivalent to the array-of-strings syntax. | ||
| Support for other keys should be added later. | ||
|
|
||
| ### feature-documentation |
There was a problem hiding this comment.
Could you expand https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#feature-metadata a bit? Perhaps with a subsection linking to feature-documentation RFC and tracking issue.
I've added a subsection. It's not added to the ToC at the beginning of the page as feature-documentation is not actually an unstable feature.
| ```toml | ||
| [features.serde] | ||
| enables = [] | ||
| doc = "Enables support for serialization and deserialization via serde." |
There was a problem hiding this comment.
This is mostly the example from the RFC, but I've taken the liberty to make it fit the rustdoc guidelines a bit more.
What does this PR try to resolve?
This implements part of RFC
feature-documentation, tracked by #17445. This only adds support for the new key in the schema. This doesn't add anything to the index as this was decided against.This doesn't not introduce a dedicated unstable feature, as mentioned in #17445 (comment), and the new key is simply gated behind the existing
feature-metadataunstable feature.The exact name of the key is still TBD, but it will be easy to rename either in this PR or later.
Open questions
feature-metadatathere, or stacked as a separate PR on top of docs(book): document the table syntax of features #17446?Future work
At least the following is still to be done for this RFC (I may not have time to tackle this):
cargo metadata.cargo add(and through other tools/services, like docs.rs).How to test and review this PR?
The tests should be enough to review this.