docs: html: load stylesheet via custom.css.source
authorAndres Freund <[email protected]>
Wed, 5 Apr 2023 04:10:46 +0000 (21:10 -0700)
committerAndres Freund <[email protected]>
Wed, 5 Apr 2023 04:29:45 +0000 (21:29 -0700)
Until now the meson built docs did not have a working reference to the css
stylesheet, it was copied in the make target. Instead of duplicating that for
meson, use the docbook-xsl parameter custom.css.source to reference it. An
additional benefit of that approach is that the stylesheet is now included in
the single-file HTML documentation.

Reported-by: Peter Eisentraut <[email protected]>
Discussion: https://postgr.es/m/3fc3bb9b-f7f8-d442-35c1-ec82280c564a@enterprisedb.com

doc/src/sgml/Makefile
doc/src/sgml/meson.build
doc/src/sgml/stylesheet-html-common.xsl
doc/src/sgml/stylesheet-html-nochunk.xsl
doc/src/sgml/stylesheet.css.xml [new file with mode: 0644]
doc/src/sgml/stylesheet.xsl

index 11ecdaf717eb5395ec2cac19f8743738ea55df37..71cbef230f34a6ad6b41a667c7d2977fb6560378 100644 (file)
@@ -39,7 +39,7 @@ ifndef FOP
 FOP = $(missing) fop
 endif
 
-XMLINCLUDE = --path .
+XMLINCLUDE = --path . --path $(srcdir)
 
 ifdef XMLLINT
 XMLLINT := $(XMLLINT) --nonet
@@ -144,7 +144,6 @@ html: html-stamp
 
 html-stamp: stylesheet.xsl postgres-full.xml $(ALL_IMAGES)
    $(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_HTML_FLAGS) $(wordlist 1,2,$^)
-   cp $(srcdir)/stylesheet.css html/
    touch $@
 
 # single-page HTML
index f293eca612ab0b6b3fe795ffb4617bd41d14a7f2..539865da8d94aa7274c3f3c1f0b23a23f9f3380f 100644 (file)
@@ -96,7 +96,7 @@ if xsltproc_bin.found()
   xsltproc_flags = [
     '--nonet',
     '--stringparam', 'pg.version', pg_version,
-    '--path', '@OUTDIR@',
+    '--path', '@OUTDIR@', '--path', '@CURRENT_SOURCE_DIR@',
   ]
 
   xsltproc = xmltools_wrapper + [
index 9df2782ce4f4f000240ad952b0d7e9fcba318012..bb6429ef7cf63a0d4bfe91d40109feb883e3f5d9 100644 (file)
 <xsl:param name="make.graphic.viewport" select="0"/>
 <xsl:param name="link.mailto.url">[email protected]</xsl:param>
 <xsl:param name="toc.max.depth">2</xsl:param>
+<xsl:param name="website.stylesheet" select="0"/>
+<xsl:param name="custom.css.source">
+  <xsl:if test="$website.stylesheet = 0">stylesheet.css.xml</xsl:if>
+</xsl:param>
+<xsl:param name="html.stylesheet">
+  <xsl:if test="not($website.stylesheet = 0)">https://www.postgresql.org/media/css/docs-complete.css</xsl:if>
+</xsl:param>
+
 
 <!--
   The below allows the stylesheets provided by the website to be applied fully
index 8167127b93a7ae197ec364562699b2565848820d..5a0bb4ea08f6e55bd8bc002e835d2f8755f1fc27 100644 (file)
@@ -7,6 +7,9 @@
 <xsl:include href="stylesheet-html-common.xsl" />
 <xsl:include href="stylesheet-speedup-xhtml.xsl" />
 
+<!-- except when referencing the online stylesheet, embed stylesheet -->
+<xsl:param name="generate.css.header" select="$website.stylesheet = 0"/>
+
 <!-- embed SVG images into output file -->
 <xsl:template match="imagedata[@format='SVG']">
   <xsl:variable name="filename">
diff --git a/doc/src/sgml/stylesheet.css.xml b/doc/src/sgml/stylesheet.css.xml
new file mode 100644 (file)
index 0000000..a21fcca
--- /dev/null
@@ -0,0 +1,8 @@
+<!--
+    wrapper around stylesheet.css.xml to allow it to be loaded via docbook-xsl's
+    generate.css.header parameter.
+-->
+<!DOCTYPE style [
+<!ENTITY css SYSTEM "stylesheet.css">
+]>
+<style>&css;</style>
index c492dc38e54f15aaee069e068ada3b0c54095b49..363cc93e6b0e792de3ce1a4e8327e01efdc6427c 100644 (file)
 <xsl:param name="chunk.quietly" select="1"></xsl:param>
 <xsl:param name="admon.style"></xsl:param>  <!-- handled by CSS stylesheet -->
 
-<xsl:param name="website.stylesheet" select="0"/>
-
-<xsl:param name="html.stylesheet">
-  <xsl:choose>
-    <xsl:when test="$website.stylesheet = 0">stylesheet.css</xsl:when>
-    <xsl:otherwise>
-      https://www.postgresql.org/media/css/docs-complete.css
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:param>
-
 
 <!-- copy images to the output directory, so the output is self contained -->
 <xsl:template match="imageobject">