From a9df6ccb275f8cb9594110b6d5a0ee7173e356d8 Mon Sep 17 00:00:00 2001 From: fonsp Date: Sun, 27 Sep 2020 09:17:14 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=AE=20Added=20Dump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project.toml | 2 +- src/Terminal.jl | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 31cef290..129d4e59 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlutoUI" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" authors = ["Fons van der Plas "] -version = "0.6.4" +version = "0.6.5" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/Terminal.jl b/src/Terminal.jl index e2b927b2..832d89df 100644 --- a/src/Terminal.jl +++ b/src/Terminal.jl @@ -1,4 +1,4 @@ -export with_terminal +export with_terminal, Dump import Suppressor: @color_output, @capture_out, @capture_err import Logging: ConsoleLogger, with_logger @@ -41,6 +41,8 @@ end ```julia with_terminal(dump, [1,2,[3,4]]) ``` + +See also [PlutoUI.Dump](@ref). """ function with_terminal(f::Function, args...; kwargs...) @@ -62,4 +64,17 @@ function with_terminal(f::Function, args...; kwargs...) $(isempty(spam_err) ? "" : "
" * htmlesc(spam_err) * "
") """) +end + +""" + Dump(x; maxdepth=8) + +Show every part of the representation of a value. The depth of the output is truncated at maxdepth. + +This is a variant of [`Base.dump`](@ref) that returns the representation directly, instead of printing it to stdout. +""" +function Dump(x; maxdepth=8) + sprint() do io + dump(io, x; maxdepth=maxdepth) + end |> Text end \ No newline at end of file