}
pub mod markdown;
pub mod passes;
-pub mod plugins;
pub mod visit_ast;
pub mod visit_lib;
pub mod test;
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()
+ // determine if we know about this pass
+ let pass = match passes::PASSES.iter().find(|(p, ..)| p == pass) {
+ /*
.position(|&(p, ..)| {
p == *pass
}) {
- Some(i) => passes::PASSES[i].1,
+ */
+ 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();
}));
// except according to those terms.
use clean::{self, DocFragment, Item};
-use plugins;
use fold;
use fold::DocFolder;
use std::mem::replace;
}
}
-pub fn collapse_docs(krate: clean::Crate) -> plugins::PluginResult {
+pub fn collapse_docs(krate: clean::Crate) -> clean::Crate {
Collapser.fold_crate(krate)
}
use clean::{self, GetDefId, Item};
use fold;
use fold::FoldItem::Strip;
-use plugins;
mod collapse_docs;
pub use self::collapse_docs::collapse_docs;
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] = &[
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)
}
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
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)
}
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();
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)
}
+++ /dev/null
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(deprecated)]
-
-use clean;
-
-pub type PluginResult = clean::Crate;
-pub type PluginCallback = fn (clean::Crate) -> PluginResult;
-
-/// Manages loading and running of plugins
-pub struct PluginManager {
- callbacks: Vec<PluginCallback> ,
-}
-
-impl PluginManager {
- /// Create a new plugin manager
- pub fn new() -> PluginManager {
- PluginManager {
- callbacks: Vec::new(),
- }
- }
-
- /// Load a normal Rust function as a plugin.
- ///
- /// This is to run passes over the cleaned crate. Plugins run this way
- /// correspond to the A-aux tag on Github.
- pub fn add_plugin(&mut self, plugin: PluginCallback) {
- self.callbacks.push(plugin);
- }
- /// Run all the loaded plugins over the crate, returning their results
- pub fn run_plugins(&self, mut krate: clean::Crate) -> clean::Crate {
- for &callback in &self.callbacks {
- krate = callback(krate);
- }
- krate
- }
-}