Skip to content

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

Merged
merged 1 commit into from Dec 13, 2016
Merged

feat(rustdoc): harmonise error messages #38179

merged 1 commit into from Dec 13, 2016

Conversation

ghost
Copy link

@ghost ghost commented Dec 5, 2016

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.

@rust-highfive
Copy link
Contributor

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.

@GuillaumeGomez
Copy link
Member

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 println! at once. But once again, I don't have strong feelings about it.

@ghost
Copy link
Author

ghost commented Dec 12, 2016

Updated, following your advice concerning the helper function, and taking the time to use stderr where relevant.

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!(
Copy link
Member

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?

Copy link
Author

@ghost ghost Dec 12, 2016

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(),
Copy link
Member

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!(
Copy link
Member

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(),
Copy link
Member

Choose a reason for hiding this comment

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

Same comment.

@GuillaumeGomez
Copy link
Member

After explanation, it's ok for me.

@steveklabnik
Copy link
Member

/cc @rust-lang/tools

@alexcrichton
Copy link
Member

Sounds good to me!

@GuillaumeGomez
Copy link
Member

Then I r+.

Thanks @Michael-Zapata!

@bors: r+

@bors
Copy link
Collaborator

bors commented Dec 12, 2016

📌 Commit 430d39d has been approved by GuillaumeGomez

@bors
Copy link
Collaborator

bors commented Dec 13, 2016

⌛ Testing commit 430d39d with merge b1a2ab8...

bors added a commit that referenced this pull request Dec 13, 2016
…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.
@bors bors merged commit 430d39d into rust-lang:master Dec 13, 2016
@ghost ghost deleted the rf/harmonise_rustdoc_errors branch December 13, 2016 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants