Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/boostbook/xsl/manpages.xsl @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 6.1 KB
RevLine 
[12]1<?xml version="1.0" encoding="utf-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                version="1.0">
4
5  <!-- Import the man pages stylesheet -->
6  <xsl:import 
7    href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
8
9  <xsl:param name="generate.manifest" select="1"/>
10  <xsl:param name="manifest">man.manifest</xsl:param>
11
12  <xsl:template match="literallayout">
13    <xsl:text>&#10;.nf&#10;</xsl:text>
14    <xsl:apply-templates/>
15    <xsl:text>&#10;.fi&#10;</xsl:text>
16  </xsl:template>
17
18  <xsl:template match="para|simpara|remark" mode="list">
19    <xsl:variable name="foo">
20      <xsl:apply-templates/>
21    </xsl:variable>
22    <xsl:choose>
23      <xsl:when test="literallayout">
24        <xsl:copy-of select="$foo"/>
25      </xsl:when>
26      <xsl:otherwise>
27        <xsl:value-of select="normalize-space($foo)"/>
28      </xsl:otherwise>
29    </xsl:choose>
30    <xsl:text>&#10;</xsl:text>
31    <xsl:if test="following-sibling::para or following-sibling::simpara or
32                  following-sibling::remark">
33      <!-- Make sure multiple paragraphs within a list item don't -->
34      <!-- merge together.                                        -->
35      <xsl:text>&#10;</xsl:text>
36    </xsl:if>
37  </xsl:template>
38
39  <xsl:template name="build.refentry.filename">
40    <xsl:param name="node" select="."/>
41    <xsl:variable name="section" select="$node/refmeta/manvolnum"/>
42    <xsl:variable name="name" select="$node/refnamediv/refname[1]"/>
43    <xsl:value-of select="concat('man', $section, '/',
44                                 translate(normalize-space($name),
45                                           '&lt;&gt;', '__'),
46                                 '.', $section)"/>
47                                     
48  </xsl:template>
49
50  <xsl:template match="refentry" mode="manifest">
51    <xsl:call-template name="build.refentry.filename"/>
52    <xsl:text>&#10;</xsl:text>
53  </xsl:template>
54
55  <xsl:template match="/">
56    <xsl:choose>
57      <xsl:when test="//refentry">
58        <xsl:apply-templates select="//refentry"/>
59        <xsl:if test="$generate.manifest=1">
60          <xsl:call-template name="write.text.chunk">
61            <xsl:with-param name="filename" select="$manifest"/>
62            <xsl:with-param name="content">
63              <xsl:value-of select="$manifest"/>
64              <xsl:text>&#10;</xsl:text>
65              <xsl:apply-templates select="//refentry" mode="manifest"/>
66            </xsl:with-param>
67          </xsl:call-template>
68        </xsl:if>
69      </xsl:when>
70      <xsl:otherwise>
71        <xsl:message>No refentry elements!</xsl:message>
72      </xsl:otherwise>
73    </xsl:choose>
74  </xsl:template>
75
76<xsl:template match="refentry">
77  <xsl:variable name="section" select="refmeta/manvolnum"/>
78  <xsl:variable name="name" select="refnamediv/refname[1]"/>
79
80  <!-- standard man page width is 64 chars; 6 chars needed for the two
81       (x) volume numbers, and 2 spaces, leaves 56 -->
82  <xsl:variable name="twidth" select="(56 - string-length(refmeta/refentrytitle)) div 2"/>
83
84  <xsl:variable name="reftitle" 
85                select="substring(refmeta/refentrytitle, 1, $twidth)"/>
86
87  <xsl:variable name="title">
88    <xsl:choose>
89      <xsl:when test="refentryinfo/title">
90        <xsl:value-of select="refentryinfo/title"/>
91      </xsl:when>
92      <xsl:when test="../referenceinfo/title">
93        <xsl:value-of select="../referenceinfo/title"/>
94      </xsl:when>
95    </xsl:choose>
96  </xsl:variable>
97
98  <xsl:variable name="date">
99    <xsl:choose>
100      <xsl:when test="refentryinfo/date">
101        <xsl:value-of select="refentryinfo/date"/>
102      </xsl:when>
103      <xsl:when test="../referenceinfo/date">
104        <xsl:value-of select="../referenceinfo/date"/>
105      </xsl:when>
106    </xsl:choose>
107  </xsl:variable>
108
109  <xsl:variable name="productname">
110    <xsl:choose>
111      <xsl:when test="refentryinfo/productname">
112        <xsl:value-of select="refentryinfo/productname"/>
113      </xsl:when>
114      <xsl:when test="../referenceinfo/productname">
115        <xsl:value-of select="../referenceinfo/productname"/>
116      </xsl:when>
117    </xsl:choose>
118  </xsl:variable>
119
120  <xsl:call-template name="write.text.chunk">
121    <xsl:with-param name="filename">
122      <xsl:call-template name="build.refentry.filename"/>
123    </xsl:with-param>
124    <xsl:with-param name="content">
125      <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
126.de Sh \" Subsection
127.br
128.if t .Sp
129.ne 5
130.PP
131\fB\\$1\fR
132.PP
133..
134.de Sp \" Vertical space (when we can't use .PP)
135.if t .sp .5v
136.if n .sp
137..
138.de Ip \" List item
139.br
140.ie \\n(.$>=3 .ne \\$3
141.el .ne 3
142.IP "\\$1" \\$2
143..
144.TH "</xsl:text>
145      <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
146      <xsl:text>" </xsl:text>
147      <xsl:value-of select="refmeta/manvolnum[1]"/>
148      <xsl:text> "</xsl:text>
149      <xsl:value-of select="normalize-space($date)"/>
150      <xsl:text>" "</xsl:text>
151      <xsl:value-of select="normalize-space($productname)"/>
152      <xsl:text>" "</xsl:text>
153      <xsl:value-of select="$title"/>
154      <xsl:text>"
155</xsl:text>
156      <xsl:apply-templates/>
157      <xsl:text>&#10;</xsl:text>
158
159      <!-- Author section -->
160      <xsl:choose>
161        <xsl:when test="refentryinfo//author">
162          <xsl:apply-templates select="refentryinfo" mode="authorsect"/>
163        </xsl:when>
164        <xsl:when test="/book/bookinfo//author">
165          <xsl:apply-templates select="/book/bookinfo" mode="authorsect"/>
166        </xsl:when>
167        <xsl:when test="/article/articleinfo//author">
168          <xsl:apply-templates select="/article/articleinfo" mode="authorsect"/>
169        </xsl:when>
170      </xsl:choose>
171
172    </xsl:with-param>
173  </xsl:call-template>
174  <!-- Now generate stub include pages for every page documented in
175       this refentry (except the page itself) -->
176  <xsl:for-each select="refnamediv/refname">
177    <xsl:if test=". != $name">
178      <xsl:call-template name="write.text.chunk">
179        <xsl:with-param name="filename"
180                        select="concat(normalize-space(.), '.', $section)"/>
181        <xsl:with-param name="content" select="concat('.so man',
182              $section, '/', $name, '.', $section, '&#10;')"/>
183      </xsl:call-template>
184    </xsl:if>
185  </xsl:for-each>
186</xsl:template>
187
188</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.