Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-20.03 110 lines 3.6 kB view raw
1MD_TARGETS=$(addsuffix .xml, $(basename $(wildcard ./*.md ./**/*.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 ./overrides.css out/html/ 43 cp ./style.css out/html/style.css 44 45 mkdir -p out/html/images/callouts 46 cp doc-support/result/xsl/docbook/images/callouts/*.svg out/html/images/callouts/ 47 chmod u+w -R out/html/ 48 49out/epub/manual.epub: manual-full.xml 50 mkdir -p out/epub/scratch 51 xsltproc --nonet \ 52 --output out/epub/scratch/ \ 53 doc-support/result/epub.xsl \ 54 ./manual-full.xml 55 56 cp ./overrides.css out/epub/scratch/OEBPS 57 cp ./style.css out/epub/scratch/OEBPS 58 mkdir -p out/epub/scratch/OEBPS/images/callouts/ 59 cp doc-support/result/xsl/docbook/images/callouts/*.svg out/epub/scratch/OEBPS/images/callouts/ 60 echo "application/epub+zip" > mimetype 61 zip -0Xq "out/epub/manual.epub" mimetype 62 rm mimetype 63 cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" * 64 rm -rf "out/epub/scratch/" 65 66highlightjs: doc-support/result 67 mkdir -p highlightjs 68 cp -r doc-support/result/highlightjs/highlight.pack.js highlightjs/ 69 cp -r doc-support/result/highlightjs/LICENSE highlightjs/ 70 cp -r doc-support/result/highlightjs/mono-blue.css highlightjs/ 71 cp -r doc-support/result/highlightjs/loader.js highlightjs/ 72 73 74manual-full.xml: ${MD_TARGETS} .version functions/library/locations.xml functions/library/generated *.xml **/*.xml **/**/*.xml 75 xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml 76 77.version: doc-support/result 78 ln -rfs ./doc-support/result/version .version 79 80doc-support/result: doc-support/default.nix 81 (cd doc-support; nix-build) 82 83functions/library/locations.xml: doc-support/result 84 ln -rfs ./doc-support/result/function-locations.xml functions/library/locations.xml 85 86functions/library/generated: doc-support/result 87 ln -rfs ./doc-support/result/function-docs functions/library/generated 88 89%.section.xml: %.section.md 90 pandoc $^ -w docbook+smart \ 91 -f markdown+smart \ 92 | sed -e 's|<ulink url=|<link xlink:href=|' \ 93 -e 's|</ulink>|</link>|' \ 94 -e 's|<sect. id=|<section xml:id=|' \ 95 -e 's|</sect[0-9]>|</section>|' \ 96 -e '1s| id=| xml:id=|' \ 97 -e '1s|\(<[^ ]* \)|\1xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" |' \ 98 | cat > $@ 99 100%.chapter.xml: %.chapter.md 101 pandoc $^ -w docbook+smart \ 102 --top-level-division=chapter \ 103 -f markdown+smart \ 104 | sed -e 's|<ulink url=|<link xlink:href=|' \ 105 -e 's|</ulink>|</link>|' \ 106 -e 's|<sect. id=|<section xml:id=|' \ 107 -e 's|</sect[0-9]>|</section>|' \ 108 -e '1s| id=| xml:id=|' \ 109 -e '1s|\(<[^ ]* \)|\1|' \ 110 | cat > $@