1 // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
15 pub type PluginResult = clean::Crate;
16 pub type PluginCallback = fn (clean::Crate) -> PluginResult;
18 /// Manages loading and running of plugins
19 pub struct PluginManager {
20 callbacks: Vec<PluginCallback> ,
24 /// Create a new plugin manager
25 pub fn new() -> PluginManager {
27 callbacks: Vec::new(),
31 /// Load a normal Rust function as a plugin.
33 /// This is to run passes over the cleaned crate. Plugins run this way
34 /// correspond to the A-aux tag on Github.
35 pub fn add_plugin(&mut self, plugin: PluginCallback) {
36 self.callbacks.push(plugin);
38 /// Run all the loaded plugins over the crate, returning their results
39 pub fn run_plugins(&self, mut krate: clean::Crate) -> clean::Crate {
40 for &callback in &self.callbacks {
41 krate = callback(krate);