Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When doing HTML rendering the crate name needs to be set so the correct extern crate can be added to the code. The first item in the tuple is the crate name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do that in follow up PR, thanks @ollie27 !

}

let test_args = matches.opt_strs("test-args");
let test_args: Vec<String> = test_args.iter()
.flat_map(|s| s.split_whitespace())
Expand Down