Browse Source

add credit kwarg to print credits

pull/5/head
Fredrik Ekre 8 years ago
parent
commit
5b6de5954d
  1. 15
      src/Literate.jl

15
src/Literate.jl

@ -116,12 +116,14 @@ end
function replace_default(content, sym; function replace_default(content, sym;
name = error("required kwarg"), name = error("required kwarg"),
documenter = true, documenter = true,
credit = true,
branch = "gh-pages", branch = "gh-pages",
commit = "master" commit = "master"
) )
repls = Pair{Any,Any}[] repls = Pair{Any,Any}[]
# add some shameless advertisement # add some shameless advertisement
if credit
if sym === :jl if sym === :jl
content *= """ content *= """
#- #-
@ -133,6 +135,7 @@ function replace_default(content, sym;
#' *This $(sym === :md ? "page" : "notebook") was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* #' *This $(sym === :md ? "page" : "notebook") was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*
""" """
end end
end
push!(repls, "\r\n" => "\n") # normalize line endings push!(repls, "\r\n" => "\n") # normalize line endings
@ -217,7 +220,7 @@ Keyword arguments:
as comments in the output script. Defaults to `false`. as comments in the output script. Defaults to `false`.
""" """
function script(inputfile, outputdir; preprocess = identity, postprocess = identity, function script(inputfile, outputdir; preprocess = identity, postprocess = identity,
name = filename(inputfile), documenter = true, name = filename(inputfile), documenter = true, credit = true,
keep_comments::Bool=false, kwargs...) keep_comments::Bool=false, kwargs...)
# normalize paths # normalize paths
inputfile = realpath(abspath(inputfile)) inputfile = realpath(abspath(inputfile))
@ -231,7 +234,7 @@ function script(inputfile, outputdir; preprocess = identity, postprocess = ident
content = preprocess(content) content = preprocess(content)
# default replacements # default replacements
content = replace_default(content, :jl; name = name, documenter = documenter) content = replace_default(content, :jl; name = name, documenter = documenter, credit = credit)
# create the script file # create the script file
chunks = parse(content) chunks = parse(content)
@ -290,7 +293,7 @@ Keyword arguments:
if `documenter = false`. if `documenter = false`.
""" """
function markdown(inputfile, outputdir; preprocess = identity, postprocess = identity, function markdown(inputfile, outputdir; preprocess = identity, postprocess = identity,
name = filename(inputfile), documenter::Bool = true, name = filename(inputfile), documenter::Bool = true, credit = true,
codefence::Pair = documenter ? "```@example $(name)" => "```" : "```julia" => "```", codefence::Pair = documenter ? "```@example $(name)" => "```" : "```julia" => "```",
kwargs...) kwargs...)
# normalize paths # normalize paths
@ -318,7 +321,7 @@ function markdown(inputfile, outputdir; preprocess = identity, postprocess = ide
end end
# default replacements # default replacements
content = replace_default(content, :md; name = name, documenter = documenter) content = replace_default(content, :md; name = name, documenter = documenter, credit = credit)
# create the markdown file # create the markdown file
chunks = parse(content) chunks = parse(content)
@ -378,7 +381,7 @@ Keyword arguments:
section on [Interaction with Documenter](@ref Interaction-with-Documenter). section on [Interaction with Documenter](@ref Interaction-with-Documenter).
""" """
function notebook(inputfile, outputdir; preprocess = identity, postprocess = identity, function notebook(inputfile, outputdir; preprocess = identity, postprocess = identity,
execute::Bool=true, documenter::Bool=true, execute::Bool=true, documenter::Bool=true, credit = true,
name = filename(inputfile), kwargs...) name = filename(inputfile), kwargs...)
# normalize paths # normalize paths
inputfile = realpath(abspath(inputfile)) inputfile = realpath(abspath(inputfile))
@ -393,7 +396,7 @@ function notebook(inputfile, outputdir; preprocess = identity, postprocess = ide
content = preprocess(content) content = preprocess(content)
# default replacements # default replacements
content = replace_default(content, :nb; name = name, documenter = documenter) content = replace_default(content, :nb; name = name, documenter = documenter, credit = credit)
# create the notebook # create the notebook
nb = Dict() nb = Dict()

Loading…
Cancel
Save