Skip to content

Commit f860859

Browse files
authored
Make docs build less platform-dependent (#808)
* Use Ghostscript_jll * Ghostscript added as dep to Latexify, no need to specify it here * Use Fontconfig to avoid the need for a font install * Now that it's released, update Latexify compat * Turn off fancy exponents for docs build, don't display latex images
1 parent 243efcb commit f860859

File tree

4 files changed

+46
-34
lines changed

4 files changed

+46
-34
lines changed

.github/workflows/documentation.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
runs-on: ubuntu-latest
2929
steps:
3030
- uses: actions/checkout@v5
31-
- run: sudo apt install -y ghostscript fonts-freefont-ttf
3231
- uses: julia-actions/setup-julia@v2
3332
with:
3433
version: 1

docs/Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[deps]
22
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
Fontconfig = "186bb1d3-e1f7-5a2c-a377-96d770f13627"
45
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
56
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
67
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
@@ -14,5 +15,6 @@ Unitful = {path = ".."}
1415

1516
[compat]
1617
Documenter = "1"
17-
Latexify = "0.16.9"
18+
Latexify = "0.16.10"
1819
Plots = "1"
20+
Fontconfig = "0.4"

docs/generate_latex_images.jl

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using LaTeXStrings, Unitful, Latexify, tectonic_jll
1+
using LaTeXStrings, Unitful, Latexify
2+
import tectonic_jll # needed for lightweight LaTeX render
3+
using Fontconfig: format, match, Pattern
4+
5+
# Since the docs can get built on different systems, we need to find a locally installed
6+
# monospaced font that has enough Unicode coverage to handle π
7+
monofont = format(match(Pattern(spacing=100, charset="3c0")), "%{family}")
28

39
commands = [
410
:(latexify(612.2u"nm")),
@@ -19,11 +25,16 @@ end
1925
ltab1 = latextabular(tab1, adjustment=:l, transpose=true, latex=false, booktabs=true,
2026
head=["julia", "\\LaTeX", "Result"])
2127
# Setting an explicit white background color results in transparent PDF, so go offwhite.
22-
ltab1 = LaTeXString("\\definecolor{offwhite}{rgb}{0.999,0.999,0.999}\n\\pagecolor{offwhite}\n\\color{black}\n" * ltab1)
28+
ltab1 = LaTeXString("""
29+
\\setmonofont{$monofont}
30+
\\definecolor{offwhite}{rgb}{0.999,0.999,0.999}
31+
\\pagecolor{offwhite}
32+
\\color{black}
33+
""" * ltab1)
2334

24-
render(ltab1, MIME("image/png"); use_tectonic=true,
35+
render(ltab1, MIME("image/png"); use_tectonic=true, open=false,
2536
name=(@__DIR__)*"/src/assets/latex-examples",
26-
packages=["booktabs", "color", "siunitx"],
37+
packages=["booktabs", "color", "siunitx", "fontspec"],
2738
documentclass=("standalone"))
2839

2940
functions = [
@@ -133,14 +144,13 @@ ltab2 = latextabular(tab2, adjustment=:l, transpose=true, latex=false, booktabs=
133144
# Set background to not-quite-white so it doesn't get treated as transparent
134145
ltab2 = LaTeXString(
135146
"""
136-
\\setmainfont{FreeSerif}
137-
\\setmonofont{FreeMono}
147+
\\setmonofont{$monofont}
138148
\\definecolor{offwhite}{rgb}{0.999,0.999,0.999}
139149
\\pagecolor{offwhite}
140150
\\color{black}
141151
""" * ltab2)
142152

143-
render(ltab2, MIME("image/png"); use_tectonic=true,
153+
render(ltab2, MIME("image/png"); use_tectonic=true, open=false,
144154
tectonic_flags=`-Z continue-on-errors`,
145155
name=(@__DIR__)*"/src/assets/latex-allunits",
146156
packages=["booktabs", "color", "siunitx", "fontspec"],

docs/make.jl

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@ using Documenter, Unitful, Dates
44
include("generate_latex_images.jl")
55

66
DocMeta.setdocmeta!(Unitful, :DocTestSetup, :(using Unitful))
7-
8-
makedocs(
9-
sitename = "Unitful.jl",
10-
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
11-
warnonly = [:missing_docs],
12-
modules = [Unitful],
13-
workdir = joinpath(@__DIR__, ".."),
14-
pages = [
15-
"Home" => "index.md"
16-
"Highlighted features" => "highlights.md"
17-
"Types" => "types.md"
18-
"Defining new units" => "newunits.md"
19-
"Conversion/promotion" => "conversion.md"
20-
"Manipulating units" => "manipulations.md"
21-
"How units are displayed" => "display.md"
22-
"Logarithmic scales" => "logarithm.md"
23-
"Temperature scales" => "temperature.md"
24-
"Interoperability with `Dates`" => "dates.md"
25-
"Latexifying units" => "latexify.md"
26-
"Extending Unitful" => "extending.md"
27-
"Troubleshooting" => "trouble.md"
28-
"Pre-defined dimensions, units, and constants" => "defaultunits.md"
29-
"License" => "LICENSE.md"
30-
]
31-
)
7+
withenv("UNITFUL_FANCY_EXPONENTS" => "false") do
8+
makedocs(
9+
sitename = "Unitful.jl",
10+
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
11+
warnonly = [:missing_docs],
12+
modules = [Unitful],
13+
workdir = joinpath(@__DIR__, ".."),
14+
pages = [
15+
"Home" => "index.md"
16+
"Highlighted features" => "highlights.md"
17+
"Types" => "types.md"
18+
"Defining new units" => "newunits.md"
19+
"Conversion/promotion" => "conversion.md"
20+
"Manipulating units" => "manipulations.md"
21+
"How units are displayed" => "display.md"
22+
"Logarithmic scales" => "logarithm.md"
23+
"Temperature scales" => "temperature.md"
24+
"Interoperability with `Dates`" => "dates.md"
25+
"Latexifying units" => "latexify.md"
26+
"Extending Unitful" => "extending.md"
27+
"Troubleshooting" => "trouble.md"
28+
"Pre-defined dimensions, units, and constants" => "defaultunits.md"
29+
"License" => "LICENSE.md"
30+
]
31+
)
32+
end
3233

3334
deploydocs(repo = "github.com/JuliaPhysics/Unitful.jl.git")

0 commit comments

Comments
 (0)