Skip to content
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

rustdoc: add doc comment to DocVisitor #130537

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/librustdoc/visit.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
use crate::clean::*;

/// Allows a type to traverse the cleaned ast of a crate.
///
/// Note that like [`rustc_ast::visit::Visitor`], but
/// unlike [`rustc_lint::EarlyLintPass`], if you override a
/// `visit_*` method, you will need to manually recurse into
/// its contents.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

content is never plural iirc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"contents" is definitely a word, it implies there is likely to be more than one thing contained.

eg. table of contents

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub(crate) trait DocVisitor<'a>: Sized {
fn visit_item(&mut self, item: &'a Item) {
self.visit_item_recur(item)
}

/// don't override!
/// Don't override!
fn visit_inner_recur(&mut self, kind: &'a ItemKind) {
match kind {
StrippedItem(..) => unreachable!(),
Expand Down Expand Up @@ -46,7 +52,7 @@ pub(crate) trait DocVisitor<'a>: Sized {
}
}

/// don't override!
/// Don't override!
fn visit_item_recur(&mut self, item: &'a Item) {
match &item.kind {
StrippedItem(i) => self.visit_inner_recur(&*i),
Expand All @@ -58,6 +64,7 @@ pub(crate) trait DocVisitor<'a>: Sized {
m.items.iter().for_each(|i| self.visit_item(i))
}

/// This is the main entrypoint of [`DocVisitor`].
fn visit_crate(&mut self, c: &'a Crate) {
self.visit_item(&c.module);

Expand Down
Loading