]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/lib.rs
rustc: Load the `rustc_trans` crate at runtime
[rust.git] / src / librustdoc / lib.rs
index 3b43eafb849bdc10f3f69bbc27c2277fb1098ccd..e39fe20310c2851a8288033b32fed37c2376e9a8 100644 (file)
@@ -34,7 +34,7 @@
 extern crate rustc;
 extern crate rustc_data_structures;
 extern crate rustc_const_math;
-extern crate rustc_trans;
+extern crate rustc_trans_utils;
 extern crate rustc_driver;
 extern crate rustc_resolve;
 extern crate rustc_lint;
@@ -242,8 +242,8 @@ pub fn opts() -> Vec<RustcOptGroup> {
                       or `#![doc(html_playground_url=...)]`",
                      "URL")
         }),
-        unstable("enable-commonmark", |o| {
-            o.optflag("", "enable-commonmark", "to enable commonmark doc rendering/testing")
+        unstable("disable-commonmark", |o| {
+            o.optflag("", "disable-commonmark", "to disable commonmark doc rendering/testing")
         }),
         unstable("display-warnings", |o| {
             o.optflag("", "display-warnings", "to print code warnings when testing doc")
@@ -262,6 +262,11 @@ pub fn opts() -> Vec<RustcOptGroup> {
             o.optflag("", "deny-render-differences", "abort doc runs when markdown rendering \
                                                       differences are found")
         }),
+        unstable("themes", |o| {
+            o.optmulti("", "themes",
+                       "additional themes which will be added to the generated docs",
+                       "FILES")
+        }),
     ]
 }
 
@@ -347,10 +352,10 @@ pub fn main_args(args: &[String]) -> isize {
     let css_file_extension = matches.opt_str("e").map(|s| PathBuf::from(&s));
     let cfgs = matches.opt_strs("cfg");
 
-    let render_type = if matches.opt_present("enable-commonmark") {
-        RenderType::Pulldown
-    } else {
+    let render_type = if matches.opt_present("disable-commonmark") {
         RenderType::Hoedown
+    } else {
+        RenderType::Pulldown
     };
 
     if let Some(ref p) = css_file_extension {
@@ -363,6 +368,15 @@ pub fn main_args(args: &[String]) -> isize {
         }
     }
 
+    let mut themes = Vec::new();
+    for theme in matches.opt_strs("themes").iter().map(|s| PathBuf::from(&s)) {
+        if !theme.is_file() {
+            eprintln!("rustdoc: option --themes arguments must all be files");
+            return 1;
+        }
+        themes.push(theme);
+    }
+
     let external_html = match ExternalHtml::load(
             &matches.opt_strs("html-in-header"),
             &matches.opt_strs("html-before-content"),
@@ -411,7 +425,8 @@ pub fn main_args(args: &[String]) -> isize {
                                   renderinfo,
                                   render_type,
                                   sort_modules_alphabetically,
-                                  deny_render_differences)
+                                  deny_render_differences,
+                                  themes)
                     .expect("failed to generate documentation");
                 0
             }
@@ -501,6 +516,11 @@ fn rust_input<R, F>(cratefile: PathBuf, externs: Externs, matches: &getopts::Mat
     let crate_name = matches.opt_str("crate-name");
     let crate_version = matches.opt_str("crate-version");
     let plugin_path = matches.opt_str("plugin-path");
+    let render_type = if matches.opt_present("disable-commonmark") {
+        RenderType::Hoedown
+    } else {
+        RenderType::Pulldown
+    };
 
     info!("starting to run rustc");
     let display_warnings = matches.opt_present("display-warnings");
@@ -515,7 +535,7 @@ fn rust_input<R, F>(cratefile: PathBuf, externs: Externs, matches: &getopts::Mat
 
         let (mut krate, renderinfo) =
             core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
-                           display_warnings, force_unstable_if_unmarked);
+                           display_warnings, force_unstable_if_unmarked, render_type);
 
         info!("finished with rustc");