-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Improve include macro documentation #106453
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon. Please see the contribution instructions for more information. |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
library/core/src/macros/mod.rs
Outdated
/// If the included file is parsed as an expression, it is placed in the surrounding code | ||
/// [unhygienically](https://doc.rust-lang.org/reference/macros-by-example.html#hygiene). This | ||
/// could result in variables or functions being different from what the file expected if there | ||
/// are variables or functions that have the same name in the current file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wording makes it sound like it's hygienic when in item context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit alters the wording on the hygiene of the macro. This should make it clear that even for an item, it is unhygienic.
Can you show a screenshot of what this warning ends up looking like? |
@rustbot author (use at-rustbot ready to push it back into my queue when ready) |
Currently, it looks like this. It is a pretty tame comment box. I tried it with a block quote, but I feel it does not really add the proper weight to it. There are some alternatives. I am not sure which fits best. Maybe the warning with the tooltip is the most appropriate one, since it states "Warning"? AlternativesOption 2. Error without tooltipOption 3. Error with tooltipOption 4. Warning with tooltip |
@rustbot ready |
Are there other places in the std docs where we have similar warnings? |
There are some examples, but none introduce a new semi- Other examples:
There are plenty of other examples, but none introduce a non-pre block. std::boxed does the closest to introducing a block that I could find. Most use a Overall, it seems like there isn't a convention on how to do |
Hm. TBH, this doesn't really feel like a t-libs decision, both because it's a documentation change (and documentation style change), and because r? docs |
library/core/src/macros/mod.rs
Outdated
/// way at compile time. So, for instance, an invocation with a Windows path | ||
/// containing backslashes `\` would not compile correctly on Unix. | ||
/// <div class="example-wrap" style="display:inline-block"> | ||
/// <pre class="compile_fail" style="white-space:normal;font:inherit;"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right way to do this because if someone enables the "see code blocks lines", it'll make a very weird output. We are talking about adding such a feature in #79710. I re-started the debate and hopefully, we might be able to have something not too far in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be open to me removing the <div>
so that this can be merged? This PR generally improves the documentation, so I see no reason in the html blocking the PR. I will follow the discussion on the better support for warning blocks and update it when the time comes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove the HTML tags and then it's good for me. We can come back to this at a later time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
Thanks! @bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#106287 (Add some docs to `bug`, `span_bug` and `delay_span_bug`) - rust-lang#106341 (refactor: clean up `errors.rs` and `error_codes_check.rs`) - rust-lang#106453 (Improve include macro documentation) - rust-lang#106466 (Fix rustdoc source code rendering for `#[path = "../path/to/mod.rs"]` links) - rust-lang#106528 (Tiny formatting fix) - rust-lang#106534 (rustdoc-gui: Use new block syntax for define-function in goml scripts) - rust-lang#106542 (Add default and latest stable edition to --edition in rustc (attempt 2)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
As outlined in #106118, the
include!
macro is a SEO problem when it comes to the Rust documentation. Beginners may see it as a replacement toinclude
syntax in other languages. I feel like this documentation should quite explicitly link to the modules' documentation.The primary goal of this PR is to address that issue by adding a warning to the documentation. While I was here, I also added some other parts. This included a
Uses
section and some (intra doc) links to other relevant topics.I hope this can help beginners to Rust more quickly understand some multi-file project intricacies.
References