Skip to content

Commit

Permalink
Use output_format = documenter_output (#35)
Browse files Browse the repository at this point in the history
* Use `output_format = documenter_output`

* Apply JuliaFormatter
  • Loading branch information
rikhuijzer authored Feb 4, 2022
1 parent 34da72f commit 87561c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
29 changes: 6 additions & 23 deletions docs/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,19 @@ tutorials_dir = joinpath(pkgdir(TuringGLM), "docs", "src", "tutorials")
function build()
println("Building tutorials")
# Evaluate notebooks in the same process to avoid having to recompile from scratch each time.
# This is similar to how Documenter and Franklin evaluate code.
# Note that things like method overrides and other global changes may leak between notebooks!
use_distributed = false
bopts = BuildOptions(tutorials_dir; use_distributed)
output_format = documenter_output
bopts = BuildOptions(tutorials_dir; use_distributed, output_format)
parallel_build(bopts)
return nothing
end

"Generate tutorials Markdown files which can be read by Documenter.jl"
function generate_markdown_files()
"Return Markdown file links which can be passed to Documenter.jl."
function markdown_files()
md_files = map(tutorials) do tutorial
file = lowercase(replace(tutorial, " " => '_'))

from = joinpath(tutorials_dir, "$file.html")
html = read(from, String)

md = """
# $tutorial
```@eval
# Auto generated file. Do not modify.
```
```@raw html
$html
```
"""

to = joinpath(tutorials_dir, "$file.md")
println("Writing $to")
write(to, md)

return joinpath("tutorials", "$file.md")
end
return md_files
Expand Down
5 changes: 3 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ tutorials = [
include("build.jl")

build()
md_files = generate_markdown_files()
md_files = markdown_files()
T = [t => f for (t, f) in zip(tutorials, md_files)]

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

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

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

2 comments on commit 87561c2

@storopoli
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/53876

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" 87561c2da4ca1b6dc0410fbcc475115716e15a1e
git push origin v1.0.0

Please sign in to comment.