Skip to content

Commit 36be37c

Browse files
author
p12
committed
XSLT Stylesheets: support the 'link' attribute in constructors and destructors
1 parent 7dbef77 commit 36be37c

2 files changed

Lines changed: 56 additions & 31 deletions

File tree

index-functions.README

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This file defines the schema of the index-functions-*.xml files.
1+
This file defines the schema of the index-functions-*.xml files.
22

33
/index/const defines a macro/constant/enum value
44
/index/function defines a global function
@@ -14,42 +14,58 @@ This file defines the schema of the index-functions-*.xml files.
1414
//class/function defines a member function
1515
//class/class defines a member class
1616
//class/enum defines a member enum
17-
18-
"name" attribute: name of the function/class (without the parent class/namespace prefix)
19-
"link" attribute: (optional) link relative to the parent class
20-
by default equals to 'name'
21-
if set to "." the resulting link targets to the page of the parent class
17+
18+
"name" attribute: name of the function/class (without the parent
19+
class/namespace prefix)
20+
"link" attribute: (optional) link relative to the parent class. By
21+
default equals to 'name'. If set to "." the resulting
22+
link targets to the page of the parent class
2223

2324
"since" attribute: (optional) "c++11" or none
24-
25-
//class/overload
26-
27-
defines a function overload or function specialization of some function
25+
26+
//class/overload
27+
28+
defines a function overload or function specialization of some function
2829
accepts the class as one of the arguments and can be found using ADL.
29-
30+
3031
"name" attribute: name of the identifier (with the namespace prefix)
31-
"link" attribute: link relative to the parent class
32-
if set to "." the resulting link targets to the page of the parent class
32+
"link" attribute: link relative to the parent class. If set to "." the
33+
resulting link targets to the page of the parent class
3334
"since" attribute: (optional) "c++11" or none
34-
35+
3536
//class/specialization
36-
defines a specialization of an unrelated class for specific type (for
37+
defines a specialization of an unrelated class for specific type (for
3738
function specializations use 'overload')
38-
39+
3940
"name" attribute: name of the identifier (with the namespace prefix)
40-
"link" attribute: link relative to the parent class
41-
if set to "." the resulting link targets to the page of the parent class
41+
"link" attribute: (optional) link relative to the parent class. By
42+
default equals to 'name'. If set to "." the resulting
43+
link targets to the page of the parent class
4244
"since" attribute: (optional) "c++11" or none
4345

4446
//class/constructor
4547

46-
defines a constructor. Equivalent to <function name="@@@"/> where @@@ is the name of the
47-
parent class without the namespace prefix
48+
defines a constructor. Equivalent to <function name="@1" link="@2"/>
49+
where @1 and @2 are the following:
50+
@1 - the name of the parent class without the namespace prefix
51+
@2 - the link parameter if provided, the value of @1 otherwise.
52+
53+
"link" attribute: (optional) link relative to the parent class. By
54+
default equals to the name of the parent class without
55+
the namespace prefix. If set to ".", the resulting
56+
link targets to the page of the parent class.
4857

4958
//class/destructor
5059

51-
defines a destructor. Equivalent to <function name="~@@@"/> where @@@ is the name of the
52-
parent class without the namespace prefix
60+
defines a constructor. Equivalent to <function name="~@1" link="@2"/>
61+
where @1 and @2 are the following:
62+
@1 - the name of the parent class without the namespace prefix
63+
@2 - the link parameter if provided, the value of ~@1 otherwise.
64+
65+
"link" attribute: (optional) link relative to the parent class. By
66+
default equals to the name of the parent class without
67+
the namespace prefix. If set to ".", the resulting
68+
link targets to the page of the parent class.
5369

5470
/index/typedef defines a typedef
5571

@@ -59,9 +75,9 @@ This file defines the schema of the index-functions-*.xml files.
5975
Allowed identifiers: '/index/class' and '/index/enum'
6076
"since" attribute: (optional) "c++11" or none
6177
"alias" and "link" attributes are incompatible
62-
78+
6379
//class/typedef defines a member typedef
64-
80+
6581
"name" attribute: name of the identifier (with the namespace prefix)
6682
"link" attribute: link relative to the wiki root
6783
"alias" attribute: name of the identifier whose contents to import

index_transform.xsl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
</xsl:variable>
294294

295295
<xsl:value-of select="$parent-link"/>
296-
<xsl:if test="string($parent-link) and string($link)"><xsl:text>/</xsl:text></xsl:if>
296+
<xsl:if test="string($parent-link) and string($link)"><xsl:text>/</xsl:text></xsl:if>
297297
<xsl:value-of select="$link"/>
298298
</xsl:template>
299299

@@ -327,15 +327,24 @@
327327

328328
<xsl:template mode="get-full-link" match="constructor|destructor">
329329
<xsl:param name="parent-link" select="''"/>
330+
<xsl:variable name="link">
331+
<xsl:choose>
332+
<xsl:when test="@link">
333+
<xsl:apply-templates mode="get-link" select="."/>
334+
</xsl:when>
335+
<xsl:otherwise>
336+
<xsl:call-template name="get-last-item">
337+
<xsl:with-param name="string" select="$parent-link"/>
338+
<xsl:with-param name="sep" select="'/'"/>
339+
</xsl:call-template>
340+
</xsl:otherwise>
341+
</xsl:choose>
342+
</xsl:variable>
330343

331344
<xsl:value-of select="$parent-link"/>
332-
<xsl:if test="string($parent-link)"><xsl:text>/</xsl:text></xsl:if>
345+
<xsl:if test="string($parent-link) and string($link)"><xsl:text>/</xsl:text></xsl:if>
333346
<xsl:if test="local-name() = 'destructor'"><xsl:text>~</xsl:text></xsl:if>
334-
335-
<xsl:call-template name="get-last-item">
336-
<xsl:with-param name="string" select="$parent-link"/>
337-
<xsl:with-param name="sep" select="'/'"/>
338-
</xsl:call-template>
347+
<xsl:value-of select="$link"/>
339348
</xsl:template>
340349

341350
<!--=====================================================================-->

0 commit comments

Comments
 (0)