RFC: Cargo feature descriptions - #3485
Conversation
|
@rustbot label +t-cargo |
I directly applied my more minor feedback that did not change the characteristic of the RFC.
|
@tgross35 thanks for the access. Definitely makes it handy for the more trivial feedback. |
| - Rather than being consistent with `rustdoc` and accepting markdown, should the | ||
| `doc` key be consistent with `package.description` and only support plain |
There was a problem hiding this comment.
Wanted to highlight this for discussion. My main interest is in being able to show summaries in cargo add. Might be good to reach out to @kornelski for what they have seen of how features are documented through the ecosystem as that might help show potential requirements.
There was a problem hiding this comment.
Package descriptions tend to use markdown `code` and *emphasis*. Rust devs really like using ` everywhere. Even rustc uses ` in terminal error messages.
Markdown's goal is to look fine even when displayed as plain text.
You could define it as the first line being for CLI help, and the rest for docs. Analogous to how rustdoc handles doc comments.
There was a problem hiding this comment.
@kornelski 👍 for using markdown. And I think it makes sense to treat the first logical line (anything before the first double-newline) as a "short description", cutting off subsequent paragraphs in places where full documentation doesn't fit.
|
|
||
| This RFC describes a new key to under `features` in `Cargo.toml` for | ||
| documentation. This will allow Cargo to display this information to the user and | ||
| provide a way for `rustdoc` to eventually render this data (how this is rendered |
There was a problem hiding this comment.
One of the issues is how rustdoc consumes the data. rust doc generally knows nothing about Cargo.toml. I would suggest taking #3123 as a reference to start a discussion on cargo-rustdoc integration of this. It doesn't need to be perfect but at least two teams should have some consensus.
There was a problem hiding this comment.
I did bring it up when I initially proposed this feature, https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Descriptions.20for.20feature.20flags and then opened a draft RFC suggesting that rustdoc accept JSON configuration, which Cargo could pass it #3421. That didn't get too much traction, though. I will start that discussion back up
This is allowed in [`rust-lang/rust`](https://github.com/rust-lang/rust/blob/62d9034a0d571b78e518727d6cb4b090569e5238/triagebot.toml#L12). Others have also expected it to work here: - rust-lang#3490 (comment) - rust-lang#3485 (comment) @rustbot label not-rfc
|
Since RFC 3416 is in FCP, that unblocks this feature. I'm going to go ahead and propose FCP here, and see how close we are to consensus. Personally, I do think we should use markdown here. Markdown already looks reasonable in plain text, by design, and it gives crates.io and docs.rs and rustdoc something nicer to work with. |
|
@rfcbot merge |
|
@joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
@rfcbot reviewed Though I still want to call out that intra-doc links are important #3416 (review). CC @GuillaumeGomez if they have any opinion on this. |
|
This is a very good point. Thanks for the ping! |
| # Tables are preferred for longer descriptions | ||
| [features.corge] | ||
| enables = ["bar", "baz"] | ||
| doc = """ |
There was a problem hiding this comment.
Another good question raised was "should we also support intra-doc links in this documentation?". I personally think we should and make the context the same as the crate top-level. What do you think?
There was a problem hiding this comment.
Ah I see you mentioned it below, my bad.
There was a problem hiding this comment.
Thanks for the response!
The follow-up question from me would be: Is there any compatibility issues if we hadn't implemented this RFC and rustdoc change all together? If not then this RFC can safely go first.
There was a problem hiding this comment.
I'm not sure. From cargo perspective, whether there are intra-doc links or not in this documentation doesn't matter. But it'll definitely need to be mentioned when support will be discussed in rustdoc.
For the current case, I think cargo should mention that intra-doc links may be supported when rustdoc support this option and that's it. What do you think?
There was a problem hiding this comment.
Sounds good to me.
@tgross35 could you add something like this? (or whichever way you'd like to rephase this)
- Rustdoc can build on this to show feature documentation.
+ Rustdoc can build on this to show feature documentation.
+ If this RFC gets stabilized before any corresponding change in rustdoc,
+ its documentation should highlight that rustdoc may parse the description and support intra-doc links in the feature.
+ Users need to be aware of this potential incompatibility.|
@weihanglo and @kornelski I moved your conversation into a thread in the hopes that it will make it easier to follow |
|
FYI I removed T-rustdoc from this RFC because this is the Cargo portion split out of #3421 which is now just T-rustdoc's side. T-rustdoc's input in this RFC is still important for how viable this is for allowing #3421 but I expect we'll have other clients of this as well, including ourselves. I was just thinking the other day how having the feature descriptions would be nice for cargo's new completions. |
|
Sounds good to me at least, thanks! |
|
Unfortunately I've let this slip for two years, but I opened #4002 with a metadata proposal that can then be extended to this RFC pretty easily. |
|
|
||
| See [`feature-metadata`] for information about `enables`. | ||
|
|
||
| # Reference-level explanation |
There was a problem hiding this comment.
If #4002 or similar merges, we will need to figure out how this shows up in metadata. With that proposal, this would be:
"features_v2": {
"feat": { "doc": "simple docstring for bar" }
}One question is what the key name should be. doc being consistent with the Cargo.toml makes sense, but this could also be a full name like documentation or description.
|
We talked about the active concerns in the RFC Neither of those requires the community-wide input and are likely best figured out while we work through implementation and stabilization. @tgross35 if you could record those as Unresolved Questions, we'll remove the blocking concerns, allowing FCP to commence on this RFC. |
|
Thanks for discussing, I have added those items as unresolved questions. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Co-authored-by: Kevin Reid <kpreid@switchb.org>
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
|
Thanks people! This has passed FCP. Merging (finally 🎉🎉🎉). Further discussion would happen in rust-lang/cargo#17445. Subscribe to track the progress. |
View all comments
Rendered
RFC for
feature-documentationRFC goals: add a way to write feature descriptions in Cargo.toml
This was split from #3416
This would resolve rust-lang/cargo#4956
FCP