Browse Source

Apply Runic.jl formatting.

pull/8/head
Fredrik Ekre 12 months ago
parent
commit
e7920eacd8
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 10
      src/EnumX.jl

10
src/EnumX.jl

@ -134,7 +134,8 @@ function enumx(_module_, args)
end end
end end
for (k, v) in name_value_map for (k, v) in name_value_map
push!(module_block.args, push!(
module_block.args,
Expr(:const, Expr(:(=), esc(k), Expr(:call, esc(T), v))) Expr(:const, Expr(:(=), esc(k), Expr(:call, esc(T), v)))
) )
end end
@ -148,7 +149,7 @@ function enumx(_module_, args)
return Expr(:toplevel, Expr(:module, false, esc(modname), module_block), mdoc, #=Tdoc,=# nothing) return Expr(:toplevel, Expr(:module, false, esc(modname), module_block), mdoc, #=Tdoc,=# nothing)
end end
function Base.show(io::IO, ::MIME"text/plain", x::E) where E <: Enum function Base.show(io::IO, ::MIME"text/plain", x::E) where {E <: Enum}
iob = IOBuffer() iob = IOBuffer()
ix = Integer(x) ix = Integer(x)
found = false found = false
@ -165,7 +166,7 @@ function Base.show(io::IO, ::MIME"text/plain", x::E) where E <: Enum
write(io, seekstart(iob)) write(io, seekstart(iob))
return nothing return nothing
end end
function Base.show(io::IO, ::MIME"text/plain", ::Type{E}) where E <: Enum function Base.show(io::IO, ::MIME"text/plain", ::Type{E}) where {E <: Enum}
if !isconcretetype(E) # handle EnumX.Enum and EnumX.Enum{T} if !isconcretetype(E) # handle EnumX.Enum and EnumX.Enum{T}
invoke(show, Tuple{IO, Type}, io, E) invoke(show, Tuple{IO, Type}, io, E)
return return
@ -177,7 +178,8 @@ function Base.show(io::IO, ::MIME"text/plain", ::Type{E}) where E <: Enum
string("$(nameof(parentmodule(E))).", k) => v for (k, v) in symbol_map(E) string("$(nameof(parentmodule(E))).", k) => v for (k, v) in symbol_map(E)
] ]
mx = maximum(x -> textwidth(x.first), stringmap; init = 0) mx = maximum(x -> textwidth(x.first), stringmap; init = 0)
print(iob, print(
iob,
"Enum type $(nameof(parentmodule(E))).$(nameof(E)) <: ", "Enum type $(nameof(parentmodule(E))).$(nameof(E)) <: ",
"Enum{$(Base.Enums.basetype(E))} with $(n) instance$(n == 1 ? "" : "s")$(n > 0 ? ":" : "")" "Enum{$(Base.Enums.basetype(E))} with $(n) instance$(n == 1 ? "" : "s")$(n > 0 ? ":" : "")"
) )

Loading…
Cancel
Save