Skip to content

Commit

Permalink
mention REPL IOContext in pretty-printing docs (#53926)
Browse files Browse the repository at this point in the history
Fix omission in pretty-printing docs mentioned here:
#53678 (comment)

(I think these docs were written before `IOContext` existed?)

Also fixes a corresponding place in the REPL docs, which mentioned the
`IOContext` but omitted `display`. Closes #53678
  • Loading branch information
stevengj authored May 24, 2024
1 parent 1488da8 commit 83edaab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions doc/src/manual/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -1481,8 +1481,8 @@ julia> [Polar(3, 4.0), Polar(4.0,5.3)]
```

where the single-line `show(io, z)` form is still used for an array of `Polar` values. Technically,
the REPL calls `display(z)` to display the result of executing a line, which defaults to `show(stdout, MIME("text/plain"), z)`,
which in turn defaults to `show(stdout, z)`, but you should *not* define new [`display`](@ref)
the REPL calls `display(z)` to display the result `z` of executing a line, which defaults to `show(io, MIME("text/plain"), z)` (where `io` is an [`IOContext`](@ref) wrapper around [`stdout`](@ref)),
which in turn defaults to `show(io, z)`, but you should *not* define new [`display`](@ref)
methods unless you are defining a new multimedia display handler (see [Multimedia I/O](@ref Multimedia-I/O)).

Moreover, you can also define `show` methods for other MIME types in order to enable richer display
Expand Down
4 changes: 3 additions & 1 deletion stdlib/REPL/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ disabled or enabled at will with `REPL.enable_promptpaste(::Bool)`. If it is ena
out by pasting the code block above this paragraph straight into the REPL. This feature does not
work on the standard Windows command prompt due to its limitation at detecting when a paste occurs.

Objects are printed at the REPL using the [`show`](@ref) function with a specific [`IOContext`](@ref).
A non-[`nothing`](@ref) result of executing an expression is displayed by the REPL using the [`show`](@ref) function
with a specific [`IOContext`](@ref) (via [`display`](@ref), which defaults to calling
`show(io, MIME("text/plain"), ans)`, which in turn defaults to `show(io, ans)`).
In particular, the `:limit` attribute is set to `true`.
Other attributes can receive in certain `show` methods a default value if it's not already set,
like `:compact`.
Expand Down

0 comments on commit 83edaab

Please sign in to comment.