summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2019-07-04 09:06:39 -0400
committerGraham Christensen <graham@grahamc.com>2019-07-04 09:16:06 -0400
commitfa47df617443b6bd7be0fe0239418c241df146c3 (patch)
tree62403f13912681f858fb79a49590b7578b516d5b
parent5a0696f6d0bf3344437eb1c83f1108e46664e24a (diff)
downloadnixpkgs-fa47df617443b6bd7be0fe0239418c241df146c3.tar
nixpkgs-fa47df617443b6bd7be0fe0239418c241df146c3.tar.gz
nixpkgs-fa47df617443b6bd7be0fe0239418c241df146c3.tar.bz2
nixpkgs-fa47df617443b6bd7be0fe0239418c241df146c3.tar.lz
nixpkgs-fa47df617443b6bd7be0fe0239418c241df146c3.tar.xz
nixpkgs-fa47df617443b6bd7be0fe0239418c241df146c3.tar.zst
nixpkgs-fa47df617443b6bd7be0fe0239418c241df146c3.zip
doc: move parameters to an XML file
-rw-r--r--doc/Makefile8
-rw-r--r--doc/default.nix15
-rw-r--r--doc/doc-support/default.nix22
-rw-r--r--doc/doc-support/parameters.xml14
4 files changed, 40 insertions, 19 deletions
diff --git a/doc/Makefile b/doc/Makefile
index 4bf33f7dd43..e7ca31b20d7 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -30,10 +30,10 @@ validate: manual-full.xml doc-support/result
 
 out/html/index.html: doc-support/result manual-full.xml style.css highlightjs
 	mkdir -p out/html
-	xsltproc ${xsltFlags} \
+	xsltproc \
 		--nonet --xinclude \
 		--output $@ \
-		doc-support/result/xsl/docbook/xhtml/docbook.xsl \
+		doc-support/result/xhtml.xsl \
 		./manual-full.xml
 
 	mkdir -p out/html/highlightjs/
@@ -48,9 +48,9 @@ out/html/index.html: doc-support/result manual-full.xml style.css highlightjs
 
 out/epub/manual.epub: manual-full.xml
 	mkdir -p out/epub/scratch
-	xsltproc ${xsltFlags} --nonet \
+	xsltproc --nonet \
 		--output out/epub/scratch/ \
-		doc-support/result/xsl/docbook/epub/docbook.xsl \
+		doc-support/result/epub.xsl \
 		./manual-full.xml
 
 	cp ./overrides.css out/epub/scratch/OEBPS
diff --git a/doc/default.nix b/doc/default.nix
index 971c60b35c2..d9051167dee 100644
--- a/doc/default.nix
+++ b/doc/default.nix
@@ -9,21 +9,6 @@ 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 :)
-  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 = ''
     ln -s ${doc-support} ./doc-support/result
   '';
diff --git a/doc/doc-support/default.nix b/doc/doc-support/default.nix
index c8be039fa7e..53990b67719 100644
--- a/doc/doc-support/default.nix
+++ b/doc/doc-support/default.nix
@@ -3,6 +3,26 @@ 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
@@ -13,6 +33,8 @@ in pkgs.runCommand "doc-support" {}
 
     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
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>