Skip to content
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

Use --color=always in rustdoc command when stderr is tty #360

Merged
merged 4 commits into from
Feb 21, 2023

Conversation

tonowak
Copy link
Collaborator

@tonowak tonowak commented Feb 9, 2023

Fixes #326

@tonowak tonowak requested a review from obi1kenobi February 9, 2023 15:28
@tonowak tonowak force-pushed the color-always-rustdoc branch from 81d533a to 8e0be8c Compare February 9, 2023 15:29
Comment on lines 86 to 88
if atty::is(atty::Stream::Stderr) {
cmd.arg("--color=always");
}
Copy link
Owner

Choose a reason for hiding this comment

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

Should this reference the GlobalConfig struct's stderr value instead of the global stderr, just in case they are different?

This might need a bit more plumbing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But isn't anyhow::bail! using the normal stderr, and that's where this command's output will go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Owner

@obi1kenobi obi1kenobi Feb 9, 2023

Choose a reason for hiding this comment

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

That is an excellent point!

We should change that too, before a "cargo-semver-checks-as-a-library" user opens an issue about their library polluting their stderr even though they configured its stderr behavior to be something else.

I take it back: bail!() doesn't print to stderr, it's just return Err() with that error message: https://docs.rs/anyhow/latest/anyhow/macro.bail.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. But nevertheless it should use the GlobalConfig, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 8f7d387.

@obi1kenobi
Copy link
Owner

obi1kenobi commented Feb 20, 2023 via email

@tonowak
Copy link
Collaborator Author

tonowak commented Feb 20, 2023

Why is the CI failing? I don't understand it. The compilation error references line numbers in rustdoc_cmd.rs which don't exist (the file is shorter than the line numbers).

@obi1kenobi
Copy link
Owner

Why is the CI failing? I don't understand it. The compilation error references line numbers in rustdoc_cmd.rs which don't exist (the file is shorter than the line numbers).

Possibly due to merging main into this branch first. There's some poorly-documented default behavior of GitHub Actions where PR tests implicitly run on the current branch with main merged into it, IIRC.

I just merged main and if that causes the line numbers to more-or-less match up (because I merged #375 into main first, after this CI run), that might be the cause.

@tonowak tonowak requested a review from obi1kenobi February 21, 2023 08:44
@obi1kenobi obi1kenobi changed the title Using --color=always in rustdoc command when stdout is tty Use --color=always in rustdoc command when stderr is tty Feb 21, 2023
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

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

Nice!

@obi1kenobi obi1kenobi merged commit f219ca4 into obi1kenobi:main Feb 21, 2023
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.

Error output from rustdoc is stripped of color
2 participants