You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

111 lines
3.5 KiB

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