at 21.11-pre 3.3 kB view raw
1MD_TARGETS=$(addsuffix .xml, $(basename $(shell find . -type f -regex '.*\.md$$' -not -name README.md))) 2 3.PHONY: all 4all: validate format out/html/index.html out/epub/manual.epub 5 6.PHONY: debug 7debug: 8 nix-shell --run "xmloscopy --docbook5 ./manual.xml ./manual-full.xml" 9 10.PHONY: format 11format: doc-support/result 12 find . -iname '*.xml' -type f | while read f; do \ 13 echo $$f ;\ 14 xmlformat --config-file "doc-support/result/xmlformat.conf" -i $$f ;\ 15 done 16 17.PHONY: fix-misc-xml 18fix-misc-xml: 19 find . -iname '*.xml' -type f \ 20 -exec ../nixos/doc/varlistentry-fixer.rb {} ';' 21 22.PHONY: clean 23clean: 24 rm -f ${MD_TARGETS} doc-support/result .version manual-full.xml functions/library/locations.xml functions/library/generated 25 rm -rf ./out/ ./highlightjs 26 27.PHONY: validate 28validate: manual-full.xml doc-support/result 29 jing doc-support/result/docbook.rng manual-full.xml 30 31out/html/index.html: doc-support/result manual-full.xml style.css highlightjs 32 mkdir -p out/html 33 xsltproc \ 34 --nonet --xinclude \ 35 --output $@ \ 36 doc-support/result/xhtml.xsl \ 37 ./manual-full.xml 38 39 mkdir -p out/html/highlightjs/ 40 cp -r highlightjs out/html/ 41 42 cp -r media out/html/ 43 cp ./overrides.css out/html/ 44 cp ./style.css out/html/style.css 45 46 mkdir -p out/html/images/callouts 47 cp doc-support/result/xsl/docbook/images/callouts/*.svg out/html/images/callouts/ 48 chmod u+w -R out/html/ 49 50out/epub/manual.epub: manual-full.xml 51 mkdir -p out/epub/scratch 52 xsltproc --nonet \ 53 --output out/epub/scratch/ \ 54 doc-support/result/epub.xsl \ 55 ./manual-full.xml 56 57 cp -r media out/epub/scratch/OEBPS 58 cp ./overrides.css out/epub/scratch/OEBPS 59 cp ./style.css out/epub/scratch/OEBPS 60 mkdir -p out/epub/scratch/OEBPS/images/callouts/ 61 cp doc-support/result/xsl/docbook/images/callouts/*.svg out/epub/scratch/OEBPS/images/callouts/ 62 echo "application/epub+zip" > mimetype 63 zip -0Xq "out/epub/manual.epub" mimetype 64 rm mimetype 65 cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" * 66 rm -rf "out/epub/scratch/" 67 68highlightjs: doc-support/result 69 mkdir -p highlightjs 70 cp -r doc-support/result/highlightjs/highlight.pack.js highlightjs/ 71 cp -r doc-support/result/highlightjs/LICENSE highlightjs/ 72 cp -r doc-support/result/highlightjs/mono-blue.css highlightjs/ 73 cp -r doc-support/result/highlightjs/loader.js highlightjs/ 74 75 76manual-full.xml: ${MD_TARGETS} .version functions/library/locations.xml functions/library/generated *.xml **/*.xml **/**/*.xml 77 xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml 78 79.version: doc-support/result 80 ln -rfs ./doc-support/result/version .version 81 82doc-support/result: doc-support/default.nix 83 (cd doc-support; nix-build) 84 85functions/library/locations.xml: doc-support/result 86 ln -rfs ./doc-support/result/function-locations.xml functions/library/locations.xml 87 88functions/library/generated: doc-support/result 89 ln -rfs ./doc-support/result/function-docs functions/library/generated 90 91%.section.xml: %.section.md 92 pandoc $^ -t docbook \ 93 --extract-media=media \ 94 --lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \ 95 -f markdown+smart \ 96 | cat > $@ 97 98%.chapter.xml: %.chapter.md 99 pandoc $^ -t docbook \ 100 --top-level-division=chapter \ 101 --extract-media=media \ 102 --lua-filter=$(PANDOC_LUA_FILTERS_DIR)/diagram-generator.lua \ 103 -f markdown+smart \ 104 | cat > $@