rustdoc: fix up --playground-url
This commit is contained in:
parent
943bf96300
commit
d5785a368e
3 changed files with 9 additions and 11 deletions
|
@ -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>,
|
||||
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
@ -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) => {
|
||||
|
@ -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,
|
||||
|
|
|
@ -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)); });
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue