-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
make.jl
86 lines (75 loc) · 2.86 KB
/
make.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Documenter
if haskey(ENV, "GITHUB_ACTIONS")
ENV["JULIA_DEBUG"] = "Documenter"
end
deployconfig = Documenter.auto_detect_deploy_system()
Documenter.post_status(deployconfig; type="pending", repo="github.com/fredrikekre/Literate.jl.git")
using Literate
using Plots # to not capture precompilation output
# generate examples
EXAMPLE = joinpath(@__DIR__, "..", "examples", "example.jl")
OUTPUT = joinpath(@__DIR__, "src/generated")
function preprocess(str)
str = replace(str, "x = 123" => "y = 321"; count=1)
return str
end
Literate.markdown(EXAMPLE, OUTPUT, preprocess = preprocess)
Literate.notebook(EXAMPLE, OUTPUT, preprocess = preprocess)
Literate.script(EXAMPLE, OUTPUT, preprocess = preprocess)
# generate the example notebook for the documentation, keep in sync with outputformats.md
Literate.markdown(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; credit = false, name = "name")
Literate.notebook(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; name = "notebook")
Literate.script(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; credit = false)
# Replace the link in outputformats.md
# since that page is not "literated"
if haskey(ENV, "GITHUB_ACTIONS")
folder = Base.CoreLogging.with_logger(Base.CoreLogging.NullLogger()) do
Documenter.deploy_folder(
deployconfig;
repo = "github.com/fredrikekre/Literate.jl.git",
devbranch = "master",
push_preview = true,
devurl = "dev",
).subfolder
end
url = "https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/$(folder)/"
str = read(joinpath(@__DIR__, "src/outputformats.md"), String)
str = replace(str, "[notebook.ipynb](generated/notebook.ipynb)." => "[notebook.ipynb]($(url)generated/notebook.ipynb).")
write(joinpath(@__DIR__, "src/outputformats.md"), str)
end
# Generate changelog
using Changelog
clog = joinpath(@__DIR__, "src", "changelog.md")
Changelog.generate(
Changelog.Documenter(),
joinpath(@__DIR__, "..", "CHANGELOG.md"),
clog;
repo = "fredrikekre/Literate.jl",
)
write(clog, replace(read(clog, String), r"^# Literate.jl changelog"m => "# **9.** Changelog"))
makedocs(
format = Documenter.HTML(
assets = ["assets/custom.css", "assets/favicon.ico"],
prettyurls = true, # haskey(ENV, "GITHUB_ACTIONS"),
canonical = "https://fredrikekre.github.io/Literate.jl/v2",
),
modules = [Literate],
sitename = "Literate.jl",
pages = Any[
"index.md",
"fileformat.md",
"pipeline.md",
"outputformats.md",
"customprocessing.md",
"documenter.md",
"tips.md",
"generated/example.md",
"changelog.md",
],
)
deploydocs(
repo = "github.com/fredrikekre/Literate.jl.git",
push_preview = true,
versions = ["v2" => "v^", "v#.#", "dev" => "dev"],
deploy_config = deployconfig,
)