mirror of
https://github.com/boostorg/boostbook.git
synced 2025-05-09 15:03:57 +00:00
manpages.xsl: Output man pages into subdirectories based on the man page number
(e.g., man3 for section 3 man pages) [SVN r17965]
This commit is contained in:
parent
83006bbfb3
commit
ea66c4215c
117
xsl/manpages.xsl
117
xsl/manpages.xsl
@ -36,10 +36,12 @@
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<xsl:template match="refentry" mode="manifest">
|
||||
<xsl:variable name="section" select="refmeta/manvolnum"/>
|
||||
<xsl:variable name="name" select="refnamediv/refname[1]"/>
|
||||
<xsl:value-of select="concat(normalize-space ($name), '.', $section)"/>
|
||||
<xsl:value-of select="concat('man', $section, '/', normalize-space ($name),
|
||||
'.', $section)"/>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:template>
|
||||
|
||||
@ -51,6 +53,8 @@
|
||||
<xsl:call-template name="write.text.chunk">
|
||||
<xsl:with-param name="filename" select="$manifest"/>
|
||||
<xsl:with-param name="content">
|
||||
<xsl:value-of select="$manifest"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:apply-templates select="//refentry" mode="manifest"/>
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
@ -62,4 +66,115 @@
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="refentry">
|
||||
<xsl:variable name="section" select="refmeta/manvolnum"/>
|
||||
<xsl:variable name="name" select="refnamediv/refname[1]"/>
|
||||
|
||||
<!-- standard man page width is 64 chars; 6 chars needed for the two
|
||||
(x) volume numbers, and 2 spaces, leaves 56 -->
|
||||
<xsl:variable name="twidth" select="(56 - string-length(refmeta/refentrytitle)) div 2"/>
|
||||
|
||||
<xsl:variable name="reftitle"
|
||||
select="substring(refmeta/refentrytitle, 1, $twidth)"/>
|
||||
|
||||
<xsl:variable name="title">
|
||||
<xsl:choose>
|
||||
<xsl:when test="refentryinfo/title">
|
||||
<xsl:value-of select="refentryinfo/title"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="../referenceinfo/title">
|
||||
<xsl:value-of select="../referenceinfo/title"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="date">
|
||||
<xsl:choose>
|
||||
<xsl:when test="refentryinfo/date">
|
||||
<xsl:value-of select="refentryinfo/date"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="../referenceinfo/date">
|
||||
<xsl:value-of select="../referenceinfo/date"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="productname">
|
||||
<xsl:choose>
|
||||
<xsl:when test="refentryinfo/productname">
|
||||
<xsl:value-of select="refentryinfo/productname"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="../referenceinfo/productname">
|
||||
<xsl:value-of select="../referenceinfo/productname"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:call-template name="write.text.chunk">
|
||||
<xsl:with-param name="filename"
|
||||
select="concat('man', $section, '/', normalize-space ($name), '.', $section)"/>
|
||||
<xsl:with-param name="content">
|
||||
<xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
|
||||
.de Sh \" Subsection
|
||||
.br
|
||||
.if t .Sp
|
||||
.ne 5
|
||||
.PP
|
||||
\fB\\$1\fR
|
||||
.PP
|
||||
..
|
||||
.de Sp \" Vertical space (when we can't use .PP)
|
||||
.if t .sp .5v
|
||||
.if n .sp
|
||||
..
|
||||
.de Ip \" List item
|
||||
.br
|
||||
.ie \\n(.$>=3 .ne \\$3
|
||||
.el .ne 3
|
||||
.IP "\\$1" \\$2
|
||||
..
|
||||
.TH "</xsl:text>
|
||||
<xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
|
||||
<xsl:text>" </xsl:text>
|
||||
<xsl:value-of select="refmeta/manvolnum[1]"/>
|
||||
<xsl:text> "</xsl:text>
|
||||
<xsl:value-of select="normalize-space($date)"/>
|
||||
<xsl:text>" "</xsl:text>
|
||||
<xsl:value-of select="normalize-space($productname)"/>
|
||||
<xsl:text>" "</xsl:text>
|
||||
<xsl:value-of select="$title"/>
|
||||
<xsl:text>"
|
||||
</xsl:text>
|
||||
<xsl:apply-templates/>
|
||||
<xsl:text> </xsl:text>
|
||||
|
||||
<!-- Author section -->
|
||||
<xsl:choose>
|
||||
<xsl:when test="refentryinfo//author">
|
||||
<xsl:apply-templates select="refentryinfo" mode="authorsect"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="/book/bookinfo//author">
|
||||
<xsl:apply-templates select="/book/bookinfo" mode="authorsect"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="/article/articleinfo//author">
|
||||
<xsl:apply-templates select="/article/articleinfo" mode="authorsect"/>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:with-param>
|
||||
</xsl:call-template>
|
||||
<!-- Now generate stub include pages for every page documented in
|
||||
this refentry (except the page itself) -->
|
||||
<xsl:for-each select="refnamediv/refname">
|
||||
<xsl:if test=". != $name">
|
||||
<xsl:call-template name="write.text.chunk">
|
||||
<xsl:with-param name="filename"
|
||||
select="concat(normalize-space(.), '.', $section)"/>
|
||||
<xsl:with-param name="content" select="concat('.so man',
|
||||
$section, '/', $name, '.', $section, ' ')"/>
|
||||
</xsl:call-template>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
Loading…
x
Reference in New Issue
Block a user