summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2023-04-05 04:05:52 +0000
committerAndres Freund2023-04-05 04:29:44 +0000
commit0012979d989fd1640ed17c32b303ebbd2294a3fc (patch)
treef6b57f933134886cc23c71aff19c2afb783cbc07
parentef07d351a1860a6e93c89cc7af3ae13366942bf0 (diff)
docs: html: copy images to output as part of xslt build
Until now the meson built HTML docs had non-working references to images. They were copied in the make target. Instead of duplicating that for meson, copy them as part of the xslt stylesheet. Reported-by: Peter Eisentraut <[email protected]> Discussion: https://postgr.es/m/[email protected]
-rw-r--r--doc/src/sgml/Makefile1
-rw-r--r--doc/src/sgml/stylesheet-common.xsl22
-rw-r--r--doc/src/sgml/stylesheet.xsl6
3 files changed, 28 insertions, 1 deletions
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 3c4aa6bebe..11ecdaf717 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -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 $(ALL_IMAGES) html/
cp $(srcdir)/stylesheet.css html/
touch $@
diff --git a/doc/src/sgml/stylesheet-common.xsl b/doc/src/sgml/stylesheet-common.xsl
index 761484c7fe..d2928f86eb 100644
--- a/doc/src/sgml/stylesheet-common.xsl
+++ b/doc/src/sgml/stylesheet-common.xsl
@@ -101,4 +101,26 @@
<xsl:apply-templates select="." mode="xref"/>
</xsl:template>
+
+<!--
+ Support for copying images to the output directory, so the output is self
+ contained.
+-->
+<xsl:template name="write-image">
+ <xsl:variable name="input_filename">
+ <xsl:value-of select="imagedata/@fileref"/>
+ </xsl:variable>
+
+ <!-- references images directly, without images/ -->
+ <xsl:variable name="output_filename">
+ <xsl:value-of select="concat($chunk.base.dir, substring-after($input_filename, '/'))"/>
+ </xsl:variable>
+
+ <xsl:call-template name="write.chunk">
+ <xsl:with-param name="filename" select="$output_filename"/>
+ <xsl:with-param name="content" select="document($input_filename)"/>
+ </xsl:call-template>
+</xsl:template>
+
+
</xsl:stylesheet>
diff --git a/doc/src/sgml/stylesheet.xsl b/doc/src/sgml/stylesheet.xsl
index b6141303ab..c492dc38e5 100644
--- a/doc/src/sgml/stylesheet.xsl
+++ b/doc/src/sgml/stylesheet.xsl
@@ -29,6 +29,12 @@
</xsl:param>
+<!-- copy images to the output directory, so the output is self contained -->
+<xsl:template match="imageobject">
+ <xsl:call-template name="write-image"/>
+ <xsl:apply-templates select="imagedata"/>
+</xsl:template>
+
<!-- strip directory name from image filerefs -->
<xsl:template match="imagedata/@fileref">
<xsl:value-of select="substring-after(., '/')"/>