Skip to content

Commit ed5d779

Browse files
Rollup merge of #130537 - lolbinarycat:rustdoc-DocVisitor-docs, r=GuillaumeGomez
rustdoc: add doc comment to DocVisitor
2 parents 6799b80 + 5ef63ec commit ed5d779

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: src/librustdoc/visit.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
use crate::clean::*;
22

3+
/// Allows a type to traverse the cleaned ast of a crate.
4+
///
5+
/// Note that like [`rustc_ast::visit::Visitor`], but
6+
/// unlike [`rustc_lint::EarlyLintPass`], if you override a
7+
/// `visit_*` method, you will need to manually recurse into
8+
/// its contents.
39
pub(crate) trait DocVisitor<'a>: Sized {
410
fn visit_item(&mut self, item: &'a Item) {
511
self.visit_item_recur(item)
612
}
713

8-
/// don't override!
14+
/// Don't override!
915
fn visit_inner_recur(&mut self, kind: &'a ItemKind) {
1016
match kind {
1117
StrippedItem(..) => unreachable!(),
@@ -46,7 +52,7 @@ pub(crate) trait DocVisitor<'a>: Sized {
4652
}
4753
}
4854

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

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

0 commit comments

Comments
 (0)