add RenderType to DocContext

This commit is contained in:
QuietMisdreavus 2017-12-21 15:15:07 -06:00 committed by Manish Goregaokar
parent 473fcfd49a
commit 5db40f7754
2 changed files with 12 additions and 2 deletions

View File

@ -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(),
};

View File

@ -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");