Skip to content

Commit

Permalink
rustdoc: add cli argument --playground-url
Browse files Browse the repository at this point in the history
  • Loading branch information
liigo committed Nov 14, 2016
1 parent 87b76a5 commit dc3859d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,8 @@ pub fn run(mut krate: clean::Crate,
clean::NameValue(ref x, ref s)
if "html_playground_url" == *x => {
markdown::PLAYGROUND.with(|slot| {
if slot.borrow().is_none() {
let name = krate.name.clone();
*slot.borrow_mut() = Some((Some(name), s.clone()));
}
let name = krate.name.clone();
*slot.borrow_mut() = Some((Some(name), s.clone()));
});
}
clean::NameValue(ref x, ref s)
Expand Down
8 changes: 8 additions & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ pub fn opts() -> Vec<RustcOptGroup> {
unstable(optmulti("Z", "",
"internal and debugging options (only on nightly build)", "FLAG")),
stable(optopt("", "sysroot", "Override the system root", "PATH")),
stable(optopt("", "playground-url",
"URL to send code snippets to, may be reset by --markdown-playground-url \
or `#![doc(html_playground_url=...)]`",
"URL")),
]
}

Expand Down Expand Up @@ -230,6 +234,10 @@ 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

0 comments on commit dc3859d

Please sign in to comment.