Skip to content

Commit

Permalink
Auto merge of #52257 - steveklabnik:refactor-rustdoc, r=QuietMisdreavus
Browse files Browse the repository at this point in the history
Refactor rustdoc

This is based on #52194 and so shouldn't be merged until it gets merged.

Now that plugin functionality has been removed, let's kill PluginManager. Additionally, rustdoc now follows the standard cargo layout instead of dumping everything at the top level.

r? @rust-lang/rustdoc
  • Loading branch information
bors committed Jul 24, 2018
2 parents 487e961 + 0bf2a06 commit 46804ef
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 72 deletions.
22 changes: 9 additions & 13 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub mod html {
}
pub mod markdown;
pub mod passes;
pub mod plugins;
pub mod visit_ast;
pub mod visit_lib;
pub mod test;
Expand Down Expand Up @@ -750,25 +749,22 @@ where R: 'static + Send,
eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622");
}

// Load all plugins/passes into a PluginManager
let mut pm = plugins::PluginManager::new();
info!("Executing passes");

for pass in &passes {
let plugin = match passes::PASSES.iter()
.position(|&(p, ..)| {
p == *pass
}) {
Some(i) => passes::PASSES[i].1,
// determine if we know about this pass
let pass = match passes::PASSES.iter().find(|(p, ..)| p == pass) {
Some(pass) => pass.1,
None => {
error!("unknown pass {}, skipping", *pass);

continue
},
};
pm.add_plugin(plugin);
}

// Run everything!
info!("Executing passes/plugins");
let krate = pm.run_plugins(krate);
// run it
krate = pass(krate);
}

tx.send(f(Output { krate: krate, renderinfo: renderinfo, passes: passes })).unwrap();
}));
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/passes/collapse_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

use clean::{self, DocFragment, Item};
use plugins;
use fold;
use fold::DocFolder;
use std::mem::replace;
Expand All @@ -31,7 +30,7 @@ impl DocFragment {
}
}

pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
pub fn collapse_docs(krate: clean::Crate) -> clean::Crate {
Collapser.fold_crate(krate)
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::mem;
use clean::{self, GetDefId, Item};
use fold;
use fold::FoldItem::Strip;
use plugins;

mod collapse_docs;
pub use self::collapse_docs::collapse_docs;
Expand All @@ -37,7 +36,7 @@ mod propagate_doc_cfg;
pub use self::propagate_doc_cfg::propagate_doc_cfg;

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

pub const PASSES: &'static [Pass] = &[
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/passes/propagate_doc_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use std::sync::Arc;
use clean::{Crate, Item};
use clean::cfg::Cfg;
use fold::DocFolder;
use plugins::PluginResult;

pub fn propagate_doc_cfg(cr: Crate) -> PluginResult {
pub fn propagate_doc_cfg(cr: Crate) -> Crate {
CfgPropagator { parent_cfg: None }.fold_crate(cr)
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/passes/strip_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ use std::mem;

use clean::{self, AttributesExt, NestedAttributesExt};
use clean::Item;
use plugins;
use fold;
use fold::DocFolder;
use fold::FoldItem::Strip;
use passes::ImplStripper;

/// Strip items marked `#[doc(hidden)]`
pub fn strip_hidden(krate: clean::Crate) -> plugins::PluginResult {
pub fn strip_hidden(krate: clean::Crate) -> clean::Crate {
let mut retained = DefIdSet();

// strip all #[doc(hidden)] items
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/passes/strip_priv_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

use clean;
use fold::DocFolder;
use plugins;
use passes::ImportStripper;

pub fn strip_priv_imports(krate: clean::Crate) -> plugins::PluginResult {
pub fn strip_priv_imports(krate: clean::Crate) -> clean::Crate {
ImportStripper.fold_crate(krate)
}
3 changes: 1 addition & 2 deletions src/librustdoc/passes/strip_private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
use rustc::util::nodemap::DefIdSet;

use clean;
use plugins;
use fold::DocFolder;
use passes::{ImplStripper, ImportStripper, Stripper};

/// Strip private items from the point of view of a crate or externally from a
/// crate, specified by the `xcrate` flag.
pub fn strip_private(mut krate: clean::Crate) -> plugins::PluginResult {
pub fn strip_private(mut krate: clean::Crate) -> clean::Crate {
// This stripper collects all *retained* nodes.
let mut retained = DefIdSet();
let access_levels = krate.access_levels.clone();
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/passes/unindent_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ use std::string::String;
use std::usize;

use clean::{self, DocFragment, Item};
use plugins;
use fold::{self, DocFolder};

pub fn unindent_comments(krate: clean::Crate) -> plugins::PluginResult {
pub fn unindent_comments(krate: clean::Crate) -> clean::Crate {
CommentCleaner.fold_crate(krate)
}

Expand Down
45 changes: 0 additions & 45 deletions src/librustdoc/plugins.rs

This file was deleted.

0 comments on commit 46804ef

Please sign in to comment.