Skip to content

Commit 554c00e

Browse files
JohnTitorcamelid
authored andcommitted
Cleanup rustdoc-internals
1 parent 5e26873 commit 554c00e

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

src/rustdoc-internals.md

+8-25
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ is the `impl Clean<Crate> for visit_ast::RustdocVisitor`, which is called by
3232
`run_core` above.
3333

3434
You see, I actually lied a little earlier: There's another AST transformation
35-
that happens before the events in `clean/mod.rs`. In `visit_ast.rs` is the
35+
that happens before the events in `clean/mod.rs`. In `visit_ast.rs` is the
3636
type `RustdocVisitor`, which *actually* crawls a `rustc_hir::Crate` to get the first
3737
intermediate representation, defined in `doctree.rs`. This pass is mainly to
3838
get a few intermediate wrappers around the HIR types and to process visibility
@@ -52,10 +52,10 @@ which describe the publicly-documentable items in the target crate.
5252

5353
Before moving on to the next major step, a few important "passes" occur over
5454
the documentation. These do things like combine the separate "attributes" into
55-
a single string and strip leading whitespace to make the document easier on the
56-
markdown parser, or drop items that are not public or deliberately hidden with
57-
`#[doc(hidden)]`. These are all implemented in the `passes/` directory, one
58-
file per pass. By default, all of these passes are run on a crate, but the ones
55+
a single string to make the document easier on the markdown parser,
56+
or drop items that are not public or deliberately hidden with `#[doc(hidden)]`.
57+
These are all implemented in the `passes/` directory, one file per pass.
58+
By default, all of these passes are run on a crate, but the ones
5959
regarding dropping private/hidden items can be bypassed by passing
6060
`--document-private-items` to rustdoc. Note that unlike the previous set of AST
6161
transformations, the passes are run on the _cleaned_ crate.
@@ -66,15 +66,15 @@ these passes, please let us know!)
6666

6767
[44136]: https://github.com/rust-lang/rust/issues/44136
6868

69-
Here is the list of passes as of <!-- date: 2021-10 --> October 2021:
69+
Here is the list of passes as of <!-- date: 2022-05 --> May 2022:
7070

7171
- `calculate-doc-coverage` calculates information used for the `--show-coverage`
7272
flag.
7373

7474
- `check-bare-urls` detects links that are not linkified, e.g., in Markdown such as
7575
`Go to https://example.com/.` It suggests wrapping the link with angle brackets:
7676
`Go to <https://example.com/>.` to linkify it. This is the code behind the <!--
77-
date: 2021-10 --> `rustdoc::bare_urls` lint.
77+
date: 2022-05 --> `rustdoc::bare_urls` lint.
7878

7979
- `check-code-block-syntax` validates syntax inside Rust code blocks
8080
(<code>```rust</code>)
@@ -84,7 +84,7 @@ Here is the list of passes as of <!-- date: 2021-10 --> October 2021:
8484
- `check-invalid-html-tags` detects invalid HTML (like an unclosed `<span>`)
8585
in doc comments.
8686

87-
- `collect-intra-doc-links` resolves [intra-doc links](https://doc.rust-lang.org/rustdoc/linking-to-items-by-name.html).
87+
- `collect-intra-doc-links` resolves [intra-doc links](https://doc.rust-lang.org/nightly/rustdoc/write-documentation/linking-to-items-by-name.html).
8888

8989
- `collect-trait-impls` collects trait impls for each item in the crate. For
9090
example, if we define a struct that implements a trait, this pass will note
@@ -102,23 +102,6 @@ Here is the list of passes as of <!-- date: 2021-10 --> October 2021:
102102
from the output. `strip-private` implies `strip-priv-imports`. Basically, the
103103
goal is to remove items that are not relevant for public documentation.
104104

105-
- `unindent-comments` removes excess indentation on comments in order for the
106-
Markdown to be parsed correctly. This is necessary because the convention for
107-
writing documentation is to provide a space between the `///` or `//!` marker
108-
and the doc text, but Markdown is whitespace-sensitive. For example, a block
109-
of text with four-space indentation is parsed as a code block, so if we didn't
110-
unindent comments, these list items
111-
112-
```rust,ignore
113-
/// A list:
114-
///
115-
/// - Foo
116-
/// - Bar
117-
```
118-
119-
would be parsed as if they were in a code block, which is likely not what the
120-
user intended.
121-
122105
There is also a `stripper` module in `passes/`, but it is a collection of
123106
utility functions for the `strip-*` passes and is not a pass itself.
124107

0 commit comments

Comments
 (0)