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

Ability to set IOContext in which @example/@repl blocks are run #1450

Closed
nickrobinson251 opened this issue Oct 22, 2020 · 5 comments
Closed

Comments

@nickrobinson251
Copy link

Seems closely related to #942 but unsure if it's the same problem with the same solution

I'd like to print a long Vector in an @example block in the docs (or an @repl block), e.g.

``@example
f() = collect('a':'z') # hide
f()
``

will result in

f()
26-element Array{Char,1}:
 'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
 'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
 'c': ASCII/Unicode U+0063 (category Ll: Letter, lowercase)
 'd': ASCII/Unicode U+0064 (category Ll: Letter, lowercase)
 'e': ASCII/Unicode U+0065 (category Ll: Letter, lowercase)
 'f': ASCII/Unicode U+0066 (category Ll: Letter, lowercase)
 'g': ASCII/Unicode U+0067 (category Ll: Letter, lowercase)
 'h': ASCII/Unicode U+0068 (category Ll: Letter, lowercase)
 'i': ASCII/Unicode U+0069 (category Ll: Letter, lowercase)
 'j': ASCII/Unicode U+006A (category Ll: Letter, lowercase)
 
 'r': ASCII/Unicode U+0072 (category Ll: Letter, lowercase)
 's': ASCII/Unicode U+0073 (category Ll: Letter, lowercase)
 't': ASCII/Unicode U+0074 (category Ll: Letter, lowercase)
 'u': ASCII/Unicode U+0075 (category Ll: Letter, lowercase)
 'v': ASCII/Unicode U+0076 (category Ll: Letter, lowercase)
 'w': ASCII/Unicode U+0077 (category Ll: Letter, lowercase)
 'x': ASCII/Unicode U+0078 (category Ll: Letter, lowercase)
 'y': ASCII/Unicode U+0079 (category Ll: Letter, lowercase)
 'z': ASCII/Unicode U+007A (category Ll: Letter, lowercase)

But i'd like to be able to show the full 26-element output. Is that's possible right now?

(As a workaround i ended up wriitng foreach(println, f()))

@fredrikekre
Copy link
Member

@mortenpi
Copy link
Member

We can leave this open, as this is about at-example/repl blocks and #942 is doctests. But the solution should be the same basically.

DisplayAs is a great workaround, but it would probably be good to support this natively. DisplayAs sets the following IOContext attributes:

IOContext(
    io,
    :compact => false,
    :limit => false,
    :displaysize => (typemax(Int), typemax(Int)),
)

I think we should have some keyword arguments to the at-blocks to control them.

@pdeffebach
Copy link

I think I have the opposite problem. I am making a tutorial with DataFrames and it by default prints all the rows of a DataFrame in the @example blocks. I would like to print a smaller amount.

@fredrikekre
Copy link
Member

tkf/DisplayAs.jl#14

@fredrikekre
Copy link
Member

tkf/DisplayAs.jl#14 is merged and released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants