Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b0f0a94

Browse files
committed
Make documentation builds reproducible
Currently, the documentation builds are not fully reproducible (in the sense of https://reproducible-builds.org/). A fix is available upstream (docbook/xslt10-stylesheets#54) but not released. This commit patches the upstream fix into our customization layer. This patch addresses both the HTML and the FO output. The man output is already reproducible. Discussion: https://www.postgresql.org/message-id/flat/9077b779-a9f8-09c8-6e85-da1ebfba15af@eisentraut.org
1 parent 2bcf078 commit b0f0a94

File tree

2 files changed

+493
-0
lines changed

2 files changed

+493
-0
lines changed

doc/src/sgml/stylesheet-fo.xsl

+259
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE xsl:stylesheet [
3+
<!ENTITY % common.entities SYSTEM "http://docbook.sourceforge.net/release/xsl/current/common/entities.ent">
4+
%common.entities;
5+
]>
26
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
37
version="1.0"
48
xmlns:fo="http://www.w3.org/1999/XSL/Format">
@@ -138,4 +142,259 @@
138142
</fo:bookmark>
139143
</xsl:template>
140144

145+
<!-- make generated ids reproducible
146+
(https://github.com/docbook/xslt10-stylesheets/issues/54) -->
147+
148+
<!-- from fo/autoidx.xsl -->
149+
150+
<xsl:template match="indexterm" mode="index-primary">
151+
<xsl:param name="scope" select="."/>
152+
<xsl:param name="role" select="''"/>
153+
<xsl:param name="type" select="''"/>
154+
155+
<xsl:variable name="key" select="&primary;"/>
156+
<xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
157+
158+
<xsl:variable name="term.separator">
159+
<xsl:call-template name="index.separator">
160+
<xsl:with-param name="key" select="'index.term.separator'"/>
161+
</xsl:call-template>
162+
</xsl:variable>
163+
164+
<xsl:variable name="range.separator">
165+
<xsl:call-template name="index.separator">
166+
<xsl:with-param name="key" select="'index.range.separator'"/>
167+
</xsl:call-template>
168+
</xsl:variable>
169+
170+
<xsl:variable name="number.separator">
171+
<xsl:call-template name="index.separator">
172+
<xsl:with-param name="key" select="'index.number.separator'"/>
173+
</xsl:call-template>
174+
</xsl:variable>
175+
176+
<fo:block xmlns:rx="http://www.renderx.com/XSL/Extensions" xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions">
177+
<xsl:if test="$autolink.index.see != 0">
178+
<xsl:attribute name="id">
179+
<!-- pgsql-docs: begin -->
180+
<xsl:text>ientry-</xsl:text>
181+
<xsl:call-template name="object.id"/>
182+
<!-- pgsql-docs: end -->
183+
</xsl:attribute>
184+
</xsl:if>
185+
<xsl:if test="$axf.extensions != 0">
186+
<xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>
187+
</xsl:if>
188+
189+
<xsl:for-each select="$refs/primary">
190+
<xsl:if test="@id or @xml:id">
191+
<fo:inline id="{(@id|@xml:id)[1]}"/>
192+
</xsl:if>
193+
</xsl:for-each>
194+
195+
<xsl:value-of select="primary"/>
196+
197+
<xsl:choose>
198+
<xsl:when test="$xep.extensions != 0">
199+
<xsl:if test="$refs[not(see) and not(secondary)]">
200+
<xsl:copy-of select="$term.separator"/>
201+
<xsl:variable name="primary" select="&primary;"/>
202+
<xsl:variable name="primary.significant" select="concat(&primary;, $significant.flag)"/>
203+
<rx:page-index list-separator="{$number.separator}"
204+
range-separator="{$range.separator}">
205+
<xsl:if test="$refs[@significance='preferred'][not(see) and not(secondary)]">
206+
<rx:index-item xsl:use-attribute-sets="index.preferred.page.properties xep.index.item.properties"
207+
ref-key="{$primary.significant}"/>
208+
</xsl:if>
209+
<xsl:if test="$refs[not(@significance) or @significance!='preferred'][not(see) and not(secondary)]">
210+
<rx:index-item xsl:use-attribute-sets="xep.index.item.properties"
211+
ref-key="{$primary}"/>
212+
</xsl:if>
213+
</rx:page-index>
214+
</xsl:if>
215+
</xsl:when>
216+
<xsl:otherwise>
217+
<xsl:variable name="page-number-citations">
218+
<xsl:for-each select="$refs[not(see)
219+
and not(secondary)]">
220+
<xsl:apply-templates select="." mode="reference">
221+
<xsl:with-param name="scope" select="$scope"/>
222+
<xsl:with-param name="role" select="$role"/>
223+
<xsl:with-param name="type" select="$type"/>
224+
<xsl:with-param name="position" select="position()"/>
225+
</xsl:apply-templates>
226+
</xsl:for-each>
227+
</xsl:variable>
228+
229+
<xsl:copy-of select="$page-number-citations"/>
230+
</xsl:otherwise>
231+
</xsl:choose>
232+
233+
<xsl:if test="$refs[not(secondary)]/*[self::see]">
234+
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
235+
mode="index-see">
236+
<xsl:with-param name="scope" select="$scope"/>
237+
<xsl:with-param name="role" select="$role"/>
238+
<xsl:with-param name="type" select="$type"/>
239+
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
240+
</xsl:apply-templates>
241+
</xsl:if>
242+
243+
</fo:block>
244+
245+
<xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]">
246+
<fo:block start-indent="1pc">
247+
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
248+
mode="index-seealso">
249+
<xsl:with-param name="scope" select="$scope"/>
250+
<xsl:with-param name="role" select="$role"/>
251+
<xsl:with-param name="type" select="$type"/>
252+
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
253+
</xsl:apply-templates>
254+
<xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]"
255+
mode="index-secondary">
256+
<xsl:with-param name="scope" select="$scope"/>
257+
<xsl:with-param name="role" select="$role"/>
258+
<xsl:with-param name="type" select="$type"/>
259+
<xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
260+
</xsl:apply-templates>
261+
</fo:block>
262+
</xsl:if>
263+
</xsl:template>
264+
265+
<xsl:template match="indexterm" mode="index-see">
266+
<xsl:param name="scope" select="."/>
267+
<xsl:param name="role" select="''"/>
268+
<xsl:param name="type" select="''"/>
269+
270+
<xsl:variable name="see" select="normalize-space(see)"/>
271+
272+
<!-- can only link to primary, which should appear before comma
273+
in see "primary, secondary" entry -->
274+
<xsl:variable name="seeprimary">
275+
<xsl:choose>
276+
<xsl:when test="contains($see, ',')">
277+
<xsl:value-of select="substring-before($see, ',')"/>
278+
</xsl:when>
279+
<xsl:otherwise>
280+
<xsl:value-of select="$see"/>
281+
</xsl:otherwise>
282+
</xsl:choose>
283+
</xsl:variable>
284+
285+
<xsl:variable name="seetarget" select="key('primaryonly', $seeprimary)[1]"/>
286+
287+
<xsl:variable name="linkend">
288+
<xsl:if test="$seetarget">
289+
<!-- pgsql-docs: begin -->
290+
<xsl:text>ientry-</xsl:text>
291+
<xsl:call-template name="object.id">
292+
<xsl:with-param name="object" select="$seetarget"/>
293+
</xsl:call-template>
294+
<!-- pgsql-docs: end -->
295+
</xsl:if>
296+
</xsl:variable>
297+
298+
<fo:inline xmlns:xlink='http://www.w3.org/1999/xlink'>
299+
<xsl:text> (</xsl:text>
300+
<xsl:call-template name="gentext">
301+
<xsl:with-param name="key" select="'see'"/>
302+
</xsl:call-template>
303+
<xsl:text> </xsl:text>
304+
<xsl:choose>
305+
<!-- manual links have precedence -->
306+
<xsl:when test="see/@linkend or see/@xlink:href">
307+
<xsl:call-template name="simple.xlink">
308+
<xsl:with-param name="node" select="see"/>
309+
<xsl:with-param name="content" select="$see"/>
310+
</xsl:call-template>
311+
</xsl:when>
312+
<xsl:when test="$autolink.index.see = 0">
313+
<xsl:value-of select="$see"/>
314+
</xsl:when>
315+
<xsl:when test="$seetarget">
316+
<fo:basic-link internal-destination="{$linkend}"
317+
xsl:use-attribute-sets="xref.properties">
318+
<xsl:value-of select="$see"/>
319+
</fo:basic-link>
320+
</xsl:when>
321+
<xsl:otherwise>
322+
<xsl:value-of select="$see"/>
323+
</xsl:otherwise>
324+
</xsl:choose>
325+
<xsl:text>)</xsl:text>
326+
</fo:inline>
327+
</xsl:template>
328+
329+
<xsl:template match="indexterm" mode="index-seealso">
330+
<xsl:param name="scope" select="."/>
331+
<xsl:param name="role" select="''"/>
332+
<xsl:param name="type" select="''"/>
333+
334+
<xsl:for-each select="seealso">
335+
<xsl:sort select="translate(., &lowercase;, &uppercase;)"/>
336+
337+
<xsl:variable name="seealso" select="normalize-space(.)"/>
338+
339+
<!-- can only link to primary, which should appear before comma
340+
in seealso "primary, secondary" entry -->
341+
<xsl:variable name="seealsoprimary">
342+
<xsl:choose>
343+
<xsl:when test="contains($seealso, ',')">
344+
<xsl:value-of select="substring-before($seealso, ',')"/>
345+
</xsl:when>
346+
<xsl:otherwise>
347+
<xsl:value-of select="$seealso"/>
348+
</xsl:otherwise>
349+
</xsl:choose>
350+
</xsl:variable>
351+
352+
<xsl:variable name="seealsotarget" select="key('primaryonly', $seealsoprimary)[1]"/>
353+
354+
<xsl:variable name="linkend">
355+
<xsl:if test="$seealsotarget">
356+
<!-- pgsql-docs: begin -->
357+
<xsl:text>ientry-</xsl:text>
358+
<xsl:call-template name="object.id">
359+
<xsl:with-param name="object" select="$seealsotarget"/>
360+
</xsl:call-template>
361+
<!-- pgsql-docs: end -->
362+
</xsl:if>
363+
</xsl:variable>
364+
365+
<fo:block xmlns:xlink='http://www.w3.org/1999/xlink'>
366+
<xsl:text>(</xsl:text>
367+
<xsl:call-template name="gentext">
368+
<xsl:with-param name="key" select="'seealso'"/>
369+
</xsl:call-template>
370+
<xsl:text> </xsl:text>
371+
<xsl:choose>
372+
<!-- manual links have precedence -->
373+
<xsl:when test="@linkend or see/@xlink:href">
374+
<xsl:call-template name="simple.xlink">
375+
<xsl:with-param name="node" select="."/>
376+
<xsl:with-param name="content" select="$seealso"/>
377+
</xsl:call-template>
378+
</xsl:when>
379+
<xsl:when test="$autolink.index.see = 0">
380+
<xsl:value-of select="$seealso"/>
381+
</xsl:when>
382+
<xsl:when test="$seealsotarget">
383+
<fo:basic-link internal-destination="{$linkend}"
384+
xsl:use-attribute-sets="xref.properties">
385+
<xsl:value-of select="$seealso"/>
386+
</fo:basic-link>
387+
</xsl:when>
388+
<xsl:otherwise>
389+
<xsl:value-of select="$seealso"/>
390+
</xsl:otherwise>
391+
</xsl:choose>
392+
<xsl:text>)</xsl:text>
393+
</fo:block>
394+
395+
</xsl:for-each>
396+
397+
</xsl:template>
398+
399+
141400
</xsl:stylesheet>

0 commit comments

Comments
 (0)