Navigation Menu

Skip to content

Commit

Permalink
rustdoc: fix up --playground-url
Browse files Browse the repository at this point in the history
  • Loading branch information
liigo committed Nov 30, 2016
1 parent 943bf96 commit d5785a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/librustdoc/html/render.rs
Expand Up @@ -428,6 +428,7 @@ pub fn derive_id(candidate: String) -> String {
/// Generates the documentation for `crate` into the directory `dst`
pub fn run(mut krate: clean::Crate,
external_html: &ExternalHtml,
playground_url: Option<String>,
dst: PathBuf,
passes: FxHashSet<String>,
css_file_extension: Option<PathBuf>,
Expand All @@ -452,12 +453,11 @@ pub fn run(mut krate: clean::Crate,
};

// If user passed in `--playground-url` arg, we fill in crate name here
markdown::PLAYGROUND.with(|slot| {
if slot.borrow().is_some() {
let url = slot.borrow().as_ref().unwrap().1.clone();
if let Some(url) = playground_url {
markdown::PLAYGROUND.with(|slot| {
*slot.borrow_mut() = Some((Some(krate.name.clone()), url));
}
});
});
}

// Crawl the crate attributes looking for attributes which control how we're
// going to emit HTML
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/lib.rs
Expand Up @@ -234,10 +234,6 @@ pub fn main_args(args: &[String]) -> isize {
}
};

if let Some(playground) = matches.opt_str("playground-url") {
html::markdown::PLAYGROUND.with(|s| { *s.borrow_mut() = Some((None, playground)); });
}

let test_args = matches.opt_strs("test-args");
let test_args: Vec<String> = test_args.iter()
.flat_map(|s| s.split_whitespace())
Expand Down Expand Up @@ -266,6 +262,7 @@ pub fn main_args(args: &[String]) -> isize {
None => return 3
};
let crate_name = matches.opt_str("crate-name");
let playground_url = matches.opt_str("playground-url");

match (should_test, markdown_input) {
(true, true) => {
Expand All @@ -287,7 +284,7 @@ pub fn main_args(args: &[String]) -> isize {
info!("going to format");
match output_format.as_ref().map(|s| &**s) {
Some("html") | None => {
html::render::run(krate, &external_html,
html::render::run(krate, &external_html, playground_url,
output.unwrap_or(PathBuf::from("doc")),
passes.into_iter().collect(),
css_file_extension,
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/markdown.rs
Expand Up @@ -63,7 +63,8 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
Err(LoadStringError::ReadFail) => return 1,
Err(LoadStringError::BadUtf8) => return 2,
};
if let Some(playground) = matches.opt_str("markdown-playground-url") {
if let Some(playground) = matches.opt_str("markdown-playground-url").or(
matches.opt_str("playground-url")) {
markdown::PLAYGROUND.with(|s| { *s.borrow_mut() = Some((None, playground)); });
}

Expand Down

0 comments on commit d5785a3

Please sign in to comment.