Add a line to generated index.md and throw a more specific error

This commit is contained in:
Chris de Graaf 2017-08-14 17:49:44 -05:00
parent f51259b2fd
commit 87a41f00cd
2 changed files with 13 additions and 10 deletions

View File

@ -17,7 +17,9 @@ function generate(pkg_name::AbstractString, t::Template; force::Bool=false)
if force && ispath(pkg_dir)
rm(pkg_dir; recursive=true)
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
# 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)
end
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")
info("Made initial empty commit")
LibGit2.set_remote_url(repo, url)
@ -286,7 +288,7 @@ function substitute(
d["DOCUMENTER"] = true
d["AFTER"] = true
end
if haskey(t.plugins, CodeCov)
if haskey(pkg_template.plugins, CodeCov)
d["CODECOV"] = true
d["AFTER"] = true
end

View File

@ -15,6 +15,7 @@ Generate the "docs" directory with files common to all Documenter subtypes.
* `pkg_name::AbstractString`: Name of the package.
"""
function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractString)
info("Adding Documenter.jl")
Pkg.add("Documenter")
path = joinpath(template.path, pkg_name)
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
cp(file, joinpath(docs_dir, "assets", basename(file)))
end
end
if isempty(plugin.assets)
assets = "[]"
else
# We want something that looks like the following:
# [
# assets/file1,
# assets/file2,
# ]
const TAB = repeat(" ", 4)
assets = "[\n"
for file in plugin.assets
assets *= """$(TAB^2)"assets/$file",\n"""
assets *= """$(TAB^2)"assets/$(basename(file))",\n"""
end
assets *= "$TAB]"
else
assets = "[]"
end
user = strip(URI(template.remote_prefix).path, '/')
text = """
@ -59,7 +58,9 @@ function gen_plugin(plugin::Documenter, template::Template, pkg_name::AbstractSt
"""
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 = ""
try
readme_path = joinpath(template.path, pkg_name, "README.md")