docs: html: copy images to output as part of xslt build
authorAndres Freund <[email protected]>
Wed, 5 Apr 2023 04:05:52 +0000 (21:05 -0700)
committerAndres Freund <[email protected]>
Wed, 5 Apr 2023 04:29:44 +0000 (21:29 -0700)
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/3fc3bb9b-f7f8-d442-35c1-ec82280c564a@enterprisedb.com

doc/src/sgml/Makefile
doc/src/sgml/stylesheet-common.xsl
doc/src/sgml/stylesheet.xsl

index 3c4aa6bebe33e6b15c1fa1ccf6984d13828bed18..11ecdaf717eb5395ec2cac19f8743738ea55df37 100644 (file)
@@ -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 $@
 
index 761484c7fefa9af3efd0e83f2844ddec1fa70b9c..d2928f86eb749d8a2acb95363ee2eec8f3df2925 100644 (file)
   <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>
index b6141303abd2f4542154c9fef4ac4637313d97a1..c492dc38e54f15aaee069e068ada3b0c54095b49 100644 (file)
 </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(., '/')"/>