From a40f5bea71af79c4731aeca6e8b502c8f66a68ab Mon Sep 17 00:00:00 2001 From: Chris de Graaf Date: Mon, 14 Aug 2017 21:39:14 -0500 Subject: [PATCH] Fix tiny bugs --- src/generate.jl | 12 +++++++----- src/plugins/githubpages.jl | 18 +++++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/generate.jl b/src/generate.jl index c1c9798..418ef26 100644 --- a/src/generate.jl +++ b/src/generate.jl @@ -63,7 +63,7 @@ function generate(pkg_name::AbstractString, t::Template; force::Bool=false) end 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") info("Committed files generated by PkgTemplates") info("Finished") @@ -217,13 +217,15 @@ function gen_tests(pkg_dir::AbstractString) 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. # Arguments * `file::AbstractString`: Path to the file to be created. * `text::AbstractString`: Text to write to the file. + +Returns the number of bytes written to the file. """ function gen_file(file::AbstractString, text::AbstractString) mkpath(dirname(file)) @@ -231,7 +233,7 @@ function gen_file(file::AbstractString, text::AbstractString) text *= "\n" end open(file, "w") do fp - write(fp, text) + return write(fp, text) end end @@ -260,7 +262,7 @@ end pkg_name::AbstractString, pkg_template::Template; view::Dict{String, Any}=Dict{String, Any}(), - ) + ) -> String Replace placeholders in `template`. The input string is not modified. @@ -276,7 +278,7 @@ function substitute( template::AbstractString, pkg_name::AbstractString, 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. d = merge!(Dict{String, Any}(), view) diff --git a/src/plugins/githubpages.jl b/src/plugins/githubpages.jl index 2ad6ec3..f3d1f58 100644 --- a/src/plugins/githubpages.jl +++ b/src/plugins/githubpages.jl @@ -34,22 +34,18 @@ Generate Markdown badges for the current package. Returns an array of Markdown badges. """ function badges(_::GitHubPages, t::Template, pkg_name::AbstractString) - if haskey(t.plugins, TravisCI) - user = strip(URI(t.remote_prefix).path, '/') - return [ - "[![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)" - ] - end - return String[] + user = strip(URI(t.remote_prefix).path, '/') + return [ + "[![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)" + ] end - """ 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 -GitHub Pages. +Generate the "docs" directory and set up direct HTML output from Documenter to be pushed +to GitHub Pages. # Arguments * `plugin::GitHubPages`: Plugin whose files are being generated.