1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:exsl="http://exslt.org/common"
4                version='1.0'
5                exclude-result-prefixes="exsl">
6
7<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
8<xsl:import href="stylesheet-common.xsl" />
9
10
11<!-- Parameters -->
12
13<xsl:param name="man.authors.section.enabled">0</xsl:param>
14<xsl:param name="man.copyright.section.enabled">0</xsl:param>
15<xsl:param name="man.endnotes.are.numbered">0</xsl:param> <!-- for performance -->
16<xsl:param name="man.output.base.dir"></xsl:param>
17<xsl:param name="man.output.in.separate.dir" select="1"></xsl:param>
18<xsl:param name="man.output.quietly" select="1"></xsl:param>
19<xsl:param name="man.th.title.max.length">32</xsl:param> <!-- enough room for "CREATE TEXT SEARCH CONFIGURATION" -->
20<xsl:param name="man.th.extra3.max.length">40</xsl:param> <!-- enough room for "PostgreSQL X.Ydevel Documentation" -->
21<xsl:param name="refentry.meta.get.quietly" select="0"></xsl:param>
22<xsl:param name="refentry.xref.manvolnum" select="1"/> <!-- overridden from stylesheet-common.xsl -->
23
24<!-- Fixup for apostrophe groff output.  See the following references:
25     <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=457839>
26     <https://sourceforge.net/tracker/?func=detail&aid=2412738&group_id=21935&atid=373747>
27 -->
28<xsl:param name="man.string.subst.map.local.post">
29  <substitution oldstring="\'" newstring="\(aq"></substitution>
30</xsl:param>
31
32
33<!-- Custom templates -->
34
35<!-- Improve output of email element.  See also
36     <https://sourceforge.net/tracker/?func=detail&aid=3524417&group_id=21935&atid=373747>
37 -->
38<xsl:template match="email">
39  <xsl:text>&lt;</xsl:text>
40  <xsl:apply-templates/>
41  <xsl:text>&gt;</xsl:text>
42</xsl:template>
43
44
45<!-- Make superscripts visible in man pages (default is no decoration) -->
46<xsl:template match="superscript">
47  <xsl:text>^</xsl:text>
48  <xsl:apply-templates/>
49</xsl:template>
50
51
52<xsl:template match="refentry" mode="xref-to">
53  <xsl:param name="referrer"/>
54  <xsl:param name="xrefstyle"/>
55
56  <xsl:choose>
57    <!-- If the refname contains a space, we construct a reference
58         like CREATE DATABASE (CREATE_DATABASE(7)), so the reader
59         knows both the command name being referred to and the name of
60         the man page to read about it. -->
61    <xsl:when test="contains(refnamediv/refname[1],' ')">
62      <xsl:variable name="mangled.title">
63        <xsl:value-of select="translate(refnamediv/refname[1],' ','_')"/>
64      </xsl:variable>
65      <xsl:apply-templates select="refnamediv/refname[1]"/>
66      <xsl:text> (</xsl:text>
67      <xsl:call-template name="bold">
68        <xsl:with-param name="node" select="exsl:node-set($mangled.title)"/>
69        <xsl:with-param name="context" select="."/>
70      </xsl:call-template>
71      <xsl:apply-templates select="refmeta/manvolnum"/>
72      <xsl:text>)</xsl:text>
73    </xsl:when>
74
75    <!-- This is the original case, except that boldness has been
76         added, per the convention mentioned in man-pages(7). -->
77    <xsl:otherwise>
78      <xsl:choose>
79        <xsl:when test="refmeta/refentrytitle">
80          <xsl:call-template name="bold">
81            <xsl:with-param name="node" select="refmeta/refentrytitle"/>
82            <xsl:with-param name="context" select="."/>
83          </xsl:call-template>
84        </xsl:when>
85        <xsl:otherwise>
86          <xsl:call-template name="bold">
87            <xsl:with-param name="node" select="refnamediv/refname[1]"/>
88            <xsl:with-param name="context" select="."/>
89          </xsl:call-template>
90        </xsl:otherwise>
91      </xsl:choose>
92      <xsl:apply-templates select="refmeta/manvolnum"/>
93    </xsl:otherwise>
94  </xsl:choose>
95
96</xsl:template>
97
98
99<!-- For refentries we don't man to generate a man page for, leave out
100     manvolnum, let it default to 0, and skip writing out man files
101     with section 0. -->
102
103<!-- overridden from common/refentry.xsl -->
104<xsl:template name="get.refentry.section">
105  <xsl:choose>
106    <xsl:when test="refmeta/manvolnum">
107      <xsl:value-of select="refmeta/manvolnum"/>
108    </xsl:when>
109    <xsl:otherwise>
110      <xsl:text>0</xsl:text>
111    </xsl:otherwise>
112  </xsl:choose>
113</xsl:template>
114
115<!-- overridden from manpages/other.xsl -->
116  <xsl:template name="write.man.file">
117    <xsl:param name="name"/>
118    <xsl:param name="section"/>
119    <xsl:param name="lang"/>
120    <xsl:param name="content"/>
121    <xsl:param name="filename">
122      <xsl:call-template name="make.adjusted.man.filename">
123        <xsl:with-param name="name" select="$name"/>
124        <xsl:with-param name="section" select="$section"/>
125        <xsl:with-param name="lang" select="$lang"/>
126      </xsl:call-template>
127    </xsl:param>
128    <xsl:if test="$section != 0">
129    <xsl:call-template name="write.text.chunk">
130      <xsl:with-param name="filename" select="$filename"/>
131      <xsl:with-param name="suppress-context-node-name" select="1"/>
132      <xsl:with-param name="quiet" select="$man.output.quietly"/>
133      <xsl:with-param
134          name="message-prolog"
135          >Note: </xsl:with-param>
136      <xsl:with-param name="encoding" select="$man.output.encoding"/>
137      <xsl:with-param name="content" select="$content"/>
138    </xsl:call-template>
139    </xsl:if>
140  </xsl:template>
141
142
143<!-- Overridden template as workaround for this problem:
144     <https://sourceforge.net/tracker/?func=detail&aid=2831602&group_id=21935&atid=373747>
145-->
146  <xsl:template name="write.stubs">
147    <xsl:param name="first.refname"/>
148    <xsl:param name="section"/>
149    <xsl:param name="lang"/>
150    <xsl:for-each select="refnamediv/refname">
151      <xsl:if test=". != $first.refname">
152        <xsl:call-template name="write.text.chunk">
153          <xsl:with-param name="filename">
154            <xsl:call-template name="make.adjusted.man.filename">
155              <xsl:with-param name="name" select="."/>
156              <xsl:with-param name="section" select="$section"/>
157              <xsl:with-param name="lang" select="$lang"/>
158            </xsl:call-template>
159          </xsl:with-param>
160          <xsl:with-param name="quiet" select="$man.output.quietly"/>
161          <xsl:with-param name="suppress-context-node-name" select="1"/>
162          <xsl:with-param name="message-prolog">Note: </xsl:with-param>
163          <xsl:with-param name="message-epilog"> (soelim stub)</xsl:with-param>
164          <xsl:with-param name="content">
165            <xsl:choose>
166              <xsl:when test="$man.output.in.separate.dir = 0">
167                <xsl:value-of select="concat('.so man', $section, '/')"/>
168              </xsl:when>
169              <xsl:otherwise>
170                <xsl:value-of select="'.so '"/> <!-- added case -->
171              </xsl:otherwise>
172            </xsl:choose>
173            <xsl:call-template name="make.adjusted.man.filename">
174              <xsl:with-param name="name" select="$first.refname"/>
175              <xsl:with-param name="section" select="$section"/>
176            </xsl:call-template>
177            <xsl:text>&#10;</xsl:text>
178          </xsl:with-param>
179        </xsl:call-template>
180      </xsl:if>
181    </xsl:for-each>
182  </xsl:template>
183
184
185  <!-- https://sourceforge.net/tracker/?func=detail&aid=3545150&group_id=21935&atid=373747 -->
186  <xsl:template match="step/title">
187    <xsl:apply-templates/>
188    <xsl:text>: </xsl:text>
189  </xsl:template>
190
191
192  <!-- http://sourceforge.net/p/docbook/bugs/1340/ -->
193  <xsl:template match="indexterm"/>
194
195
196<!-- https://github.com/docbook/xslt10-stylesheets/issues/59 -->
197<xsl:template match="a/sup">
198  <xsl:apply-templates/>
199</xsl:template>
200
201
202<!-- Gentext customization -->
203
204<!-- see http://www.sagehill.net/docbookxsl/CustomGentext.html -->
205<xsl:param name="local.l10n.xml" select="document('')"/>
206<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
207  <l:l10n language="en">
208    <!-- Use ISO 8601 date format. -->
209    <l:context name="datetime">
210      <l:template name="format" text="Y-m-d"/>
211    </l:context>
212
213    <!-- Slight rephrasing to indicate that missing sections are found
214         in the documentation. -->
215    <l:context name="xref-number-and-title">
216      <l:template name="chapter" text="Chapter %n, %t, in the documentation"/>
217      <l:template name="sect1" text="Section %n, “%t”, in the documentation"/>
218      <l:template name="sect2" text="Section %n, “%t”, in the documentation"/>
219      <l:template name="sect3" text="Section %n, “%t”, in the documentation"/>
220      <l:template name="sect4" text="Section %n, “%t”, in the documentation"/>
221      <l:template name="sect5" text="Section %n, “%t”, in the documentation"/>
222    </l:context>
223  </l:l10n>
224</l:i18n>
225
226</xsl:stylesheet>
227