-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix unindent in doc comments #78400
Fix unindent in doc comments #78400
Conversation
How come this doesn't break https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/issue-42760.rs, which was explicitly testing for the old behaviour? |
793d2de
to
914640c
Compare
This test only check that there is a title, not that the indent isn't broken as far as I can tell? |
If the unindent pass doesn't strip the leading space (because of the |
914640c
to
b3da309
Compare
336bab3
to
13b3187
Compare
But they don't, you can have ///# Documentation
///
///Without leading whitespace just fine, it's just convention to have a space between the doc-comment marker and the docs. |
Well, glad I treated that correctly then. Thanks for the extra information! :) |
Hum, actually I might need to make a small update in the code. :3 |
13b3187
to
8198b62
Compare
8198b62
to
0e9d972
Compare
0e9d972
to
b4c3536
Compare
We're discussing this on discord, but either way the following test cases we came up with should be added: ///no whitespace
#[doc = " lol"] /// 4 whitespaces!
#[doc = "something"] #[cfg_attr(not(unix), doc = " ```ignore")]
#[cfg_attr(unix, doc = " ```rust")]
/// fn has_ampersand(v: &OsStr) -> Result<(), String> {
/// if v.as_bytes().iter().any(|b| *b == b'&') { return Ok(()); }
/// Err(String::from("The value did not contain the required & sigil"))
/// } Additionally, note that the fixed version of #70732 in the test case uses 4 spaces instead of 5, which differs from the original bug report. IMO this seems reasonable to match #42760. There should also be test cases for |
So I changed a bit how the unindent is handled. For example: #[doc = "hello
second"] Before, we didn't take into account the first line that in this case, we could align the doc based on the next lines indent. It was very misleading and not that great as I discovered while updating this PR. I always assumed it was supposed to be: #[doc = "hello
second"] I definitely think it's better this way. Apart from that change, I also added comments and extended tests to add doc includes. |
📌 Commit 87f2897 has been approved by |
⌛ Testing commit 87f2897 with merge 1d5057d91ad6ad54b899a9b93b5b6b8f1fe73ffa... |
💔 Test failed - checks-actions |
Fetch error, let's retry! @bors: retry |
⌛ Testing commit 87f2897 with merge 83a3d46759cbc915445e3f07addb85a82085b2c7... |
If this fails because of another zlib error, let's avoid retrying, |
💔 Test failed - checks-actions |
Seeing that other PRs seem to pass, let's give it another try. @bors: retry |
Fix unindent in doc comments Fixes rust-lang#70732 r? `@jyn514`
Rollup of 8 pull requests Successful merges: - rust-lang#78376 (Treat trailing semicolon as a statement in macro call) - rust-lang#78400 (Fix unindent in doc comments) - rust-lang#78575 (Add a test for compiletest rustc-env & unset-rustc-env directives) - rust-lang#78616 (Document -Zinstrument-coverage) - rust-lang#78663 (Fix ICE when a future-incompat-report has its command-line level capped) - rust-lang#78664 (Fix intrinsic size_of stable link) - rust-lang#78668 (inliner: Remove redundant loop) - rust-lang#78676 (add mipsel-unknown-none target) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #70732
r? @jyn514