Fix tiny bugs

This commit is contained in:
Chris de Graaf 2017-08-14 21:39:14 -05:00
parent 5dc80dddc5
commit a40f5bea71
2 changed files with 14 additions and 16 deletions

View File

@ -63,7 +63,7 @@ function generate(pkg_name::AbstractString, t::Template; force::Bool=false)
end end
LibGit2.add!(repo, files...) LibGit2.add!(repo, files...)
info("Added files/directories to git: $(join(files, ", "))") info("Staged $(length(files)) files/directories: $(join(files, ", "))")
LibGit2.commit(repo, "Files generated by PkgTemplates") LibGit2.commit(repo, "Files generated by PkgTemplates")
info("Committed files generated by PkgTemplates") info("Committed files generated by PkgTemplates")
info("Finished") info("Finished")
@ -217,13 +217,15 @@ function gen_tests(pkg_dir::AbstractString)
end end
""" """
gen_file(file_path::AbstractString, text::AbstractString) -> Void gen_file(file_path::AbstractString, text::AbstractString) -> Int
Create a new file containing some given text. Always ends the file with a newline. Create a new file containing some given text. Always ends the file with a newline.
# Arguments # Arguments
* `file::AbstractString`: Path to the file to be created. * `file::AbstractString`: Path to the file to be created.
* `text::AbstractString`: Text to write to the file. * `text::AbstractString`: Text to write to the file.
Returns the number of bytes written to the file.
""" """
function gen_file(file::AbstractString, text::AbstractString) function gen_file(file::AbstractString, text::AbstractString)
mkpath(dirname(file)) mkpath(dirname(file))
@ -231,7 +233,7 @@ function gen_file(file::AbstractString, text::AbstractString)
text *= "\n" text *= "\n"
end end
open(file, "w") do fp open(file, "w") do fp
write(fp, text) return write(fp, text)
end end
end end
@ -260,7 +262,7 @@ end
pkg_name::AbstractString, pkg_name::AbstractString,
pkg_template::Template; pkg_template::Template;
view::Dict{String, Any}=Dict{String, Any}(), view::Dict{String, Any}=Dict{String, Any}(),
) ) -> String
Replace placeholders in `template`. The input string is not modified. Replace placeholders in `template`. The input string is not modified.
@ -276,7 +278,7 @@ function substitute(
template::AbstractString, template::AbstractString,
pkg_name::AbstractString, pkg_name::AbstractString,
pkg_template::Template; pkg_template::Template;
view::Dict{String, String}=Dict{String, String}(), view::Dict{String, Any}=Dict{String, Any}(),
) )
# Don't use version_floor here because we don't want the trailing '-' on prereleases. # Don't use version_floor here because we don't want the trailing '-' on prereleases.
d = merge!(Dict{String, Any}(), view) d = merge!(Dict{String, Any}(), view)

View File

@ -34,22 +34,18 @@ Generate Markdown badges for the current package.
Returns an array of Markdown badges. Returns an array of Markdown badges.
""" """
function badges(_::GitHubPages, t::Template, pkg_name::AbstractString) function badges(_::GitHubPages, t::Template, pkg_name::AbstractString)
if haskey(t.plugins, TravisCI) user = strip(URI(t.remote_prefix).path, '/')
user = strip(URI(t.remote_prefix).path, '/') return [
return [ "[![stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://$user.github.io/$pkg_name.jl/stable)"
"[![stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://$user.github.io/$pkg_name.jl/stable)" "[![latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://$user.github.io/$pkg_name.jl/latest)"
"[![latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://$user.github.io/$pkg_name.jl/latest)" ]
]
end
return String[]
end end
""" """
gen_plugin(plugin::GitHubPages, template::Template, pkg_name::AbstractString) gen_plugin(plugin::GitHubPages, template::Template, pkg_name::AbstractString)
Generate the "docs" folder and set up direct HTML output from Documenter to be pushed to Generate the "docs" directory and set up direct HTML output from Documenter to be pushed
GitHub Pages. to GitHub Pages.
# Arguments # Arguments
* `plugin::GitHubPages`: Plugin whose files are being generated. * `plugin::GitHubPages`: Plugin whose files are being generated.