Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librustdoc refactoring and cleanup. #36729

Merged
merged 6 commits into from
Sep 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 11 additions & 35 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,39 +91,14 @@ pub mod test;

use clean::Attributes;

type Pass = (&'static str, // name
fn(clean::Crate) -> plugins::PluginResult, // fn
&'static str); // description

const PASSES: &'static [Pass] = &[
("strip-hidden", passes::strip_hidden,
"strips all doc(hidden) items from the output"),
("unindent-comments", passes::unindent_comments,
"removes excess indentation on comments in order for markdown to like it"),
("collapse-docs", passes::collapse_docs,
"concatenates all document attributes into one document attribute"),
("strip-private", passes::strip_private,
"strips all private items from a crate which cannot be seen externally, \
implies strip-priv-imports"),
("strip-priv-imports", passes::strip_priv_imports,
"strips all private import statements (`use`, `extern crate`) from a crate"),
];

const DEFAULT_PASSES: &'static [&'static str] = &[
"strip-hidden",
"strip-private",
"collapse-docs",
"unindent-comments",
];

struct Output {
krate: clean::Crate,
renderinfo: html::render::RenderInfo,
passes: Vec<String>,
}

pub fn main() {
const STACK_SIZE: usize = 32000000; // 32MB
const STACK_SIZE: usize = 32_000_000; // 32MB
let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
let s = env::args().collect::<Vec<_>>();
main_args(&s)
Expand Down Expand Up @@ -222,11 +197,11 @@ pub fn main_args(args: &[String]) -> isize {

if matches.opt_strs("passes") == ["list"] {
println!("Available passes for running rustdoc:");
for &(name, _, description) in PASSES {
for &(name, _, description) in passes::PASSES {
println!("{:>20} - {}", name, description);
}
println!("\nDefault passes for rustdoc:");
for &name in DEFAULT_PASSES {
for &name in passes::DEFAULT_PASSES {
println!("{:>20}", name);
}
return 0;
Expand All @@ -235,7 +210,8 @@ pub fn main_args(args: &[String]) -> isize {
if matches.free.is_empty() {
println!("expected an input file to act on");
return 1;
} if matches.free.len() > 1 {
}
if matches.free.len() > 1 {
println!("only one input file may be specified");
return 1;
}
Expand Down Expand Up @@ -410,7 +386,7 @@ fn rust_input(cratefile: &str, externs: Externs, matches: &getopts::Matches) ->
}

if default_passes {
for name in DEFAULT_PASSES.iter().rev() {
for name in passes::DEFAULT_PASSES.iter().rev() {
passes.insert(0, name.to_string());
}
}
Expand All @@ -420,11 +396,11 @@ fn rust_input(cratefile: &str, externs: Externs, matches: &getopts::Matches) ->
.unwrap_or("/tmp/rustdoc/plugins".to_string());
let mut pm = plugins::PluginManager::new(PathBuf::from(path));
for pass in &passes {
let plugin = match PASSES.iter()
.position(|&(p, ..)| {
p == *pass
}) {
Some(i) => PASSES[i].1,
let plugin = match passes::PASSES.iter()
.position(|&(p, ..)| {
p == *pass
}) {
Some(i) => passes::PASSES[i].1,
None => {
error!("unknown pass {}, skipping", *pass);
continue
Expand Down
Loading