Move in-pass-function structs and impls outside functions.
Now that each pass has its own module, there's not much of a reason to keep these structs within the functions.
This commit is contained in:
parent
bd62c4c83d
commit
99e1b9cfa6
3 changed files with 76 additions and 70 deletions
|
@ -16,8 +16,14 @@ use fold;
|
|||
use fold::DocFolder;
|
||||
|
||||
pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
|
||||
struct Collapser;
|
||||
impl fold::DocFolder for Collapser {
|
||||
let mut collapser = Collapser;
|
||||
let krate = collapser.fold_crate(krate);
|
||||
krate
|
||||
}
|
||||
|
||||
struct Collapser;
|
||||
|
||||
impl fold::DocFolder for Collapser {
|
||||
fn fold_item(&mut self, mut i: Item) -> Option<Item> {
|
||||
let mut docstr = String::new();
|
||||
for attr in &i.attrs {
|
||||
|
@ -38,8 +44,4 @@ pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
|
|||
i.attrs = a;
|
||||
self.fold_item_recur(i)
|
||||
}
|
||||
}
|
||||
let mut collapser = Collapser;
|
||||
let krate = collapser.fold_crate(krate);
|
||||
krate
|
||||
}
|
||||
|
|
|
@ -25,11 +25,21 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
|
|||
|
||||
// strip all #[doc(hidden)] items
|
||||
let krate = {
|
||||
struct Stripper<'a> {
|
||||
let mut stripper = Stripper{ retained: &mut retained, update_retained: true };
|
||||
stripper.fold_crate(krate)
|
||||
};
|
||||
|
||||
// strip all impls referencing stripped items
|
||||
let mut stripper = ImplStripper { retained: &retained };
|
||||
stripper.fold_crate(krate)
|
||||
}
|
||||
|
||||
struct Stripper<'a> {
|
||||
retained: &'a mut DefIdSet,
|
||||
update_retained: bool,
|
||||
}
|
||||
impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
}
|
||||
|
||||
impl<'a> fold::DocFolder for Stripper<'a> {
|
||||
fn fold_item(&mut self, i: Item) -> Option<Item> {
|
||||
if i.attrs.list("doc").has_word("hidden") {
|
||||
debug!("found one in strip_hidden; removing");
|
||||
|
@ -53,12 +63,4 @@ pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
|
|||
}
|
||||
self.fold_item_recur(i)
|
||||
}
|
||||
}
|
||||
let mut stripper = Stripper{ retained: &mut retained, update_retained: true };
|
||||
stripper.fold_crate(krate)
|
||||
};
|
||||
|
||||
// strip all impls referencing stripped items
|
||||
let mut stripper = ImplStripper { retained: &retained };
|
||||
stripper.fold_crate(krate)
|
||||
}
|
||||
|
|
|
@ -17,8 +17,14 @@ use plugins;
|
|||
use fold::{self, DocFolder};
|
||||
|
||||
pub fn unindent_comments(krate: clean::Crate) -> plugins::PluginResult {
|
||||
struct CommentCleaner;
|
||||
impl fold::DocFolder for CommentCleaner {
|
||||
let mut cleaner = CommentCleaner;
|
||||
let krate = cleaner.fold_crate(krate);
|
||||
krate
|
||||
}
|
||||
|
||||
struct CommentCleaner;
|
||||
|
||||
impl fold::DocFolder for CommentCleaner {
|
||||
fn fold_item(&mut self, mut i: Item) -> Option<Item> {
|
||||
let mut avec: Vec<clean::Attribute> = Vec::new();
|
||||
for attr in &i.attrs {
|
||||
|
@ -34,10 +40,6 @@ pub fn unindent_comments(krate: clean::Crate) -> plugins::PluginResult {
|
|||
i.attrs = avec;
|
||||
self.fold_item_recur(i)
|
||||
}
|
||||
}
|
||||
let mut cleaner = CommentCleaner;
|
||||
let krate = cleaner.fold_crate(krate);
|
||||
krate
|
||||
}
|
||||
|
||||
fn unindent(s: &str) -> String {
|
||||
|
|
Loading…
Add table
Reference in a new issue