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

enable colored print for REPL output #1691

Merged
merged 2 commits into from
Sep 7, 2021

Conversation

aviatesk
Copy link
Contributor

@aviatesk aviatesk commented Sep 6, 2021

Won't be enabled for doctests (so I believe this should be safe).

Won't be enabled for doctests (so I believe this should be safe).
@KristofferC
Copy link
Member

Regarding doctests, how about producing colored output but stripping it before the comparison is made? I guess some people would not want that but it could be optional?

@aviatesk
Copy link
Contributor Author

aviatesk commented Sep 6, 2021

it could be optional?

So that people can do something like ?

julia> printstyled("red"; color=:red)
\e[31mred\e[39m

Honestly, I'm not super willing to support it. Maybe we can delay the support to the future until when someone finds it useful ?

@KristofferC
Copy link
Member

No, I meant so that people can still do:

```jldoctest
julia> @test 1==1
Test Passed
```

but have Test Passed written in green (like in the REPL).

@aviatesk
Copy link
Contributor Author

aviatesk commented Sep 6, 2021

Ah, I see. But it seems it requires much refactors in order to replace the contents of generated document with the actual outputs of doctests.

@KristofferC
Copy link
Member

KristofferC commented Sep 6, 2021

It was probably bad form of me to comment on this PR. It wasn't really meant as anything that should be done here, it was just a related thought I hade when I read the PR description. I should just open a separate issue.

@fredrikekre
Copy link
Member

Do you have an example of what this enables?

@aviatesk
Copy link
Contributor Author

aviatesk commented Sep 6, 2021

It was probably bad form of me to comment on this PR. It wasn't really meant as anything that should be done here, it was just a related thought I hade when I read the PR description. I should just open a separate issue.

I see. Thanks for the clarification :)

Do you have an example of what this enables?

An object may implement its own show method that may use color when enabled.
Probably the easiest repro would be something like:

```@repl; ansicolor=true
struct Foo end
Base.show(io::IO, ::Foo) = printstyled(io, "Foo"; color = :blue)

Foo()
```

@aviatesk
Copy link
Contributor Author

aviatesk commented Sep 7, 2021

@KristofferC so can this get merged (and maybe can we tag a patch release) ?

@fredrikekre
Copy link
Member

Can you add a note in the changelog?

@aviatesk
Copy link
Contributor Author

aviatesk commented Sep 7, 2021

Sure. Added.

@fredrikekre fredrikekre merged commit f94e12a into JuliaDocs:master Sep 7, 2021
@aviatesk aviatesk deleted the avi/replcolor branch September 7, 2021 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants