summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2019-07-05 14:32:43 -0400
committerGitHub <noreply@github.com>2019-07-05 14:32:43 -0400
commite9451ebc9b594077fbeb90961dd09e14b25b4378 (patch)
tree46076a75c78d269bcb926f024ecd989033a4aa12 /doc
parent5a04ebb67e0be838e8a10c80612c2ccfe07c782a (diff)
parentfa47df617443b6bd7be0fe0239418c241df146c3 (diff)
downloadnixpkgs-e9451ebc9b594077fbeb90961dd09e14b25b4378.tar
nixpkgs-e9451ebc9b594077fbeb90961dd09e14b25b4378.tar.gz
nixpkgs-e9451ebc9b594077fbeb90961dd09e14b25b4378.tar.bz2
nixpkgs-e9451ebc9b594077fbeb90961dd09e14b25b4378.tar.lz
nixpkgs-e9451ebc9b594077fbeb90961dd09e14b25b4378.tar.xz
nixpkgs-e9451ebc9b594077fbeb90961dd09e14b25b4378.tar.zst
nixpkgs-e9451ebc9b594077fbeb90961dd09e14b25b4378.zip
Merge pull request #64301 from grahamc/docs/clean-build
Docs/clean build
Diffstat (limited to 'doc')
-rw-r--r--doc/Makefile53
-rw-r--r--doc/default.nix27
-rw-r--r--doc/doc-support/default.nix45
-rw-r--r--doc/doc-support/lib-function-docs.nix (renamed from doc/lib-function-docs.nix)2
-rw-r--r--doc/doc-support/lib-function-locations.nix (renamed from doc/lib-function-locations.nix)0
-rw-r--r--doc/doc-support/parameters.xml14
6 files changed, 88 insertions, 53 deletions
diff --git a/doc/Makefile b/doc/Makefile
index 5badfe4138d..e7ca31b20d7 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -8,10 +8,10 @@ debug:
 	nix-shell --run "xmloscopy --docbook5 ./manual.xml ./manual-full.xml"
 
 .PHONY: format
-format:
+format: doc-support/result
 	find . -iname '*.xml' -type f | while read f; do \
 		echo $$f ;\
-		xmlformat --config-file "$$XMLFORMAT_CONFIG" -i $$f ;\
+		xmlformat --config-file "doc-support/result/xmlformat.conf" -i $$f ;\
 	done
 
 .PHONY: fix-misc-xml
@@ -21,19 +21,19 @@ fix-misc-xml:
 
 .PHONY: clean
 clean:
-	rm -f ${MD_TARGETS} .version manual-full.xml functions/library/locations.xml functions/library/generated
+	rm -f ${MD_TARGETS} doc-support/result .version manual-full.xml functions/library/locations.xml functions/library/generated
 	rm -rf ./out/ ./highlightjs
 
 .PHONY: validate
-validate: manual-full.xml
-	jing "$$RNG" manual-full.xml
+validate: manual-full.xml doc-support/result
+	jing doc-support/result/docbook.rng manual-full.xml
 
-out/html/index.html: manual-full.xml style.css highlightjs
+out/html/index.html: doc-support/result manual-full.xml style.css highlightjs
 	mkdir -p out/html
-	xsltproc ${xsltFlags} \
+	xsltproc \
 		--nonet --xinclude \
 		--output $@ \
-		"$$XSL/docbook/xhtml/docbook.xsl" \
+		doc-support/result/xhtml.xsl \
 		./manual-full.xml
 
 	mkdir -p out/html/highlightjs/
@@ -43,49 +43,48 @@ out/html/index.html: manual-full.xml style.css highlightjs
 	cp ./style.css out/html/style.css
 
 	mkdir -p out/html/images/callouts
-	cp "$$XSL/docbook/images/callouts/"*.svg out/html/images/callouts/
+	cp doc-support/result/xsl/docbook/images/callouts/*.svg out/html/images/callouts/
 	chmod u+w -R out/html/
 
 out/epub/manual.epub: manual-full.xml
 	mkdir -p out/epub/scratch
-	xsltproc ${xsltFlags} --nonet \
+	xsltproc --nonet \
 		--output out/epub/scratch/ \
-		"$$XSL/docbook/epub/docbook.xsl" \
+		doc-support/result/epub.xsl \
 		./manual-full.xml
 
 	cp ./overrides.css out/epub/scratch/OEBPS
 	cp ./style.css out/epub/scratch/OEBPS
 	mkdir -p out/epub/scratch/OEBPS/images/callouts/
-	cp "$$XSL/docbook/images/callouts/"*.svg out/epub/scratch/OEBPS/images/callouts/
+	cp doc-support/result/xsl/docbook/images/callouts/*.svg out/epub/scratch/OEBPS/images/callouts/
 	echo "application/epub+zip" > mimetype
 	zip -0Xq "out/epub/manual.epub" mimetype
 	rm mimetype
 	cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" *
 	rm -rf "out/epub/scratch/"
 
-highlightjs:
+highlightjs: doc-support/result
 	mkdir -p highlightjs
-	cp -r "$$HIGHLIGHTJS/highlight.pack.js" highlightjs/
-	cp -r "$$HIGHLIGHTJS/LICENSE" highlightjs/
-	cp -r "$$HIGHLIGHTJS/mono-blue.css" highlightjs/
-	cp -r "$$HIGHLIGHTJS/loader.js" highlightjs/
+	cp -r doc-support/result/highlightjs/highlight.pack.js highlightjs/
+	cp -r doc-support/result/highlightjs/LICENSE highlightjs/
+	cp -r doc-support/result/highlightjs/mono-blue.css highlightjs/
+	cp -r doc-support/result/highlightjs/loader.js highlightjs/
 
 
 manual-full.xml: ${MD_TARGETS} .version functions/library/locations.xml functions/library/generated *.xml **/*.xml **/**/*.xml
 	xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml
 
-.version:
-	nix-instantiate --eval \
-		-E '(import ../lib).version' > .version
+.version: doc-support/result
+	ln -rfs ./doc-support/result/version .version
 
-functions/library/locations.xml:
-	nix-build ./lib-function-locations.nix \
-		--out-link $@
+doc-support/result: doc-support/default.nix
+	(cd doc-support; nix-build)
 
-functions/library/generated: functions/library/locations.xml
-	nix-build ./lib-function-docs.nix \
-		--arg locationsXml $< \
-		--out-link $@
+functions/library/locations.xml: doc-support/result
+	ln -rfs ./doc-support/result/function-locations.xml functions/library/locations.xml
+
+functions/library/generated: doc-support/result
+	ln -rfs ./doc-support/result/function-docs functions/library/generated
 
 %.section.xml: %.section.md
 	pandoc $^ -w docbook+smart \
diff --git a/doc/default.nix b/doc/default.nix
index 7ceaec28af3..d9051167dee 100644
--- a/doc/default.nix
+++ b/doc/default.nix
@@ -1,8 +1,7 @@
 { pkgs ? (import ./.. { }), nixpkgs ? { }}:
 let
   lib = pkgs.lib;
-  locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs; };
-  functionDocs = import ./lib-function-docs.nix { inherit locationsXml pkgs; };
+  doc-support = import ./doc-support { inherit pkgs nixpkgs; };
 in pkgs.stdenv.mkDerivation {
   name = "nixpkgs-manual";
 
@@ -10,30 +9,8 @@ in pkgs.stdenv.mkDerivation {
 
   src = ./.;
 
-  # Hacking on these variables? Make sure to close and open
-  # nix-shell between each test, maybe even:
-  # $ nix-shell --run "make clean all"
-  # otherwise they won't reapply :)
-  HIGHLIGHTJS = pkgs.documentation-highlighter;
-  XSL = "${pkgs.docbook_xsl_ns}/xml/xsl";
-  RNG = "${pkgs.docbook5}/xml/rng/docbook/docbook.rng";
-  XMLFORMAT_CONFIG = ../nixos/doc/xmlformat.conf;
-  xsltFlags = lib.concatStringsSep " " [
-    "--param section.autolabel 1"
-    "--param section.label.includes.component.label 1"
-    "--stringparam html.stylesheet 'style.css overrides.css highlightjs/mono-blue.css'"
-    "--stringparam html.script './highlightjs/highlight.pack.js ./highlightjs/loader.js'"
-    "--param xref.with.number.and.title 1"
-    "--param toc.section.depth 3"
-    "--stringparam admon.style ''"
-    "--stringparam callout.graphics.extension .svg"
-  ];
-
   postPatch = ''
-    rm -rf ./functions/library/locations.xml
-    ln -s ${locationsXml} ./functions/library/locations.xml
-    ln -s ${functionDocs} ./functions/library/generated
-    echo ${lib.version} > .version
+    ln -s ${doc-support} ./doc-support/result
   '';
 
   installPhase = ''
diff --git a/doc/doc-support/default.nix b/doc/doc-support/default.nix
new file mode 100644
index 00000000000..53990b67719
--- /dev/null
+++ b/doc/doc-support/default.nix
@@ -0,0 +1,45 @@
+{ pkgs ? (import ../.. {}), nixpkgs ? { }}:
+let
+  locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs; };
+  functionDocs = import ./lib-function-docs.nix { inherit locationsXml pkgs; };
+  version = pkgs.lib.version;
+
+  epub-xsl = pkgs.writeText "epub.xsl" ''
+    <?xml version='1.0'?>
+    <xsl:stylesheet
+      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+      version="1.0">
+      <xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/epub/docbook.xsl" />
+      <xsl:import href="${./parameters.xml}"/>
+    </xsl:stylesheet>
+  '';
+
+  xhtml-xsl = pkgs.writeText "xhtml.xsl" ''
+    <?xml version='1.0'?>
+    <xsl:stylesheet
+      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+      version="1.0">
+      <xsl:import href="${pkgs.docbook_xsl_ns}/xml/xsl/docbook/xhtml/docbook.xsl" />
+      <xsl:import href="${./parameters.xml}"/>
+    </xsl:stylesheet>
+  '';
+in pkgs.runCommand "doc-support" {}
+''
+  mkdir result
+  (
+    cd result
+    ln -s ${locationsXml} ./function-locations.xml
+    ln -s ${functionDocs} ./function-docs
+
+    ln -s ${pkgs.docbook5}/xml/rng/docbook/docbook.rng ./docbook.rng
+    ln -s ${pkgs.docbook_xsl_ns}/xml/xsl ./xsl
+    ln -s ${epub-xsl} ./epub.xsl
+    ln -s ${xhtml-xsl} ./xhtml.xsl
+
+    ln -s ${../../nixos/doc/xmlformat.conf} ./xmlformat.conf
+    ln -s ${pkgs.documentation-highlighter} ./highlightjs
+
+    echo -n "${version}" > ./version
+  )
+  mv result $out
+''
diff --git a/doc/lib-function-docs.nix b/doc/doc-support/lib-function-docs.nix
index 421f848d25a..5199b949e7b 100644
--- a/doc/lib-function-docs.nix
+++ b/doc/doc-support/lib-function-docs.nix
@@ -6,7 +6,7 @@
 
 with pkgs; stdenv.mkDerivation {
   name = "nixpkgs-lib-docs";
-  src = ./../lib;
+  src = ./../../lib;
 
   buildInputs = [ nixdoc ];
   installPhase = ''
diff --git a/doc/lib-function-locations.nix b/doc/doc-support/lib-function-locations.nix
index ae7036e4626..ae7036e4626 100644
--- a/doc/lib-function-locations.nix
+++ b/doc/doc-support/lib-function-locations.nix
diff --git a/doc/doc-support/parameters.xml b/doc/doc-support/parameters.xml
new file mode 100644
index 00000000000..bc13e2b70de
--- /dev/null
+++ b/doc/doc-support/parameters.xml
@@ -0,0 +1,14 @@
+<?xml version='1.0'?>
+<xsl:stylesheet
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    version="1.0">
+ <xsl:param name="section.autolabel" select="1" />
+ <xsl:param name="section.label.includes.component.label" select="1" />
+ <xsl:param name="html.stylesheet" select="'style.css overrides.css highlightjs/mono-blue.css'" />
+ <xsl:param name="html.script" select="'./highlightjs/highlight.pack.js ./highlightjs/loader.js'" />
+ <xsl:param name="xref.with.number.and.title" select="1" />
+ <xsl:param name="use.id.as.filename" select="1" />
+ <xsl:param name="toc.section.depth" select="3" />
+ <xsl:param name="admon.style" select="''" />
+ <xsl:param name="callout.graphics.extension" select="'.svg'" />
+</xsl:stylesheet>