From 308e4e9b1404390b18fb535f3f379c849b1561b5 Mon Sep 17 00:00:00 2001 From: Jared Lumpe Date: Thu, 2 Sep 2021 10:17:44 -0600 Subject: [PATCH 1/3] Use new representation of Vector type in docstrings/tests --- docs/src/implementing.md | 2 +- src/printing.jl | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/src/implementing.md b/docs/src/implementing.md index 9ad5772..4c01b1e 100644 --- a/docs/src/implementing.md +++ b/docs/src/implementing.md @@ -52,7 +52,7 @@ tree = MyNode(1, [ # output -7-element Array{Int64,1}: +7-element Vector{Int64}: 3 4 2 diff --git a/src/printing.jl b/src/printing.jl index 4545a57..c669bf0 100644 --- a/src/printing.jl +++ b/src/printing.jl @@ -25,15 +25,15 @@ Print a text representation of `tree` to the given `io` object. julia> tree = [1:3, "foo", [[[4, 5], 6, 7], 8]]; julia> print_tree(tree) -Array{Any,1} +Vector{Any} ├─ UnitRange{Int64} │ ├─ 1 │ ├─ 2 │ └─ 3 ├─ "foo" -└─ Array{Any,1} - ├─ Array{Any,1} - │ ├─ Array{Int64,1} +└─ Vector{Any} + ├─ Vector{Any} + │ ├─ Vector{Int64} │ │ ├─ 4 │ │ └─ 5 │ ├─ 6 @@ -41,28 +41,28 @@ Array{Any,1} └─ 8 julia> print_tree(tree, maxdepth=2) -Array{Any,1} +Vector{Any} ├─ UnitRange{Int64} │ ├─ 1 │ ├─ 2 │ └─ 3 ├─ "foo" -└─ Array{Any,1} - ├─ Array{Any,1} +└─ Vector{Any} + ├─ Vector{Any} │ ⋮ │ └─ 8 julia> print_tree(tree, charset=AbstractTrees.ASCII_CHARSET) -Array{Any,1} +Vector{Any} +-- UnitRange{Int64} | +-- 1 | +-- 2 | \\-- 3 +-- "foo" -\\-- Array{Any,1} - +-- Array{Any,1} - | +-- Array{Int64,1} +\\-- Vector{Any} + +-- Vector{Any} + | +-- Vector{Int64} | | +-- 4 | | \\-- 5 | +-- 6 From 08bdd85cf28224b11a7edf419784e824e5412bf9 Mon Sep 17 00:00:00 2001 From: Jared Lumpe Date: Thu, 2 Sep 2021 10:18:05 -0600 Subject: [PATCH 2/3] Fix bad link in documentation --- docs/src/implementing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/implementing.md b/docs/src/implementing.md index 4c01b1e..005cca6 100644 --- a/docs/src/implementing.md +++ b/docs/src/implementing.md @@ -99,9 +99,9 @@ if possible: ## Printing -[`print_tree`](@ref) calls the [`printnode`](@ref) function to display the representation of each -node in the tree. The default implementation uses the output of `Base.show` (with an appropriate -`IOContext`). You may override this to customize how your tree is printed: +[`print_tree`](@ref) calls the [`AbstractTrees.printnode`](@ref) function to display the +representation of each node in the tree. The default implementation uses the output of `Base.show` +(with an appropriate `IOContext`). You may override this to customize how your tree is printed: ```jldoctest mynode AbstractTrees.printnode(io::IO, node::MyNode) = print(io, "MyNode($(node.data))") From b463a85d0d00f3a3b6409ed34abf608f2d3cf9d4 Mon Sep 17 00:00:00 2001 From: Jared Lumpe Date: Thu, 2 Sep 2021 10:19:37 -0600 Subject: [PATCH 3/3] Convert tab indentation to spaces --- src/builtins.jl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/builtins.jl b/src/builtins.jl index 75f7cfb..0e46342 100644 --- a/src/builtins.jl +++ b/src/builtins.jl @@ -12,9 +12,9 @@ children(x::AbstractString) = () children(x::Expr) = x.args function printnode(io::IO, x::Expr) - print(io, "Expr(") - show(io, x.head) - print(io, ")") + print(io, "Expr(") + show(io, x.head) + print(io, ")") end @@ -27,7 +27,7 @@ children(kv::Pair{K,V}) where {K,V} = (kv[2],) printnode(io::IO, ::T) where T <: Union{AbstractArray, AbstractDict} = print(io, T) if isdefined(Core.Compiler, :Timings) - children(t::Core.Compiler.Timings.Timing) = t.children - printnode(io::IO, t::Core.Compiler.Timings.Timing) = print(io, t.time/10^6, "ms: ", t.mi_info) - nodetype(t::Core.Compiler.Timings.Timing) = Core.Compiler.Timings.Timing + children(t::Core.Compiler.Timings.Timing) = t.children + printnode(io::IO, t::Core.Compiler.Timings.Timing) = print(io, t.time/10^6, "ms: ", t.mi_info) + nodetype(t::Core.Compiler.Timings.Timing) = Core.Compiler.Timings.Timing end