Skip to content

Commit 5db40f7

Browse files
QuietMisdreavusManishearth
authored andcommitted
add RenderType to DocContext
1 parent 473fcfd commit 5db40f7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/librustdoc/core.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use std::path::PathBuf;
3535
use visit_ast::RustdocVisitor;
3636
use clean;
3737
use clean::Clean;
38+
use html::markdown::RenderType;
3839
use html::render::RenderInfo;
3940

4041
pub use rustc::session::config::Input;
@@ -54,6 +55,8 @@ pub struct DocContext<'a, 'tcx: 'a> {
5455
pub renderinfo: RefCell<RenderInfo>,
5556
/// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
5657
pub external_traits: RefCell<FxHashMap<DefId, clean::Trait>>,
58+
/// Which markdown renderer to use when extracting links.
59+
pub render_type: RenderType,
5760

5861
// The current set of type and lifetime substitutions,
5962
// for expanding type aliases at the HIR level:
@@ -104,7 +107,8 @@ pub fn run_core(search_paths: SearchPaths,
104107
triple: Option<String>,
105108
maybe_sysroot: Option<PathBuf>,
106109
allow_warnings: bool,
107-
force_unstable_if_unmarked: bool) -> (clean::Crate, RenderInfo)
110+
force_unstable_if_unmarked: bool,
111+
render_type: RenderType) -> (clean::Crate, RenderInfo)
108112
{
109113
// Parse, resolve, and typecheck the given crate.
110114

@@ -207,6 +211,7 @@ pub fn run_core(search_paths: SearchPaths,
207211
access_levels: RefCell::new(access_levels),
208212
external_traits: Default::default(),
209213
renderinfo: Default::default(),
214+
render_type,
210215
ty_substs: Default::default(),
211216
lt_substs: Default::default(),
212217
};

src/librustdoc/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
503503
let crate_name = matches.opt_str("crate-name");
504504
let crate_version = matches.opt_str("crate-version");
505505
let plugin_path = matches.opt_str("plugin-path");
506+
let render_type = if matches.opt_present("enable-commonmark") {
507+
RenderType::Pulldown
508+
} else {
509+
RenderType::Hoedown
510+
};
506511

507512
info!("starting to run rustc");
508513
let display_warnings = matches.opt_present("display-warnings");
@@ -517,7 +522,7 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
517522

518523
let (mut krate, renderinfo) =
519524
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
520-
display_warnings, force_unstable_if_unmarked);
525+
display_warnings, force_unstable_if_unmarked, render_type);
521526

522527
info!("finished with rustc");
523528

0 commit comments

Comments
 (0)