docs: Build with a makefile

+93 -103
+69
doc/Makefile
··· 1 + MD_TARGETS=$(addsuffix .xml, $(basename $(wildcard ./*.md ./**/*.md))) 2 + 3 + .PHONY: all 4 + all: out/html/index.html out/epub/manual.epub 5 + 6 + .PHONY: clean 7 + clean: 8 + rm -f ${MD_TARGETS} .version manual-full.xml 9 + rm -rf ./out/ 10 + 11 + validate: manual-full.xml 12 + jing "$$RNG" manual-full.xml 13 + 14 + out/html/index.html: manual-full.xml style.css 15 + mkdir -p out/html 16 + xsltproc $$xsltFlags \ 17 + --nonet --xinclude \ 18 + --output $@ \ 19 + "$$XSL/docbook/xhtml/docbook.xsl" \ 20 + ./manual-full.xml 21 + 22 + cp ./style.css out/html/style.css 23 + 24 + mkdir -p out/html/images/callouts 25 + cp "$$XSL/docbook/images/callouts/"*.gif out/html/images/callouts/ 26 + 27 + out/epub/manual.epub: manual-full.xml 28 + mkdir -p out/epub/scratch 29 + xsltproc $$xsltFlags --nonet \ 30 + --output out/epub/scratch/ \ 31 + "$$XSL/docbook/epub/docbook.xsl" \ 32 + ./manual-full.xml 33 + 34 + cp "$$XSL/docbook/images/callouts/"*.gif out/epub/scratch/OEBPS 35 + echo "application/epub+zip" > mimetype 36 + zip -0Xq "out/epub/manual.epub" mimetype 37 + rm mimetype 38 + cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" * 39 + rm -rf "out/epub/scratch/" 40 + 41 + manual-full.xml: ${MD_TARGETS} .version *.xml 42 + xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml 43 + 44 + .version: 45 + nix-instantiate --eval \ 46 + -E '(import ../lib).nixpkgsVersion' > .version 47 + 48 + %.section.xml: %.section.md 49 + pandoc $^ -w docbook+smart \ 50 + -f markdown+smart \ 51 + | sed -e 's|<ulink url=|<link xlink:href=|' \ 52 + -e 's|</ulink>|</link>|' \ 53 + -e 's|<sect. id=|<section xml:id=|' \ 54 + -e 's|</sect[0-9]>|</section>|' \ 55 + -e '1s| id=| xml:id=|' \ 56 + -e '1s|\(<[^ ]* \)|\1xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" |' \ 57 + | cat > $@ 58 + 59 + %.chapter.xml: %.chapter.md 60 + pandoc $^ -w docbook+smart \ 61 + --top-level-division=chapter \ 62 + -f markdown+smart \ 63 + | sed -e 's|<ulink url=|<link xlink:href=|' \ 64 + -e 's|</ulink>|</link>|' \ 65 + -e 's|<sect. id=|<section xml:id=|' \ 66 + -e 's|</sect[0-9]>|</section>|' \ 67 + -e '1s| id=| xml:id=|' \ 68 + -e '1s|\(<[^ ]* \)|\1|' \ 69 + | cat > $@
+22 -103
doc/default.nix
··· 7 7 pkgs.stdenv.mkDerivation { 8 8 name = "nixpkgs-manual"; 9 9 10 - 11 10 buildInputs = with pkgs; [ pandoc libxml2 libxslt zip ]; 12 11 13 - xsltFlags = '' 14 - --param section.autolabel 1 15 - --param section.label.includes.component.label 1 16 - --param html.stylesheet 'style.css' 17 - --param xref.with.number.and.title 1 18 - --param toc.section.depth 3 19 - --param admon.style ''' 20 - --param callout.graphics.extension '.gif' 21 - ''; 12 + src = ./.; 22 13 14 + XSL = "${pkgs.docbook5_xsl}/xml/xsl"; 15 + RNG = "${pkgs.docbook5}/xml/rng/docbook/docbook.rng"; 16 + xsltFlags = lib.concatStringsSep " " [ 17 + "--param section.autolabel 1" 18 + "--param section.label.includes.component.label 1" 19 + "--param html.stylesheet 'style.css'" 20 + "--param xref.with.number.and.title 1" 21 + "--param toc.section.depth 3" 22 + "--param admon.style ''" 23 + "--param callout.graphics.extension '.gif'" 24 + ]; 23 25 24 - buildCommand = let toDocbook = { useChapters ? false, inputFile, outputFile }: 25 - let 26 - extraHeader = lib.optionalString (!useChapters) 27 - ''xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" ''; 28 - in '' 29 - { 30 - pandoc '${inputFile}' -w docbook+smart ${lib.optionalString useChapters "--top-level-division=chapter"} \ 31 - -f markdown+smart \ 32 - | sed -e 's|<ulink url=|<link xlink:href=|' \ 33 - -e 's|</ulink>|</link>|' \ 34 - -e 's|<sect. id=|<section xml:id=|' \ 35 - -e 's|</sect[0-9]>|</section>|' \ 36 - -e '1s| id=| xml:id=|' \ 37 - -e '1s|\(<[^ ]* \)|\1${extraHeader}|' 38 - } > '${outputFile}' 39 - ''; 40 - in 41 - 42 - '' 43 - ln -s '${sources}/'*.xml . 44 - mkdir ./languages-frameworks 45 - cp -s '${sources-langs}'/* ./languages-frameworks 46 - '' 47 - + toDocbook { 48 - inputFile = ./introduction.chapter.md; 49 - outputFile = "introduction.chapter.xml"; 50 - useChapters = true; 51 - } 52 - + toDocbook { 53 - inputFile = ./shell.section.md; 54 - outputFile = "shell.section.xml"; 55 - } 56 - + toDocbook { 57 - inputFile = ./languages-frameworks/python.section.md; 58 - outputFile = "./languages-frameworks/python.section.xml"; 59 - } 60 - + toDocbook { 61 - inputFile = ./languages-frameworks/haskell.section.md; 62 - outputFile = "./languages-frameworks/haskell.section.xml"; 63 - } 64 - + toDocbook { 65 - inputFile = ./languages-frameworks/idris.section.md; 66 - outputFile = "languages-frameworks/idris.section.xml"; 67 - } 68 - + toDocbook { 69 - inputFile = ./languages-frameworks/node.section.md; 70 - outputFile = "languages-frameworks/node.section.xml"; 71 - } 72 - + toDocbook { 73 - inputFile = ./languages-frameworks/r.section.md; 74 - outputFile = "languages-frameworks/r.section.xml"; 75 - } 76 - + toDocbook { 77 - inputFile = ./languages-frameworks/rust.section.md; 78 - outputFile = "./languages-frameworks/rust.section.xml"; 79 - } 80 - + toDocbook { 81 - inputFile = ./languages-frameworks/vim.section.md; 82 - outputFile = "./languages-frameworks/vim.section.xml"; 83 - } 84 - + toDocbook { 85 - inputFile = ./languages-frameworks/emscripten.section.md; 86 - outputFile = "./languages-frameworks/emscripten.section.xml"; 87 - } 88 - + '' 26 + postPatch = '' 89 27 echo ${lib.nixpkgsVersion} > .version 90 - 91 - # validate against relaxng schema 92 - xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml 93 - ${pkgs.jing}/bin/jing ${pkgs.docbook5}/xml/rng/docbook/docbook.rng manual-full.xml 94 - 95 - dst=$out/share/doc/nixpkgs 96 - mkdir -p $dst 97 - xsltproc $xsltFlags --nonet --xinclude \ 98 - --output $dst/manual.html \ 99 - ${pkgs.docbook5_xsl}/xml/xsl/docbook/xhtml/docbook.xsl \ 100 - ./manual.xml 28 + ''; 101 29 102 - cp ${./style.css} $dst/style.css 30 + installPhase = '' 31 + dest="$out/share/doc/nixpkgs" 32 + mkdir -p "$(dirname "$dest")" 33 + mv out/html "$dest" 34 + mv "$dest/index.html" "$dest/manual.html" 103 35 104 - mkdir -p $dst/images/callouts 105 - cp "${pkgs.docbook5_xsl}/xml/xsl/docbook/images/callouts/"*.gif $dst/images/callouts/ 36 + mv out/epub/manual.epub "$dest/nixpkgs-manual.epub" 106 37 107 - mkdir -p $out/nix-support 108 - echo "doc manual $dst manual.html" >> $out/nix-support/hydra-build-products 109 - 110 - xsltproc $xsltFlags --nonet --xinclude \ 111 - --output $dst/epub/ \ 112 - ${pkgs.docbook5_xsl}/xml/xsl/docbook/epub/docbook.xsl \ 113 - ./manual.xml 114 - 115 - cp -r $dst/images $dst/epub/OEBPS 116 - echo "application/epub+zip" > mimetype 117 - manual="$dst/nixpkgs-manual.epub" 118 - zip -0Xq "$manual" mimetype 119 - cd $dst/epub && zip -Xr9D "$manual" * 120 - rm -rf $dst/epub 38 + mkdir -p $out/nix-support/ 39 + echo "doc manual $dest manual.html" >> $out/nix-support/hydra-build-products 121 40 ''; 122 41 }
+2
doc/shell.section.md
··· 4 4 date: 2017-10-30 5 5 --- 6 6 7 + # mkShell 8 + 7 9 pkgs.mkShell is a special kind of derivation that is only useful when using 8 10 it combined with nix-shell. It will in fact fail to instantiate when invoked 9 11 with nix-build.