about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuietMisdreavus <grey@quietmisdreavus.net>2017-12-21 15:15:07 -0600
committerManish Goregaokar <manishsmail@gmail.com>2018-01-22 15:21:28 +0530
commit5db40f775415a9c006a14ebe65b88bcee31976ea (patch)
tree178a9526856db0375fb873ec6205d50c51f6e46e
parent473fcfd49a1bdb3981e7354165f98af04f847df1 (diff)
downloadrust-5db40f775415a9c006a14ebe65b88bcee31976ea.tar.gz
rust-5db40f775415a9c006a14ebe65b88bcee31976ea.zip
add RenderType to DocContext
-rw-r--r--src/librustdoc/core.rs7
-rw-r--r--src/librustdoc/lib.rs7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index ef7d5b5ff84..6cbbe1fdf44 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -35,6 +35,7 @@ use std::path::PathBuf;
 use visit_ast::RustdocVisitor;
 use clean;
 use clean::Clean;
+use html::markdown::RenderType;
 use html::render::RenderInfo;
 
 pub use rustc::session::config::Input;
@@ -54,6 +55,8 @@ pub struct DocContext<'a, 'tcx: 'a> {
     pub renderinfo: RefCell<RenderInfo>,
     /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
     pub external_traits: RefCell<FxHashMap<DefId, clean::Trait>>,
+    /// Which markdown renderer to use when extracting links.
+    pub render_type: RenderType,
 
     // The current set of type and lifetime substitutions,
     // for expanding type aliases at the HIR level:
@@ -104,7 +107,8 @@ pub fn run_core(search_paths: SearchPaths,
                 triple: Option<String>,
                 maybe_sysroot: Option<PathBuf>,
                 allow_warnings: bool,
-                force_unstable_if_unmarked: bool) -> (clean::Crate, RenderInfo)
+                force_unstable_if_unmarked: bool,
+                render_type: RenderType) -> (clean::Crate, RenderInfo)
 {
     // Parse, resolve, and typecheck the given crate.
 
@@ -207,6 +211,7 @@ pub fn run_core(search_paths: SearchPaths,
             access_levels: RefCell::new(access_levels),
             external_traits: Default::default(),
             renderinfo: Default::default(),
+            render_type,
             ty_substs: Default::default(),
             lt_substs: Default::default(),
         };
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 2e2dba7681c..01c2a5620da 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -503,6 +503,11 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
     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("enable-commonmark") {
+        RenderType::Pulldown
+    } else {
+        RenderType::Hoedown
+    };
 
     info!("starting to run rustc");
     let display_warnings = matches.opt_present("display-warnings");
@@ -517,7 +522,7 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
 
         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");