Skip to content

Commit 87561c2

Browse files
authored
Use output_format = documenter_output (#35)
* Use `output_format = documenter_output` * Apply JuliaFormatter
1 parent 34da72f commit 87561c2

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

docs/build.jl

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,19 @@ tutorials_dir = joinpath(pkgdir(TuringGLM), "docs", "src", "tutorials")
44
function build()
55
println("Building tutorials")
66
# Evaluate notebooks in the same process to avoid having to recompile from scratch each time.
7+
# This is similar to how Documenter and Franklin evaluate code.
8+
# Note that things like method overrides and other global changes may leak between notebooks!
79
use_distributed = false
8-
bopts = BuildOptions(tutorials_dir; use_distributed)
10+
output_format = documenter_output
11+
bopts = BuildOptions(tutorials_dir; use_distributed, output_format)
912
parallel_build(bopts)
1013
return nothing
1114
end
1215

13-
"Generate tutorials Markdown files which can be read by Documenter.jl"
14-
function generate_markdown_files()
16+
"Return Markdown file links which can be passed to Documenter.jl."
17+
function markdown_files()
1518
md_files = map(tutorials) do tutorial
1619
file = lowercase(replace(tutorial, " " => '_'))
17-
18-
from = joinpath(tutorials_dir, "$file.html")
19-
html = read(from, String)
20-
21-
md = """
22-
# $tutorial
23-
24-
```@eval
25-
# Auto generated file. Do not modify.
26-
```
27-
28-
```@raw html
29-
$html
30-
```
31-
"""
32-
33-
to = joinpath(tutorials_dir, "$file.md")
34-
println("Writing $to")
35-
write(to, md)
36-
3720
return joinpath("tutorials", "$file.md")
3821
end
3922
return md_files

docs/make.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ tutorials = [
1616
include("build.jl")
1717

1818
build()
19-
md_files = generate_markdown_files()
19+
md_files = markdown_files()
20+
T = [t => f for (t, f) in zip(tutorials, md_files)]
2021

2122
DocMeta.setdocmeta!(TuringGLM, :DocTestSetup, :(using TuringGLM); recursive=true)
2223

@@ -32,7 +33,7 @@ makedocs(;
3233
mathengine=Documenter.MathJax3(),
3334
prettyurls=get(ENV, "CI", "false") == "true",
3435
),
35-
pages=["Home" => "index.md", "Tutorials" => md_files, "API reference" => "api.md"],
36+
pages=["Home" => "index.md", "Tutorials" => T, "API reference" => "api.md"],
3637
)
3738

3839
deploydocs(; repo="github.com/TuringLang/TuringGLM.jl", devbranch="main")

0 commit comments

Comments
 (0)