-
Notifications
You must be signed in to change notification settings - Fork 946
Add print-only url to rustup doc, fix #1288 #1324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c5739f
6af1c40
fea9c7c
b2b1645
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,6 +293,9 @@ pub fn cli() -> App<'static, 'static> { | |
.alias("docs") | ||
.about("Open the documentation for the current toolchain") | ||
.after_help(DOC_HELP) | ||
.arg(Arg::with_name("print-only") | ||
.long("print-only") | ||
.help("The URL of the local Rust documentation")) | ||
.arg(Arg::with_name("book") | ||
.long("book") | ||
.help("The Rust Programming Language book")) | ||
|
@@ -780,6 +783,7 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> { | |
} | ||
|
||
fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> { | ||
let toolchain = try!(explicit_or_dir_toolchain(cfg, m)); | ||
let doc_url = if m.is_present("book") { | ||
"book/index.html" | ||
} else if m.is_present("std") { | ||
|
@@ -788,6 +792,14 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> { | |
"index.html" | ||
}; | ||
|
||
if m.is_present("print-only") { | ||
let path = toolchain.doc_path(doc_url); | ||
match path { | ||
Ok(v) => return Ok(println!("file:/{}", v.to_str().unwrap())), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will produce a URL like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I'll try to work it out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, shouldn't the URL be just the URL with no platform-specific prefixes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is probably fine - at least on windows the browser is smart enough to turn a path into a |
||
Err(e) => return Err(From::from(e)) | ||
} | ||
} | ||
|
||
Ok(try!(cfg.open_docs_for_dir(&try!(utils::current_dir()), doc_url))) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably wants to be
v.display()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleared the extra files, BTW v.display() for some reason doesn't provide the exact URL. So didn't change that part. Thanks.