Skip to content

Commit

Permalink
rustdoc: Make strip_hidden use a dedicated hidden item if any.
Browse files Browse the repository at this point in the history
fixes #13806.
  • Loading branch information
lifthrasiir committed Apr 28, 2014
1 parent 3e284ee commit 3b5d6b4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
17 changes: 16 additions & 1 deletion src/librustdoc/clean.rs
Expand Up @@ -152,6 +152,21 @@ impl Item {
return None;
}

pub fn is_hidden_from_doc(&self) -> bool {
match self.doc_list() {
Some(ref l) => {
for innerattr in l.iter() {
match *innerattr {
Word(ref s) if "hidden" == *s => return true,
_ => (),
}
}
},
None => ()
}
return false;
}

pub fn is_mod(&self) -> bool {
match self.inner { ModuleItem(..) => true, _ => false }
}
Expand Down Expand Up @@ -736,7 +751,7 @@ impl Clean<Type> for ast::Ty {

#[deriving(Clone, Encodable, Decodable)]
pub enum StructField {
HiddenStructField,
HiddenStructField, // inserted later by strip passes
TypedStructField(Type),
}

Expand Down
31 changes: 16 additions & 15 deletions src/librustdoc/passes.rs
Expand Up @@ -33,23 +33,24 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
};
impl<'a> fold::DocFolder for Stripper<'a> {
fn fold_item(&mut self, i: Item) -> Option<Item> {
for attr in i.attrs.iter() {
match attr {
&clean::List(ref x, ref l) if "doc" == *x => {
for innerattr in l.iter() {
match innerattr {
&clean::Word(ref s) if "hidden" == *s => {
debug!("found one in strip_hidden; removing");
self.stripped.insert(i.id);
return None;
},
_ => (),
}
}
},
_ => ()
if i.is_hidden_from_doc() {
debug!("found one in strip_hidden; removing");
self.stripped.insert(i.id);

// use a dedicated hidden item for given item type if any
match i.inner {
clean::StructFieldItem(..) => {
return Some(clean::Item {
inner: clean::StructFieldItem(clean::HiddenStructField),
..i
});
}
_ => {
return None;
}
}
}

self.fold_item_recur(i)
}
}
Expand Down

5 comments on commit 3b5d6b4

@bors
Copy link
Contributor

@bors bors commented on 3b5d6b4 Apr 28, 2014

Choose a reason for hiding this comment

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

saw approval from alexcrichton
at lifthrasiir@3b5d6b4

@bors
Copy link
Contributor

@bors bors commented on 3b5d6b4 Apr 28, 2014

Choose a reason for hiding this comment

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

merging lifthrasiir/rust/rustdoc-hidden-pub-field = 3b5d6b4 into auto

@bors
Copy link
Contributor

@bors bors commented on 3b5d6b4 Apr 28, 2014

Choose a reason for hiding this comment

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

lifthrasiir/rust/rustdoc-hidden-pub-field = 3b5d6b4 merged ok, testing candidate = 3cd6c1e

@bors
Copy link
Contributor

@bors bors commented on 3b5d6b4 Apr 29, 2014

@bors
Copy link
Contributor

@bors bors commented on 3b5d6b4 Apr 29, 2014

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 3cd6c1e

Please sign in to comment.