Skip to content

Commit 08b59aa

Browse files
Ericson2314Qyriadrobertheldritch horrorsMic92
committed
Build the manual with Meson
Co-Authored-By: Qyriad <[email protected]> Co-Authored-By: Robert Hensing <[email protected]> Co-Authored-By: eldritch horrors <[email protected]> Co-authored-by: Jörg Thalheim <[email protected]> Co-authored-by: Tom Bereknyei <[email protected]>
1 parent 67a6621 commit 08b59aa

24 files changed

+805
-3
lines changed

doc/manual/.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.version

doc/manual/book.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,21 @@ additional-js = ["redirects.js"]
77
edit-url-template = "https://github.com/NixOS/nix/tree/master/doc/manual/{path}"
88
git-repository-url = "https://github.com/NixOS/nix"
99

10+
# Handles replacing @docroot@ with a path to ./src relative to that markdown file,
11+
# {{#include handlebars}}, and the @generated@ syntax used within these. it mostly
12+
# but not entirely replaces the links preprocessor (which we cannot simply use due
13+
# to @generated@ files living in a different directory to make meson happy). we do
14+
# not want to disable the links preprocessor entirely though because that requires
15+
# disabling *all* built-in preprocessors and selectively reenabling those we want.
16+
[preprocessor.substitute]
17+
command = "python3 ./substitute.py"
18+
before = ["anchors", "links"]
19+
1020
[preprocessor.anchors]
1121
renderers = ["html"]
12-
command = "jq --from-file doc/manual/anchors.jq"
22+
command = "jq --from-file ./anchors.jq"
23+
24+
[output.markdown]
1325

1426
[output.linkcheck]
1527
# no Internet during the build (in the sandbox)

doc/manual/generate-deps.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
3+
import glob
4+
import sys
5+
6+
# meson expects makefile-style dependency declarations, i.e.
7+
#
8+
# target: dependency...
9+
#
10+
# meson seems to pass depfiles straight on to ninja even though
11+
# it also parses the file itself (or at least has code to do so
12+
# in its tree), so we must live by ninja's rules: only slashes,
13+
# spaces and octothorpes can be escaped, anything else is taken
14+
# literally. since the rules for these aren't even the same for
15+
# all three we will just fail when we encounter any of them (if
16+
# asserts are off for some reason the depfile will likely point
17+
# to nonexistant paths, making everything phony and thus fine.)
18+
for path in glob.glob(sys.argv[1] + '/**', recursive=True):
19+
assert '\\' not in path
20+
assert ' ' not in path
21+
assert '#' not in path
22+
print("ignored:", path)

doc/manual/local.mk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,13 @@ $(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/anchors.jq $(d)/
223223
sed -i "s,@docroot@,$$docroot,g" "$$file"; \
224224
done; \
225225
set -euo pipefail; \
226-
RUST_LOG=warn mdbook build "$$tmp/manual" -d $(DESTDIR)$(docdir)/manual.tmp 2>&1 \
227-
| { grep -Fv "because fragment resolution isn't implemented" || :; }; \
226+
( \
227+
cd "$$tmp/manual"; \
228+
RUST_LOG=warn \
229+
MDBOOK_SUBSTITUTE_SEARCH=$(d)/src \
230+
mdbook build -d $(DESTDIR)$(docdir)/manual.tmp 2>&1 \
231+
| { grep -Fv "because fragment resolution isn't implemented" || :; } \
232+
); \
228233
rm -rf "$$tmp/manual"
229234
@rm -rf $(DESTDIR)$(docdir)/manual
230235
@mv $(DESTDIR)$(docdir)/manual.tmp/html $(DESTDIR)$(docdir)/manual

0 commit comments

Comments
 (0)