-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Write the "passes" chapter of the rustdoc book #43790
Conversation
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.
When #43348 is merged, will you want to add its propagate-doc-cfg
pass? It relies on the #[doc(cfg)]
attribute form, which will be behind a feature flag when it's first released.
src/doc/rustdoc/src/passes.md
Outdated
space. | ||
|
||
It takes this indentation amount from the first line. For example: |
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.
In my experience it takes this indentation amount from the smallest indentation it sees over the whole docstring. This is the entire reason #42760 exists. Putting an example with differently-indented lines like below, but with the order reversed, will demonstrate this.
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 took the examples from the tests. Maybe we should add more tests for those cases.
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.
What it seems to do is take the smallest indent from the whole document but it will ignore the indent on the first line if the second line isn't entirely white-space. It also always removes white-space from the beginning of the first line and doesn't remove anything from lines which are entirely white-space. I'm sure the logic can be improved because there are also #38173 and #38739 which I think are also caused by this.
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.
should we maybe just be more vague about this, rather than going into this level of detail? That way we can tweak it in the future.
Hmmm how to handle unstable things is.... something I haven't though of yet. |
src/doc/rustdoc/src/passes.md
Outdated
```text | ||
line1 | ||
line2 |
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 should be:
```text
line1
line2
```
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.
not according to the tests, unless i made a mistake
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.
rust/src/librustdoc/passes/unindent_comments.rs
Lines 127 to 137 in edd82ee
#[test] | |
fn should_ignore_first_line_indent() { | |
// The first line of the first paragraph may not be indented as | |
// far due to the way the doc string was written: | |
// | |
// #[doc = "Start way over here | |
// and continue here"] | |
let s = "line1\n line2".to_string(); | |
let r = unindent(&s); | |
assert_eq!(r, "line1\nline2"); | |
} |
src/doc/rustdoc/src/passes.md
Outdated
## `collapse-docs` | ||
|
||
With this pass, multiple `#[doc]` attributes are convered into one single |
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.
*converted
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.
fixed
src/doc/rustdoc/src/passes.md
Outdated
space. | ||
|
||
It takes this indentation amount from the first line. For example: |
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.
What it seems to do is take the smallest indent from the whole document but it will ignore the indent on the first line if the second line isn't entirely white-space. It also always removes white-space from the beginning of the first line and doesn't remove anything from lines which are entirely white-space. I'm sure the logic can be improved because there are also #38173 and #38739 which I think are also caused by this.
src/doc/rustdoc/src/passes.md
Outdated
```text | ||
line1 | ||
line2 |
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.
Actually, this one would also be:
```text
line1
line2
```
However
```text
line1
line2
```
becomes:
```text
line1
line2
```
Whether the second line is entirely white-space or not makes a difference.
I've gone with #43790 (comment), this should be ready for review |
src/doc/rustdoc/src/passes.md
Outdated
|
||
* [`--passes`](command-line-arguments.html#--passes-add-more-rustdoc-passes) | ||
* [`--no-defaults`](ommand-line-arguments.html#--no-defaults-dont-run-default-passes) |
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.
typo in link (missing c
)
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.
fixed, thanks
58c85ae
to
4149ad9
Compare
4149ad9
to
7a5ee17
Compare
@bors r+ rollup ❤️ |
📌 Commit 7a5ee17 has been approved by |
space. | ||
|
||
The exact rules are left under-specified so that we can fix issues that we find. |
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 line confuses me. Is this pass anything more complex than removing a single space if it exists? Are we not able to fix issues if we specify the rules?
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.
Ah, just saw this was approved. Don't block this PR on my comment here, but feel free to answer if there's an answer
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 current semantics are a bit awkward to specify completely, see the thread at #43790 (comment) for a brief summary. I think the thought for stating this was that if we describe everything it does then it would create a situation where either we get penned in by the current implementation, or the docs inevitably get out of sync when we patch around various issues.
…tMisdreavus Write the "passes" chapter of the rustdoc book cc rust-lang#42322 r? @rust-lang/docs
cc #42322
r? @rust-lang/docs