-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustdoc::missing_doc_code_examples
inconsistent with Rust API Guidelines
#87858
Comments
This is not a bug. Think of Did you maybe come across this by enabling |
I enabled the lint since I think it's useful, however, I was surprised by the behaviour. Within a module there may be a few related functions which would be fine referencing an existing example. Not taking that into consideration makes this lint annoying for that use case. |
How could rustdoc tell if you're referencing an existing example? |
Potentially by looking at the linked item and checking if there is an example present there, instead of the current doc comment. |
(Ranting:) @jyn514 Is that (lack of fields/parts like I couldn't find much (nothing obvious at https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html; some related: https://internals.rust-lang.org/t/rustdoc-restructuredtext-vs-markdown/356/88: Linux kernel switched to reStructuredText, and https://internals.rust-lang.org/t/rustdoc-asciidoctor-vs-markdown/4161). Would some simple new Rustdoc syntax not be enough, or not flexible/future-proof? For example:
But, opposite to Javadoc's
(Update: I'll experiment, and will comment more below.) |
@peter-kehl I haven't read your whole comment, but if you want to propose introducing major new features, you should go through the RFC process. |
How I see the easiest solution/workaround and related problems: Sprinkling
Because lint names (as passed to
Of course, that would not check for any link, but it would carry some intention. And, I believe that people would love it for many other lints. Like various reasons instead of one uniform The Yes, Can you think of any reverse/negative use cases? (When we'd have alias(es) to a shortcut macro emitting |
I don't think the issue is necessarily that the current behavior is a bug, but a different set of behavior might be more useful |
@peter-kehl That's an interesting idea, but I think it would also be possible to just check the "Example" section to see if it contains a link, which I think would be simpler. |
Shameless promotion: All use allow::rustdoc::missing_doc_code_examples as allow_rustdoc_missing_docs_examples_linked;
use allow::rustdoc::missing_doc_code_examples as allow_rustdoc_missing_docs_examples_all_is_trivial; |
When the
rustdoc::missing_doc_code_examples
lint is enabled,rustdoc
reports that doc comments which reference another example is missing an example. This is inconsistent with the Rust API Guidelines.Given the following:
I expected to see no warnings.
Instead, this happened:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: