Skip to content

Commit

Permalink
rustdoc: add doc comment to DocVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
lolbinarycat committed Sep 28, 2024
1 parent a3f76a2 commit 5ef63ec
Showing 1 changed file with 9 additions and 2 deletions.
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.
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

0 comments on commit 5ef63ec

Please sign in to comment.