Skip to content

Commit d5785a3

Browse files
committed
rustdoc: fix up --playground-url
1 parent 943bf96 commit d5785a3

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/librustdoc/html/render.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ pub fn derive_id(candidate: String) -> String {
428428
/// Generates the documentation for `crate` into the directory `dst`
429429
pub fn run(mut krate: clean::Crate,
430430
external_html: &ExternalHtml,
431+
playground_url: Option<String>,
431432
dst: PathBuf,
432433
passes: FxHashSet<String>,
433434
css_file_extension: Option<PathBuf>,
@@ -452,12 +453,11 @@ pub fn run(mut krate: clean::Crate,
452453
};
453454

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

462462
// Crawl the crate attributes looking for attributes which control how we're
463463
// going to emit HTML

src/librustdoc/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,6 @@ pub fn main_args(args: &[String]) -> isize {
234234
}
235235
};
236236

237-
if let Some(playground) = matches.opt_str("playground-url") {
238-
html::markdown::PLAYGROUND.with(|s| { *s.borrow_mut() = Some((None, playground)); });
239-
}
240-
241237
let test_args = matches.opt_strs("test-args");
242238
let test_args: Vec<String> = test_args.iter()
243239
.flat_map(|s| s.split_whitespace())
@@ -266,6 +262,7 @@ pub fn main_args(args: &[String]) -> isize {
266262
None => return 3
267263
};
268264
let crate_name = matches.opt_str("crate-name");
265+
let playground_url = matches.opt_str("playground-url");
269266

270267
match (should_test, markdown_input) {
271268
(true, true) => {
@@ -287,7 +284,7 @@ pub fn main_args(args: &[String]) -> isize {
287284
info!("going to format");
288285
match output_format.as_ref().map(|s| &**s) {
289286
Some("html") | None => {
290-
html::render::run(krate, &external_html,
287+
html::render::run(krate, &external_html, playground_url,
291288
output.unwrap_or(PathBuf::from("doc")),
292289
passes.into_iter().collect(),
293290
css_file_extension,

src/librustdoc/markdown.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches,
6363
Err(LoadStringError::ReadFail) => return 1,
6464
Err(LoadStringError::BadUtf8) => return 2,
6565
};
66-
if let Some(playground) = matches.opt_str("markdown-playground-url") {
66+
if let Some(playground) = matches.opt_str("markdown-playground-url").or(
67+
matches.opt_str("playground-url")) {
6768
markdown::PLAYGROUND.with(|s| { *s.borrow_mut() = Some((None, playground)); });
6869
}
6970

0 commit comments

Comments
 (0)