Skip to content

Commit

Permalink
Update project link.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrVPlusOne committed Nov 16, 2020
1 parent e922dbb commit 9c6330d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# SimpleTypePrint.jl

[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://MrVPlusOne.github.io/SimpleTypePrint.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://MrVPlusOne.github.io/SimpleTypePrint.jl/dev)
[![Build Status](https://travis-ci.com/MrVPlusOne/SimpleTypePrint.jl.svg?branch=master)](https://travis-ci.com/MrVPlusOne/SimpleTypePrint.jl)
[![Coverage](https://codecov.io/gh/MrVPlusOne/SimpleTypePrint.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/MrVPlusOne/SimpleTypePrint.jl)
[![Build Status](https://travis-ci.com/MrVPlusOne/SimpleTypePrint.svg?branch=master)](https://travis-ci.com/MrVPlusOne/SimpleTypePrint)
[![Coverage](https://codecov.io/gh/MrVPlusOne/SimpleTypePrint/branch/master/graph/badge.svg)](https://codecov.io/gh/MrVPlusOne/SimpleTypePrint)

**Display Julia types in a more human-friendly way.**

Expand Down
26 changes: 17 additions & 9 deletions src/SimpleTypePrint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ end

"""
show_type(io, type; kwargs...)
# Keyword args
- `max_depth=3`: the maximal type AST depth to show. Type arguments deeper than this value
will be printed as `...`.
- `short_type_name=true`: when set to `true`, will print simple type names without their
corresponding module path. e.g. "Name" instead of "ModuleA.ModuleB.Name". Note that the
shorter name will always be used if the type is visible from the current scope.
"""
function show_type(io::IO, @nospecialize(ty::Type); max_depth::Int = 3, short_type_name::Bool = true)
t_var_scope::Set{Symbol} = Set{Symbol}()
Expand Down Expand Up @@ -155,16 +148,31 @@ function show_type(io::IO, @nospecialize(ty::Type); max_depth::Int = 3, short_ty
rec(ty, max_depth)
end

"""
repr_type(ty::Type; kwargs...)::String
"""
repr_type(ty::Type; kwargs...) = sprint((io,t) -> show_type(io,t; kwargs...), ty)

"""
display_simple_types(;kwargs...)
config_type_display(;kwargs...)
Replace `Base.show(io::IO, x::Type)` with the simpler type printing funciton
`show_type`. See `show_type` for details about the available `kwargs`.
`show_type`.
See also: `show_type`, `repr_type`.
"""
function config_type_display(;kwargs...)
@eval Base.show(io::IO, x::Type) = show_type(io, x; $(kwargs)...)
end

"""
# Keyword args
- `max_depth=3`: the maximal type AST depth to show. Type arguments deeper than this value
will be printed as `...`.
- `short_type_name=true`: when set to `true`, will print simple type names without their
corresponding module path. e.g. "Name" instead of "ModuleA.ModuleB.Name". Note that the
shorter name will always be used if the type is visible from the current scope.
"""
show_type, repr_type, config_type_display

end # module SimpleTypePrint

0 comments on commit 9c6330d

Please sign in to comment.