-
Notifications
You must be signed in to change notification settings - Fork 13.3k
feat(rustdoc): harmonise error messages #38179
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
So, globally, I like this PR a lot. A bit of uniformization was needed. Just a bit of factorization would be needed like writing a small function to make the two |
Updated, following your advice concerning the helper function, and taking the time to use |
Based on unix tools wording, it follows a standard format: `program_name: context: error message` on stderr, prompting the user to use the `--help` option in case of misuse.
@@ -247,14 +250,16 @@ pub fn main_args(args: &[String]) -> isize { | |||
|
|||
if let Some(ref p) = css_file_extension { | |||
if !p.is_file() { | |||
println!("{}", "--extend-css option must take a css file as input"); | |||
writeln!( |
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.
Why not using print_error
here?
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.
Because the prompting for --help
should only be used for error in the invocation syntax, such as missing operands or missing arguments.
The same goes for every other non-covered call.
@@ -71,7 +71,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, | |||
let mut out = match File::create(&output) { | |||
Err(e) => { | |||
let _ = writeln!(&mut io::stderr(), |
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.
Same comment.
@@ -80,8 +80,10 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, | |||
|
|||
let (metadata, text) = extract_leading_metadata(&input_str); | |||
if metadata.is_empty() { | |||
let _ = writeln!(&mut io::stderr(), | |||
"invalid markdown file: expecting initial line with `% ...TITLE...`"); | |||
let _ = writeln!( |
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.
Same comment.
@@ -132,7 +134,7 @@ pub fn render(input: &str, mut output: PathBuf, matches: &getopts::Matches, | |||
match err { | |||
Err(e) => { | |||
let _ = writeln!(&mut io::stderr(), |
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.
Same comment.
After explanation, it's ok for me. |
/cc @rust-lang/tools |
Sounds good to me! |
Then I r+. Thanks @Michael-Zapata! @bors: r+ |
📌 Commit 430d39d has been approved by |
…GuillaumeGomez feat(rustdoc): harmonise error messages Based on unix tools wording, it follows a standard format: `program_name: context: error message`, potentially prompting the user to use the `--help` option. This is clearly meant to trigger some discussion on #38084, as messages still use `stdout` and `stderr` somewhat arbitrarily, and there are a few `error!()` calls as well.
Based on unix tools wording, it follows a standard format:
program_name: context: error message
, potentially prompting the user to use the--help
option.This is clearly meant to trigger some discussion on #38084, as messages still use
stdout
andstderr
somewhat arbitrarily, and there are a fewerror!()
calls as well.