Add a line to generated index.md and throw a more specific error
This commit is contained in:
parent
f51259b2fd
commit
87a41f00cd
@ -17,7 +17,9 @@ function generate(pkg_name::AbstractString, t::Template; force::Bool=false)
|
|||||||
if force && ispath(pkg_dir)
|
if force && ispath(pkg_dir)
|
||||||
rm(pkg_dir; recursive=true)
|
rm(pkg_dir; recursive=true)
|
||||||
elseif ispath(pkg_dir)
|
elseif ispath(pkg_dir)
|
||||||
error("A package already exists at $pkg_dir, use force=true to overwrite it.")
|
throw(ArgumentError(
|
||||||
|
"A directory already exists at $pkg_dir, use force=true to overwrite it."
|
||||||
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Initialize the repo and configure it.
|
# Initialize the repo and configure it.
|
||||||
@ -29,7 +31,7 @@ function generate(pkg_name::AbstractString, t::Template; force::Bool=false)
|
|||||||
LibGit2.set!(cfg, key, val)
|
LibGit2.set!(cfg, key, val)
|
||||||
end
|
end
|
||||||
info("Finished configuring git")
|
info("Finished configuring git")
|
||||||
url = "$(t.remote_prefix)$pkg_name.jl.git"
|
url = "$(t.remote_prefix)$pkg_name.jl"
|
||||||
LibGit2.commit(repo, "Empty initial commit")
|
LibGit2.commit(repo, "Empty initial commit")
|
||||||
info("Made initial empty commit")
|
info("Made initial empty commit")
|
||||||
LibGit2.set_remote_url(repo, url)
|
LibGit2.set_remote_url(repo, url)
|
||||||
@ -286,7 +288,7 @@ function substitute(
|
|||||||
d["DOCUMENTER"] = true
|
d["DOCUMENTER"] = true
|
||||||
d["AFTER"] = true
|
d["AFTER"] = true
|
||||||
end
|
end
|
||||||
if haskey(t.plugins, CodeCov)
|
if haskey(pkg_template.plugins, CodeCov)
|
||||||
d["CODECOV"] = true
|
d["CODECOV"] = true
|
||||||
d["AFTER"] = true
|
d["AFTER"] = true
|
||||||
end
|
end
|
||||||
|
@ -15,6 +15,7 @@ Generate the "docs" directory with files common to all Documenter subtypes.
|
|||||||
* `pkg_name::AbstractString`: Name of the package.
|
* `pkg_name::AbstractString`: Name of the package.
|
||||||
"""
|
"""
|
||||||
function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractString)
|
function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractString)
|
||||||
|
info("Adding Documenter.jl")
|
||||||
Pkg.add("Documenter")
|
Pkg.add("Documenter")
|
||||||
path = joinpath(template.path, pkg_name)
|
path = joinpath(template.path, pkg_name)
|
||||||
docs_dir = joinpath(path, "docs", "src")
|
docs_dir = joinpath(path, "docs", "src")
|
||||||
@ -24,22 +25,20 @@ function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractSt
|
|||||||
for file in plugin.assets
|
for file in plugin.assets
|
||||||
cp(file, joinpath(docs_dir, "assets", basename(file)))
|
cp(file, joinpath(docs_dir, "assets", basename(file)))
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if isempty(plugin.assets)
|
|
||||||
assets = "[]"
|
|
||||||
else
|
|
||||||
# We want something that looks like the following:
|
# We want something that looks like the following:
|
||||||
# [
|
# [
|
||||||
# assets/file1,
|
# assets/file1,
|
||||||
# assets/file2,
|
# assets/file2,
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
const TAB = repeat(" ", 4)
|
const TAB = repeat(" ", 4)
|
||||||
assets = "[\n"
|
assets = "[\n"
|
||||||
for file in plugin.assets
|
for file in plugin.assets
|
||||||
assets *= """$(TAB^2)"assets/$file",\n"""
|
assets *= """$(TAB^2)"assets/$(basename(file))",\n"""
|
||||||
end
|
end
|
||||||
assets *= "$TAB]"
|
assets *= "$TAB]"
|
||||||
|
|
||||||
|
else
|
||||||
|
assets = "[]"
|
||||||
end
|
end
|
||||||
user = strip(URI(template.remote_prefix).path, '/')
|
user = strip(URI(template.remote_prefix).path, '/')
|
||||||
text = """
|
text = """
|
||||||
@ -59,7 +58,9 @@ function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractSt
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
gen_file(joinpath(dirname(docs_dir), "make.jl"), text)
|
gen_file(joinpath(dirname(docs_dir), "make.jl"), text)
|
||||||
touch(joinpath(docs_dir, "index.md"))
|
open(joinpath(docs_dir, "index.md"), "w") do fp
|
||||||
|
write(fp, "# $pkg_name")
|
||||||
|
end
|
||||||
readme_path = ""
|
readme_path = ""
|
||||||
try
|
try
|
||||||
readme_path = joinpath(template.path, pkg_name, "README.md")
|
readme_path = joinpath(template.path, pkg_name, "README.md")
|
||||||
|
Loading…
Reference in New Issue
Block a user