]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/docca/include/docca/base-stage2.xsl
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / docca / include / docca / base-stage2.xsl
CommitLineData
1e59de90
TL
1<!DOCTYPE xsl:stylesheet [
2<!ENTITY SYNTAX_BLOCK "*[ self::compound
3 | self::function
4 | self::typedef
5 | self::enum
6 | self::variable
7 | self::overloaded-member
8 ]">
9<!ENTITY CODE_BLOCK "*[ self::computeroutput[not(ref)]
10 | self::code
11 ]">
12]>
13<xsl:stylesheet version="3.0"
14 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15 xmlns:xs="http://www.w3.org/2001/XMLSchema"
16 xmlns:d="http://github.com/vinniefalco/docca"
17 expand-text="yes">
18
19 <xsl:import href="common.xsl"/>
20
21 <xsl:output method="text"/>
22
23 <xsl:param name="DEBUG" select="false()"/>
24
25 <!-- Can be overridden in library-specific configuration -->
26 <xsl:variable name="emphasized-template-parameter-types" select="()"/>
27
28 <xsl:variable name="list-indent-width" select="4"/>
29
30 <xsl:template mode="before" match="/page">
31 <xsl:text>{$nl}</xsl:text>
32 <xsl:text>[section:{tokenize(@id,'\.')[last()]} {d:qb-escape(title)}]</xsl:text>
33 <xsl:apply-templates mode="indexterm" select="."/>
34 </xsl:template>
35
36 <xsl:template mode="indexterm" match="page"/>
37 <xsl:template mode="indexterm" match="page[@primary-index-term]"
38 >{$nl}[indexterm1 {d:qb-escape(@primary-index-term)}]{$nl}</xsl:template>
39 <xsl:template mode="indexterm" match="page[@secondary-index-term]" priority="1"
40 >{$nl}[indexterm2 {d:qb-escape(@primary-index-term)}..{
41 d:qb-escape(@secondary-index-term)}]{$nl}</xsl:template>
42
43 <!-- Title is already included in section header -->
44 <xsl:template match="/page/title"/>
45
46 <xsl:template match="heading">{$nl}[heading {.}]</xsl:template>
47
48 <!-- Sections inside tables don't render well; just display the heading text inline (e.g. "See Also") -->
49 <xsl:template match="td//heading">{$nl}{.} </xsl:template>
50
51 <xsl:template match="location">
52 <xsl:apply-templates mode="includes-template" select="."/>
53 </xsl:template>
54
55 <xsl:template match="footer/location">
56 <xsl:apply-templates mode="includes-template-footer" select="."/>
57 </xsl:template>
58
59 <xsl:template mode="before" match="&SYNTAX_BLOCK;">{$nl}```{$nl}</xsl:template>
60 <xsl:template mode="after" match="&SYNTAX_BLOCK;">{$nl}```{$nl}</xsl:template>
61
62 <!-- Merge adjacent overloaded-members into one syntax block, separated by one blank line -->
63 <xsl:template mode="after" match="overloaded-member[following-sibling::*[1]/self::overloaded-member]" priority="1"/>
64 <xsl:template mode="before" match="overloaded-member[preceding-sibling::*[1]/self::overloaded-member]" priority="1"
65 >{$nl}{$nl}</xsl:template>
66
67 <xsl:template mode="after" match="overloaded-member/type[normalize-space(.)]
68 | function/type[normalize-space(.)]">{$nl}</xsl:template>
69
70 <xsl:template mode="append" match="function">;</xsl:template>
71
72 <xsl:template mode="append" match="overloaded-member">
73 <xsl:text>;{$nl}</xsl:text>
74 <xsl:variable name="more-link" as="element()">
75 <emphasis>'''&amp;raquo;''' <ref d:refid="{ref/@d:refid}">more...</ref></emphasis>
76 </xsl:variable>
77 <xsl:text> ``</xsl:text>
78 <xsl:apply-templates select="$more-link"/>
79 <xsl:text>``</xsl:text>
80 </xsl:template>
81
82 <xsl:template priority="1"
83 match="&SYNTAX_BLOCK;//ref">``[link {$doc-ref}.{@d:refid} {d:qb-escape(.)}]``</xsl:template>
84 <xsl:template match="td[1]//ref" >[link {$doc-ref}.{@d:refid} {d:qb-escape(.)}]</xsl:template>
85 <xsl:template match="ref" >[link {$doc-ref}.{@d:refid} `{.}`]</xsl:template>
86
87 <xsl:template mode="before" match="&CODE_BLOCK;">`</xsl:template>
88 <xsl:template mode="after" match="&CODE_BLOCK;">`</xsl:template>
89
90 <xsl:template mode="before" match="enum/name">enum </xsl:template>
91
92 <xsl:template mode="before" match="typedef/name">using </xsl:template>
93 <xsl:template mode="after" match="typedef/name"> = </xsl:template>
94 <xsl:template mode="after" match="typedef/type">;</xsl:template>
95
96 <xsl:template match="type[. eq '__implementation_defined__' ]">``['implementation-defined]``</xsl:template>
97 <xsl:template match="type[. eq '__see_below__' ]">``['see-below]``</xsl:template>
98 <xsl:template match="type[. = ('__deduced__','void_or_deduced')]">``__deduced__``</xsl:template>
99
100 <xsl:template mode="before" match="variable/name | variable/initializer">{' '}</xsl:template>
101 <xsl:template mode="append" match="variable">;</xsl:template>
102
103 <xsl:template mode="after" match="compound/kind">{' '}</xsl:template>
104
105 <xsl:template mode="before" match="base[1]"> :{$nl} </xsl:template>
106 <xsl:template mode="before" match="base" >{$nl} </xsl:template>
107 <xsl:template mode="after" match="base[position() ne last()]">,</xsl:template>
108
109 <xsl:template mode="after" match="base/prot">{' '}</xsl:template>
110
111 <xsl:template mode="before" match="templateparamlist">template&lt;</xsl:template>
112 <xsl:template mode="after" match="templateparamlist">>{$nl}</xsl:template>
113
114 <xsl:template mode="before" match="param">{$nl} </xsl:template>
115 <xsl:template mode="after" match="param[position() ne last()]">,</xsl:template>
116
117 <xsl:template mode="after" match="param[declname]/type">{' '}</xsl:template>
118
119
120 <xsl:template mode="before" match="params">(</xsl:template>
121 <xsl:template mode="after" match="params">)</xsl:template>
122
123 <xsl:template match="templateparamlist/param/declname[. = $emphasized-template-parameter-types]"
124 >__{translate(.,'_','')}__</xsl:template>
125
126 <xsl:template mode="before" match="defval"> = </xsl:template>
127
128 <xsl:template mode="before" match="modifier[. eq 'const']">{' '}</xsl:template>
129 <xsl:template mode="after" match="modifier[. eq 'const']"/>
130
131 <xsl:template mode="after" match="modifier">{$nl}</xsl:template>
132
133
134 <xsl:template mode="#all" match="ERROR">[role red error.{@message}]</xsl:template>
135
136 <xsl:template mode="before" match="table">{$nl}[table </xsl:template>
137 <xsl:template mode="after" match="table">{$nl}]</xsl:template>
138
139 <!-- ASSUMPTION: table rows have either <th> or <td>, not both -->
140 <xsl:template mode="before" match="tr[th] | th">[</xsl:template>
141 <xsl:template mode="after" match="tr[th] | th">]</xsl:template>
142
143 <xsl:template mode="before" match="tr">{$nl} [</xsl:template>
144 <xsl:template mode="after" match="tr">{$nl} ]</xsl:template>
145
146 <xsl:template mode="before" match="td">{$nl} [</xsl:template>
147 <xsl:template mode="after" match="td">{$nl} ]</xsl:template>
148
149 <xsl:template mode="before" match="bold">[*</xsl:template>
150 <xsl:template mode="after" match="bold">]</xsl:template>
151
152 <xsl:template mode="before" match="emphasis">['</xsl:template>
153 <xsl:template mode="after" match="emphasis">]</xsl:template>
154
155 <xsl:template mode="before" match="role">[role {@class} </xsl:template>
156 <xsl:template mode="after" match="role">]</xsl:template>
157
158 <xsl:template mode="before" match="ulink">[@{@url} </xsl:template>
159 <xsl:template mode="after" match="ulink">]</xsl:template>
160
161 <xsl:template mode="after" match="itemizedlist | orderedlist">{$nl}</xsl:template>
162
163 <xsl:template match="listitem">
164 <xsl:text>{$nl}</xsl:text>
165 <xsl:apply-templates mode="list-item-indent" select="."/>
166 <xsl:apply-templates mode="list-item-label" select=".."/>
167 <xsl:text> </xsl:text>
168 <!-- ASSUMPTION: <para> always appears as a child of list items -->
169 <xsl:apply-templates select="para/node()"/>
170 </xsl:template>
171
172 <!-- TODO: verify this works as expected (find an example of a nested list) -->
173 <xsl:template mode="list-item-indent"
174 match="listitem">{ancestor::listitem ! (1 to $list-indent-width) ! ' '}</xsl:template>
175
176 <xsl:template mode="list-item-label" match="itemizedlist">*</xsl:template>
177 <xsl:template mode="list-item-label" match="orderedlist" >#</xsl:template>
178
179 <!-- Lists inside a table cell require the use of "explicit list tags" for proper rendering -->
180 <xsl:template match="td//itemizedlist
181 | td//orderedlist">
182 <xsl:text>[</xsl:text>
183 <xsl:apply-templates mode="explicit-list-name" select="."/>
184 <xsl:text> </xsl:text>
185 <xsl:apply-templates mode="explicit-list-item"/>
186 <xsl:text>]</xsl:text>
187 </xsl:template>
188
189 <xsl:template mode="explicit-list-name" match="itemizedlist">itemized_list</xsl:template>
190 <xsl:template mode="explicit-list-name" match="orderedlist">ordered_list</xsl:template>
191
192 <xsl:template mode="explicit-list-item" match="listitem">
193 <xsl:text>[</xsl:text>
194 <xsl:apply-templates/>
195 <xsl:text>]</xsl:text>
196 </xsl:template>
197
198 <xsl:template mode="append" match="/page/div[1]">
199 <xsl:if test="$DEBUG">
200 <xsl:text>['</xsl:text>
201 <xsl:text>[role red \[Page type: [*{/*/@type}]\]] </xsl:text>
202 <xsl:text>[role green \[[@../../doc/html/{translate($doc-ref,'.','/')}/{
203 translate(/page/@id,'.','/')}.html [role green doc_build_html]]\]] </xsl:text>
204 <xsl:text>[@../build/xml-pages/{/page/@id}.xml [role blue [*\[doxygen_page_xml\]]]]</xsl:text>
205 <xsl:text>[@../build/stage1_visualized/visualized/{/page/@id}.html [role magenta ---stage1_visualized-->]]</xsl:text>
206 <xsl:text>[@../build/stage1_visualized/results/{ /page/@id}.xml [role blue [*\[docca_page_xml\]]]]</xsl:text>
207 <xsl:text>[@../build/stage2_visualized/visualized/{/page/@id}.html [role magenta ---stage2_visualized-->]]</xsl:text>
208 <xsl:text>[@../build/stage2_visualized/results/{ /page/@id}.txt [role blue [*\[quickbook_result\]]]]</xsl:text>
209 <xsl:text>]</xsl:text>
210 </xsl:if>
211 </xsl:template>
212
213 <xsl:template mode="before" match="para | div">{$nl}</xsl:template>
214
215 <xsl:template match="sp">{' '}</xsl:template>
216
217 <xsl:template match="linebreak">{$nl}{$nl}</xsl:template>
218
219 <xsl:template match="br">[br]</xsl:template>
220
221 <xsl:template mode="before" match="programlisting">{$nl}```{$nl}</xsl:template>
222 <xsl:template mode="after" match="programlisting" >```{$nl}</xsl:template>
223
224 <xsl:template mode="after" match="codeline">{$nl}</xsl:template>
225
226 <!-- Ignore whitespace-only text nodes -->
227 <xsl:template match="text()[not(normalize-space())]" priority="1"/>
228
229 <!-- By default, escape Quickbook markup (square brackets) -->
230 <xsl:template match="text()">
231 <xsl:sequence select="d:qb-escape(.)"/>
232 </xsl:template>
233
234 <!-- But don't escape them in these contexts -->
235 <xsl:template match="&SYNTAX_BLOCK;//text()
236 | &CODE_BLOCK;//text()
237 | programlisting//text()">
238 <!--
239 This implementation (using <xsl:sequence> returning a string, instead of <xsl:value-of>) can
240 result in a contiguous sequence of strings, which gets converted to a text node having space
241 separators between the strings. This is desirable in some cases and not in others.
242
243 TODO: Tighten the rules so that we explicitly add the spaces where we need them but otherwise
244 strip them out (probably by using <xsl:value-of> for the rules matching text nodes).
245 -->
246 <xsl:sequence select="string(.)"/>
247 </xsl:template>
248
249 <!-- Boilerplate default rules for elements -->
250 <!-- Convention of this stylesheet is to favor use of just "before" and "after"
251 and to utilize "append" (and maybe "insert") only when a distinction is needed -->
252 <xsl:template match="*" priority="10">
253 <xsl:apply-templates mode="before" select="."/>
254 <!-- enable if needed/desired
255 <xsl:apply-templates mode="insert" select="."/> -->
256 <xsl:next-match/>
257 <xsl:apply-templates mode="append" select="."/>
258 <xsl:apply-templates mode="after" select="."/>
259 </xsl:template>
260
261 <!-- Default before/after/insert/append rules are to do nothing -->
262 <xsl:template mode="before" match="*"/>
263 <!-- enable if needed/desired
264 <xsl:template mode="insert" match="*"/> -->
265 <xsl:template mode="append" match="*"/>
266 <xsl:template mode="after" match="*"/>
267
268
269 <xsl:function name="d:qb-escape">
270 <xsl:param name="string"/>
271 <xsl:sequence select="replace(
272 replace($string, '\[', '\\['),
273 '\]',
274 '\\]'
275 )"/>
276 </xsl:function>
277
278</xsl:stylesheet>