diff --git a/src/plugin.jl b/src/plugin.jl index 14589d5..329ee06 100644 --- a/src/plugin.jl +++ b/src/plugin.jl @@ -1,3 +1,5 @@ +import Base.show + """ Generic plugins are plugins that add any number of patterns to the generated package's `.gitignore`, and have at most one associated file to generate. @@ -67,6 +69,23 @@ config template file doesn't follow the generic naming convention, we added anot """ abstract type GenericPlugin <: Plugin end +function show(io::IO, p::GenericPlugin) + t = split(string(typeof(p)), ".")[end] + println(io, "$t:") + + cfg = if isnull(p.src) + "None" + else + dirname(get(p.src)) == DEFAULTS_DIR ? "Default" : get(p.src) + end + println(io, " → Config file: $cfg") + + n = length(p.gitignore) + s = n == 1 ? "" : "s" + print(io, " → $n gitignore entrie$s") + n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))") +end + """ Custom plugins are plugins whose behaviour does not follow the [`GenericPlugin`](@ref) pattern. They can implement [`gen_plugin`](@ref), [`badges`](@ref), and diff --git a/src/plugins/documenter.jl b/src/plugins/documenter.jl index 6bc665e..e95de4b 100644 --- a/src/plugins/documenter.jl +++ b/src/plugins/documenter.jl @@ -1,3 +1,5 @@ +import Base.show + """ Add a `Documenter` subtype to a template's plugins to add support for documentation generation via [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl). @@ -59,6 +61,25 @@ function gen_plugin( end end +function show(io::IO, p::Documenter) + t = split(string(typeof(p)), ".")[end] + println(io, "$t:") + + n = length(p.assets) + s = n == 1 ? "" : "s" + print(io, " → $n asset file$s") + if n == 0 + println(io) + else + println(io, ": $(join(map(a -> replace(a, homedir(), "~"), p.assets), ", "))") + end + + n = length(p.gitignore) + s = n == 1 ? "" : "s" + print(io, " → $n gitignore entrie$s") + n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))") +end + function interactive(plugin_type::Type{<:Documenter}) plugin_name = split(string(plugin_type), ".")[end] print("$plugin_name: Enter any Documenter asset files (separated by spaces) []: ") diff --git a/src/template.jl b/src/template.jl index 5b19abe..905a0e8 100644 --- a/src/template.jl +++ b/src/template.jl @@ -1,3 +1,5 @@ +import Base.show + """ Template(; kwargs...) -> Template @@ -111,6 +113,61 @@ create a template, you can use [`interactive_template`](@ref) instead. end end +function show(io::IO, t::Template) + maybe_none(s::AbstractString) = isempty(string(s)) ? "None" : string(s) + spc = " " + + println(io, "Template:") + println(io, "$spc→ User: $(maybe_none(t.user))") + println(io, "$spc→ Host: $(maybe_none(t.host))") + println(io, "$spc→ License: $(maybe_none(t.license))") + + # We don't care about authors or license years if there is no license. + if !isempty(t.license) + # TODO: Authors could be split into multiple lines if there are more than one. + # Maybe the authors field of Template should be an array (or Dict, see #4). + println(io, "$spc→ Authors: $(maybe_none(t.authors))") + println(io, "$spc→ License years: $(maybe_none(t.years))") + end + + println(io, "$spc→ Package directory: $(replace(maybe_none(t.dir), homedir(), "~"))") + println(io, "$spc→ Precompilation enabled: $(t.precompile ? "yes" : "no")") + println(io, "$spc→ Minimum Julia version: v$(t.julia_version)") + + print(io, "$spc→ Package dependencies: ") + if isempty(t.requirements) + println(io, "None") + else + println(io) + for req in sort(t.requirements) + println(io, "$(spc^2)• $req") + end + end + + print(io, "$spc→ Git configuration options: ") + if isempty(t.gitconfig) + println(io, "None") + else + println(io) + for k in sort(collect(keys(t.gitconfig)); by=string) + println(io, "$(spc^2)• $k = $(t.gitconfig[k])") + end + end + + print(io, "$spc→ Plugins: ") + if isempty(t.plugins) + print(io, "None") + else + for plugin in sort(collect(values(t.plugins)); by=string) + println(io) + buf = IOBuffer() + show(buf, plugin) + print(io, "$(spc^2)• ") + print(io, join(split(String(take!(buf)), "\n"), "\n$(spc^2)")) + end + end +end + """ interactive_template(; fast::Bool=false) -> Template