From 87a41f00cd941231e0735a34649b32ad479e5118 Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Mon, 14 Aug 2017 17:49:44 -0500 Subject: [PATCH] Add a line to generated index.md and throw a more specific error --- src/generate.jl | 8 +++++--- src/plugins/documenter.jl | 15 ++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/generate.jl b/src/generate.jl index cd846fa..c1c9798 100644 --- a/src/generate.jl +++ b/src/generate.jl @@ -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 diff --git a/src/plugins/documenter.jl b/src/plugins/documenter.jl index d67e6c6..d29d290 100644 --- a/src/plugins/documenter.jl +++ b/src/plugins/documenter.jl @@ -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")