Skip to content

Commit 176fb18

Browse files
authored
Rollup merge of rust-lang#91987 - jsha:docdocgoose, r=jyn514
Add module documentation for rustdoc passes These are currently documented at https://rustc-dev-guide.rust-lang.org/rustdoc-internals.html#hot-potato but can easily go out of date. We'd like to document them in place and link to https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/passes/index.html [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/moving.20pass.20docs/near/265058351). r? `@camelid`
2 parents 355ed98 + 1d10e1a commit 176fb18

12 files changed

+30
-0
lines changed

src/librustdoc/passes/bare_urls.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Detects links that are not linkified, e.g., in Markdown such as `Go to https://example.com/.`
2+
//! Suggests wrapping the link with angle brackets: `Go to <https://example.com/>.` to linkify it.
13
use super::Pass;
24
use crate::clean::*;
35
use crate::core::DocContext;

src/librustdoc/passes/calculate_doc_coverage.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Calculates information used for the --show-coverage flag.
12
use crate::clean;
23
use crate::core::DocContext;
34
use crate::html::markdown::{find_testable_code, ErrorCodes};

src/librustdoc/passes/check_code_block_syntax.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Validates syntax inside Rust code blocks (\`\`\`rust).
12
use rustc_data_structures::sync::{Lock, Lrc};
23
use rustc_errors::{emitter::Emitter, Applicability, Diagnostic, Handler};
34
use rustc_middle::lint::LintDiagnosticBuilder;

src/librustdoc/passes/check_doc_test_visibility.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Looks for items missing (or incorrectly having) doctests.
2+
//!
13
//! This pass is overloaded and runs two different lints.
24
//!
35
//! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests.

src/librustdoc/passes/collect_trait_impls.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Collects trait impls for each item in the crate. For example, if a crate
2+
//! defines a struct that implements a trait, this pass will note that the
3+
//! struct implements that trait.
14
use super::Pass;
25
use crate::clean::*;
36
use crate::core::DocContext;

src/librustdoc/passes/html_tags.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Detects invalid HTML (like an unclosed `<span>`) in doc comments.
12
use super::Pass;
23
use crate::clean::*;
34
use crate::core::DocContext;

src/librustdoc/passes/propagate_doc_cfg.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Propagates [`#[doc(cfg(...))]`](https://github.com/rust-lang/rust/issues/43781) to child items.
12
use std::sync::Arc;
23

34
use crate::clean::cfg::Cfg;

src/librustdoc/passes/strip_hidden.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! Strip all doc(hidden) items from the output.
12
use rustc_span::symbol::sym;
23
use std::mem;
34

src/librustdoc/passes/strip_priv_imports.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Strips all private import statements (use, extern crate) from a
2+
//! crate.
13
use crate::clean;
24
use crate::core::DocContext;
35
use crate::fold::DocFolder;

src/librustdoc/passes/strip_private.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Strip all private items from the output. Additionally implies strip_priv_imports.
2+
//! Basically, the goal is to remove items that are not relevant for public documentation.
13
use crate::clean::{self, ItemIdSet};
24
use crate::core::DocContext;
35
use crate::fold::DocFolder;

src/librustdoc/passes/stripper.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//! A collection of utility functions for the `strip_*` passes.
12
use rustc_hir::def_id::DefId;
23
use rustc_middle::middle::privacy::AccessLevels;
34
use std::mem;

src/librustdoc/passes/unindent_comments.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
//! Removes excess indentation on comments in order for the Markdown
2+
//! to be parsed correctly. This is necessary because the convention for
3+
//! writing documentation is to provide a space between the /// or //! marker
4+
//! and the doc text, but Markdown is whitespace-sensitive. For example,
5+
//! a block of text with four-space indentation is parsed as a code block,
6+
//! so if we didn't unindent comments, these list items
7+
//!
8+
//! /// A list:
9+
//! ///
10+
//! /// - Foo
11+
//! /// - Bar
12+
//!
13+
//! would be parsed as if they were in a code block, which is likely not what the user intended.
114
use std::cmp;
215

316
use rustc_span::symbol::kw;

0 commit comments

Comments
 (0)