From 7a844f8aff0c58494b4094b7e48557baf499b727 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Tue, 2 Apr 2024 16:52:19 -0400 Subject: [PATCH 1/4] mention REPL IOContext in pretty-printing docs --- doc/src/manual/types.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/manual/types.md b/doc/src/manual/types.md index 0d7b2795401f1..20a81ccf75721 100644 --- a/doc/src/manual/types.md +++ b/doc/src/manual/types.md @@ -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 From 254a8a5d974393791461bd46dba670256aa999c9 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Tue, 2 Apr 2024 17:42:31 -0400 Subject: [PATCH 2/4] clarify REPL docs too --- stdlib/REPL/docs/src/index.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/REPL/docs/src/index.md b/stdlib/REPL/docs/src/index.md index d2a17e3a6b4a3..7e5688138f122 100644 --- a/stdlib/REPL/docs/src/index.md +++ b/stdlib/REPL/docs/src/index.md @@ -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). +The result (`ans`) 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`. From 6d4dfc6ab916ef7cc1f9660beaf2516bf4bde6a7 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Tue, 2 Apr 2024 17:51:19 -0400 Subject: [PATCH 3/4] the REPL only displays non-nothing results --- stdlib/REPL/docs/src/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/REPL/docs/src/index.md b/stdlib/REPL/docs/src/index.md index 7e5688138f122..2b0348da276b6 100644 --- a/stdlib/REPL/docs/src/index.md +++ b/stdlib/REPL/docs/src/index.md @@ -57,7 +57,7 @@ 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. -The result (`ans`) of executing an expression is displayed by the REPL using the [`show`](@ref) function +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`. From e1ebd8e1b25ea0596ab995956feb87a274f8b8b9 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Wed, 10 Apr 2024 19:52:36 -0400 Subject: [PATCH 4/4] fix trailing whitespace --- stdlib/REPL/docs/src/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/REPL/docs/src/index.md b/stdlib/REPL/docs/src/index.md index 2b0348da276b6..42a9666088ac1 100644 --- a/stdlib/REPL/docs/src/index.md +++ b/stdlib/REPL/docs/src/index.md @@ -59,7 +59,7 @@ work on the standard Windows command prompt due to its limitation at detecting w 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)`). +`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`.