finish citation
This commit is contained in:
parent
644a1f0e11
commit
9addf49fe6
@ -63,6 +63,7 @@ function generate(
|
||||
gen_require(pkg_dir, t),
|
||||
gen_readme(pkg_dir, t),
|
||||
gen_license(pkg_dir, t),
|
||||
gen_citation(pkg_dir, t),
|
||||
vcat(map(p -> gen_plugin(p, t, pkg), values(t.plugins))...),
|
||||
)
|
||||
|
||||
@ -271,6 +272,35 @@ function gen_license(pkg_dir::AbstractString, t::Template)
|
||||
return ["LICENSE"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_citation(pkg_dir::AbstractString, t::Template) -> Vector{String}
|
||||
|
||||
Create a CITATION.bib in `pkg_dir`.
|
||||
|
||||
# Arguments
|
||||
* `pkg_dir::AbstractString`: The directory in which the files will be generated.
|
||||
* `t::Template`: The template whose CITATION.bib file we are generating.
|
||||
|
||||
Returns an array of generated file/directory names.
|
||||
"""
|
||||
function gen_license(pkg_dir::AbstractString, t::Template)
|
||||
if !t.citation
|
||||
return String[]
|
||||
end
|
||||
pkg = basename(pkg_dir)
|
||||
text = "@misc{$pkg,\n"
|
||||
text *= "\tauthor = {{$(t.author)}},\n"
|
||||
text *= "\ttitle = {{$(pkg).jl}},\n"
|
||||
text *= "\turl = {https://$(t.host)/$(t.user)/$(pkg).jl},\n"
|
||||
text *= "\tversion = {v0.0.1},\n"
|
||||
text *= "\tyear = {$(year(today()))},\n"
|
||||
text *= "\tmonth = {$(month(today()))},\n"
|
||||
text *= "}"
|
||||
|
||||
gen_file(joinpath(pkg_dir, "CITATION.bib"), text)
|
||||
return ["CITATION.bib"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_file(file::AbstractString, text::AbstractString) -> Int
|
||||
|
||||
|
@ -86,7 +86,7 @@ struct Template
|
||||
@warn "Plugin list contained duplicates, only the last of each type was kept"
|
||||
end
|
||||
|
||||
new(user, host, license, authors, dir, julia_version, ssh, manifest, plugin_dict)
|
||||
new(user, host, license, authors, dir, julia_version, ssh, manifest, citation, plugin_dict)
|
||||
end
|
||||
end
|
||||
|
||||
@ -109,6 +109,7 @@ function Base.show(io::IO, t::Template)
|
||||
println(io, spc, "→ Minimum Julia version: v", version_floor(t.julia_version))
|
||||
println(io, spc, "→ SSH remote: ", t.ssh ? "Yes" : "No")
|
||||
println(io, spc, "→ Commit Manifest.toml: ", t.manifest ? "Yes" : "No")
|
||||
println(io, spc, "→ Add CITATION.bib: ", t.citation ? "Yes" : "No")
|
||||
|
||||
print(io, spc, "→ Plugins:")
|
||||
if isempty(t.plugins)
|
||||
@ -214,6 +215,13 @@ function interactive_template(; git::Bool=true, fast::Bool=false)
|
||||
uppercase(readline()) in ["Y", "YES", "T", "TRUE"]
|
||||
end
|
||||
|
||||
kwargs[:citation] = if fast
|
||||
false
|
||||
else
|
||||
print("Add CITATION.bib? [no]: ")
|
||||
uppercase(readline()) in ["Y", "YES", "T", "TRUE"]
|
||||
end
|
||||
|
||||
println("Plugins:")
|
||||
# Only include plugin types which have an `interactive` method.
|
||||
plugin_types = filter(t -> hasmethod(interactive, (Type{t},)), fetch(plugin_types))
|
||||
|
Loading…
Reference in New Issue
Block a user