Skip to content

Commit bd62c4c

Browse files
committed
Move pass contants/types into the new pass module.
1 parent f1a3eb6 commit bd62c4c

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

src/librustdoc/lib.rs

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,6 @@ pub mod test;
9191

9292
use clean::Attributes;
9393

94-
type Pass = (&'static str, // name
95-
fn(clean::Crate) -> plugins::PluginResult, // fn
96-
&'static str); // description
97-
98-
const PASSES: &'static [Pass] = &[
99-
("strip-hidden", passes::strip_hidden,
100-
"strips all doc(hidden) items from the output"),
101-
("unindent-comments", passes::unindent_comments,
102-
"removes excess indentation on comments in order for markdown to like it"),
103-
("collapse-docs", passes::collapse_docs,
104-
"concatenates all document attributes into one document attribute"),
105-
("strip-private", passes::strip_private,
106-
"strips all private items from a crate which cannot be seen externally, \
107-
implies strip-priv-imports"),
108-
("strip-priv-imports", passes::strip_priv_imports,
109-
"strips all private import statements (`use`, `extern crate`) from a crate"),
110-
];
111-
112-
const DEFAULT_PASSES: &'static [&'static str] = &[
113-
"strip-hidden",
114-
"strip-private",
115-
"collapse-docs",
116-
"unindent-comments",
117-
];
118-
11994
struct Output {
12095
krate: clean::Crate,
12196
renderinfo: html::render::RenderInfo,
@@ -222,11 +197,11 @@ pub fn main_args(args: &[String]) -> isize {
222197

223198
if matches.opt_strs("passes") == ["list"] {
224199
println!("Available passes for running rustdoc:");
225-
for &(name, _, description) in PASSES {
200+
for &(name, _, description) in passes::PASSES {
226201
println!("{:>20} - {}", name, description);
227202
}
228203
println!("\nDefault passes for rustdoc:");
229-
for &name in DEFAULT_PASSES {
204+
for &name in passes::DEFAULT_PASSES {
230205
println!("{:>20}", name);
231206
}
232207
return 0;
@@ -411,7 +386,7 @@ fn rust_input(cratefile: &str, externs: Externs, matches: &getopts::Matches) ->
411386
}
412387

413388
if default_passes {
414-
for name in DEFAULT_PASSES.iter().rev() {
389+
for name in passes::DEFAULT_PASSES.iter().rev() {
415390
passes.insert(0, name.to_string());
416391
}
417392
}
@@ -421,11 +396,11 @@ fn rust_input(cratefile: &str, externs: Externs, matches: &getopts::Matches) ->
421396
.unwrap_or("/tmp/rustdoc/plugins".to_string());
422397
let mut pm = plugins::PluginManager::new(PathBuf::from(path));
423398
for pass in &passes {
424-
let plugin = match PASSES.iter()
425-
.position(|&(p, ..)| {
426-
p == *pass
427-
}) {
428-
Some(i) => PASSES[i].1,
399+
let plugin = match passes::PASSES.iter()
400+
.position(|&(p, ..)| {
401+
p == *pass
402+
}) {
403+
Some(i) => passes::PASSES[i].1,
429404
None => {
430405
error!("unknown pass {}, skipping", *pass);
431406
continue

src/librustdoc/passes/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::mem;
1616
use clean::{self, GetDefId, Item};
1717
use fold;
1818
use fold::FoldItem::Strip;
19+
use plugins;
1920

2021
mod collapse_docs;
2122
pub use self::collapse_docs::collapse_docs;
@@ -32,6 +33,32 @@ pub use self::strip_priv_imports::strip_priv_imports;
3233
mod unindent_comments;
3334
pub use self::unindent_comments::unindent_comments;
3435

36+
type Pass = (&'static str, // name
37+
fn(clean::Crate) -> plugins::PluginResult, // fn
38+
&'static str); // description
39+
40+
pub const PASSES: &'static [Pass] = &[
41+
("strip-hidden", strip_hidden,
42+
"strips all doc(hidden) items from the output"),
43+
("unindent-comments", unindent_comments,
44+
"removes excess indentation on comments in order for markdown to like it"),
45+
("collapse-docs", collapse_docs,
46+
"concatenates all document attributes into one document attribute"),
47+
("strip-private", strip_private,
48+
"strips all private items from a crate which cannot be seen externally, \
49+
implies strip-priv-imports"),
50+
("strip-priv-imports", strip_priv_imports,
51+
"strips all private import statements (`use`, `extern crate`) from a crate"),
52+
];
53+
54+
pub const DEFAULT_PASSES: &'static [&'static str] = &[
55+
"strip-hidden",
56+
"strip-private",
57+
"collapse-docs",
58+
"unindent-comments",
59+
];
60+
61+
3562
struct Stripper<'a> {
3663
retained: &'a mut DefIdSet,
3764
access_levels: &'a AccessLevels<DefId>,

0 commit comments

Comments
 (0)