Misc style changes
This commit is contained in:
parent
bab42686d8
commit
75c7875899
@ -88,7 +88,7 @@ function generate(
|
|||||||
gen_readme(dir, pkg_name, t),
|
gen_readme(dir, pkg_name, t),
|
||||||
gen_gitignore(dir, pkg_name, t),
|
gen_gitignore(dir, pkg_name, t),
|
||||||
gen_license(dir, pkg_name, t),
|
gen_license(dir, pkg_name, t),
|
||||||
vcat([gen_plugin(plugin, t, dir, pkg_name) for plugin in values(t.plugins)]...),
|
vcat(map(p -> gen_plugin(p, t, dir, pkg_name), values(t.plugins))...),
|
||||||
)
|
)
|
||||||
|
|
||||||
LibGit2.add!(repo, files...)
|
LibGit2.add!(repo, files...)
|
||||||
@ -307,7 +307,7 @@ Returns an array of generated file/directory names.
|
|||||||
"""
|
"""
|
||||||
function gen_gitignore(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
function gen_gitignore(dir::AbstractString, pkg_name::AbstractString, template::Template)
|
||||||
seen = [".DS_Store"]
|
seen = [".DS_Store"]
|
||||||
patterns = vcat([plugin.gitignore for plugin in values(template.plugins)]...)
|
patterns = vcat(map(p -> p.gitignore, values(template.plugins))...)
|
||||||
for pattern in patterns
|
for pattern in patterns
|
||||||
if !in(pattern, seen)
|
if !in(pattern, seen)
|
||||||
push!(seen, pattern)
|
push!(seen, pattern)
|
||||||
@ -390,9 +390,15 @@ end
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
substitute(template::AbstractString, view::Dict{String, Any}) -> String
|
substitute(template::AbstractString, view::Dict{String, Any}) -> String
|
||||||
|
substitute(
|
||||||
|
template::AbstractString,
|
||||||
|
pkg_template::Template;
|
||||||
|
view::Dict{String, Any}=Dict{String, Any}(),
|
||||||
|
) -> String
|
||||||
|
|
||||||
Replace placeholders in `template` with values in `view` via
|
Replace placeholders in `template` with values in `view` via
|
||||||
[`Mustache`](https://github.com/jverzani/Mustache.jl). `template` is not modified.
|
[`Mustache`](https://github.com/jverzani/Mustache.jl). `template` is not modified.
|
||||||
|
If `pkg_template` is supplied, some default replacements are also performed.
|
||||||
|
|
||||||
For information on how to structure `template`, see "Defining Template Files" section in
|
For information on how to structure `template`, see "Defining Template Files" section in
|
||||||
[Custom Plugins](@ref).
|
[Custom Plugins](@ref).
|
||||||
@ -402,16 +408,6 @@ but will simply be evaluated as false.
|
|||||||
"""
|
"""
|
||||||
substitute(template::AbstractString, view::Dict{String, Any}) = render(template, view)
|
substitute(template::AbstractString, view::Dict{String, Any}) = render(template, view)
|
||||||
|
|
||||||
"""
|
|
||||||
substitute(
|
|
||||||
template::AbstractString,
|
|
||||||
pkg_template::Template;
|
|
||||||
view::Dict{String, Any}=Dict{String, Any}(),
|
|
||||||
) -> String
|
|
||||||
|
|
||||||
Replace placeholders in `template`, using some default replacements based on the
|
|
||||||
`pkg_template` and additional ones in `view`. `template` is not modified.
|
|
||||||
"""
|
|
||||||
function substitute(
|
function substitute(
|
||||||
template::AbstractString,
|
template::AbstractString,
|
||||||
pkg_template::Template;
|
pkg_template::Template;
|
||||||
@ -422,7 +418,7 @@ function substitute(
|
|||||||
d = Dict{String, Any}(
|
d = Dict{String, Any}(
|
||||||
"USER" => pkg_template.user,
|
"USER" => pkg_template.user,
|
||||||
"VERSION" => "$(v.major).$(v.minor)",
|
"VERSION" => "$(v.major).$(v.minor)",
|
||||||
"DOCUMENTER" => any(isa(p, Documenter) for p in values(pkg_template.plugins)),
|
"DOCUMENTER" => any(map(p -> isa(p, Documenter), values(pkg_template.plugins))),
|
||||||
"CODECOV" => haskey(pkg_template.plugins, CodeCov),
|
"CODECOV" => haskey(pkg_template.plugins, CodeCov),
|
||||||
"COVERALLS" => haskey(pkg_template.plugins, Coveralls),
|
"COVERALLS" => haskey(pkg_template.plugins, Coveralls),
|
||||||
)
|
)
|
||||||
|
@ -16,7 +16,7 @@ const LICENSES = Dict(
|
|||||||
|
|
||||||
Print the names of all available licenses.
|
Print the names of all available licenses.
|
||||||
"""
|
"""
|
||||||
available_licenses(io::IO) = println(io, join(["$k: $v" for (k, v) in LICENSES], "\n"))
|
available_licenses(io::IO) = println(io, join(("$k: $v" for (k, v) in LICENSES), "\n"))
|
||||||
available_licenses() = available_licenses(STDOUT)
|
available_licenses() = available_licenses(STDOUT)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -71,8 +71,7 @@ abstract type GenericPlugin <: Plugin end
|
|||||||
|
|
||||||
function show(io::IO, p::GenericPlugin)
|
function show(io::IO, p::GenericPlugin)
|
||||||
spc = " "
|
spc = " "
|
||||||
t = split(string(typeof(p)), ".")[end]
|
println(io, "$(Base.datatype_name(typeof(p))):")
|
||||||
println(io, "$t:")
|
|
||||||
|
|
||||||
cfg = if isnull(p.src)
|
cfg = if isnull(p.src)
|
||||||
"None"
|
"None"
|
||||||
@ -245,7 +244,7 @@ badges(plugin::Plugin, user::AbstractString, pkg_name::AbstractString) = String[
|
|||||||
function badges(plugin::GenericPlugin, user::AbstractString, pkg_name::AbstractString)
|
function badges(plugin::GenericPlugin, user::AbstractString, pkg_name::AbstractString)
|
||||||
# Give higher priority to replacements defined in the plugin's view.
|
# Give higher priority to replacements defined in the plugin's view.
|
||||||
view = merge(Dict("USER" => user, "PKGNAME" => pkg_name), plugin.view)
|
view = merge(Dict("USER" => user, "PKGNAME" => pkg_name), plugin.view)
|
||||||
return [substitute(format(badge), view) for badge in plugin.badges]
|
return map(b -> substitute(format(b), view), plugin.badges)
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -62,12 +62,12 @@ function gen_plugin(
|
|||||||
end
|
end
|
||||||
|
|
||||||
function show(io::IO, p::Documenter)
|
function show(io::IO, p::Documenter)
|
||||||
t = split(string(typeof(p)), ".")[end]
|
spc = " "
|
||||||
println(io, "$t:")
|
println(io, "$(Base.datatype_name(typeof(p))):")
|
||||||
|
|
||||||
n = length(p.assets)
|
n = length(p.assets)
|
||||||
s = n == 1 ? "" : "s"
|
s = n == 1 ? "" : "s"
|
||||||
print(io, " → $n asset file$s")
|
print(io, "$spc→ $n asset file$s")
|
||||||
if n == 0
|
if n == 0
|
||||||
println(io)
|
println(io)
|
||||||
else
|
else
|
||||||
@ -76,12 +76,12 @@ function show(io::IO, p::Documenter)
|
|||||||
|
|
||||||
n = length(p.gitignore)
|
n = length(p.gitignore)
|
||||||
s = n == 1 ? "" : "s"
|
s = n == 1 ? "" : "s"
|
||||||
print(io, " → $n gitignore entrie$s")
|
print(io, "$spc→ $n gitignore entrie$s")
|
||||||
n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))")
|
n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))")
|
||||||
end
|
end
|
||||||
|
|
||||||
function interactive(plugin_type::Type{<:Documenter})
|
function interactive(plugin_type::Type{<:Documenter})
|
||||||
plugin_name = split(string(plugin_type), ".")[end]
|
t = Base.datatype_name(plugin_type)
|
||||||
print("$plugin_name: Enter any Documenter asset files (separated by spaces) []: ")
|
print("$t: Enter any Documenter asset files (separated by spaces) []: ")
|
||||||
return plugin_type(; assets=String.(split(readline())))
|
return plugin_type(; assets=String.(split(readline())))
|
||||||
end
|
end
|
||||||
|
@ -92,7 +92,7 @@ create a template, you can use [`interactive_template`](@ref) instead.
|
|||||||
|
|
||||||
requirements_dedup = collect(Set(requirements))
|
requirements_dedup = collect(Set(requirements))
|
||||||
diff = length(requirements) - length(requirements_dedup)
|
diff = length(requirements) - length(requirements_dedup)
|
||||||
names = [tokens[1] for tokens in split.(requirements_dedup)]
|
names = map(t -> first(t), split.(requirements_dedup))
|
||||||
if length(names) > length(Set(names))
|
if length(names) > length(Set(names))
|
||||||
throw(ArgumentError(
|
throw(ArgumentError(
|
||||||
"requirements contains duplicate packages with conflicting versions"
|
"requirements contains duplicate packages with conflicting versions"
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
@testset "Interactive package generation" begin
|
@testset "Interactive package generation" begin
|
||||||
cfg = join(["$(p.first) $(p.second)" for p in gitconfig], "\n")
|
cfg = join(("$k $v" for (k, v) in gitconfig), "\n")
|
||||||
write(STDIN.buffer, "$me\n\n\r\n\n\n\n$cfg\n\nd")
|
write(STDIN.buffer, "$me\n\n\r\n\n\n\n$cfg\n\nd")
|
||||||
generate_interactive(test_pkg)
|
generate_interactive(test_pkg)
|
||||||
@test isdir(Pkg.dir(test_pkg))
|
@test isdir(Pkg.dir(test_pkg))
|
||||||
|
@ -138,7 +138,7 @@ end
|
|||||||
→ License: MIT ($(gitconfig["user.name"]) $(Dates.year(now())))
|
→ License: MIT ($(gitconfig["user.name"]) $(Dates.year(now())))
|
||||||
→ Package directory: $pkgdir
|
→ Package directory: $pkgdir
|
||||||
→ Precompilation enabled: Yes
|
→ Precompilation enabled: Yes
|
||||||
→ Minimum Julia version: v$VERSION
|
→ Minimum Julia version: v$(PkgTemplates.version_floor())
|
||||||
→ 0 package requirements
|
→ 0 package requirements
|
||||||
→ Git configuration options:
|
→ Git configuration options:
|
||||||
• github.user = $(gitconfig["github.user"])
|
• github.user = $(gitconfig["github.user"])
|
||||||
@ -167,7 +167,7 @@ end
|
|||||||
→ License: None
|
→ License: None
|
||||||
→ Package directory: $pkgdir
|
→ Package directory: $pkgdir
|
||||||
→ Precompilation enabled: Yes
|
→ Precompilation enabled: Yes
|
||||||
→ Minimum Julia version: v$VERSION
|
→ Minimum Julia version: v$(PkgTemplates.version_floor())
|
||||||
→ 2 package requirements: Bar, Foo
|
→ 2 package requirements: Bar, Foo
|
||||||
→ Git configuration options:
|
→ Git configuration options:
|
||||||
• github.user = $(gitconfig["github.user"])
|
• github.user = $(gitconfig["github.user"])
|
||||||
@ -288,7 +288,7 @@ end
|
|||||||
@test isfile(Pkg.dir(test_pkg, "test", "runtests.jl"))
|
@test isfile(Pkg.dir(test_pkg, "test", "runtests.jl"))
|
||||||
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
|
||||||
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
branches = map(b -> LibGit2.shortname(first(b)), LibGit2.GitBranchIter(repo))
|
||||||
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
||||||
# Note: This test will fail on your system if you've configured Git
|
# Note: This test will fail on your system if you've configured Git
|
||||||
# to replace all HTTPS URLs with SSH.
|
# to replace all HTTPS URLs with SSH.
|
||||||
@ -334,7 +334,7 @@ end
|
|||||||
@test isfile(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
@test isfile(Pkg.dir(test_pkg, "docs", "src", "index.md"))
|
||||||
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
repo = LibGit2.GitRepo(Pkg.dir(test_pkg))
|
||||||
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
|
||||||
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
|
branches = map(b -> LibGit2.shortname(first(b)), LibGit2.GitBranchIter(repo))
|
||||||
@test in("gh-pages", branches)
|
@test in("gh-pages", branches)
|
||||||
@test !LibGit2.isdirty(repo)
|
@test !LibGit2.isdirty(repo)
|
||||||
rm(Pkg.dir(test_pkg); recursive=true)
|
rm(Pkg.dir(test_pkg); recursive=true)
|
||||||
|
Loading…
Reference in New Issue
Block a user