Skip to content

Commit

Permalink
Rollup merge of #130537 - lolbinarycat:rustdoc-DocVisitor-docs, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

rustdoc: add doc comment to DocVisitor
  • Loading branch information
GuillaumeGomez authored Sep 29, 2024
2 parents 6799b80 + 5ef63ec commit ed5d779
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 ed5d779

Please sign in to comment.