mkdb: add support for "closure" annotation
[gtk-doc.git] / devhelp2.xsl
blobb183e9ad5d391e47126f810e3c932d7ed12acceb
1 <?xml version='1.0'?> <!--*- mode: xml -*-->
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version='1.0'
4 xmlns="http://www.devhelp.net/book"
5 xmlns:str="http://exslt.org/strings"
6 exclude-result-prefixes="str">
8 <xsl:template name="generate.devhelp2">
9 <xsl:call-template name="write.chunk">
10 <xsl:with-param name="filename">
11 <xsl:choose>
12 <xsl:when test="$gtkdoc.bookname">
13 <xsl:value-of select="$gtkdoc.bookname"/>
14 </xsl:when>
15 <xsl:otherwise>
16 <xsl:text>book</xsl:text>
17 </xsl:otherwise>
18 </xsl:choose>
19 <xsl:text>.devhelp2</xsl:text>
20 </xsl:with-param>
21 <xsl:with-param name="method" select="'xml'"/>
22 <xsl:with-param name="indent" select="'yes'"/>
23 <xsl:with-param name="encoding" select="'utf-8'"/>
24 <xsl:with-param name="content">
25 <xsl:call-template name="devhelp2"/>
26 </xsl:with-param>
27 </xsl:call-template>
28 </xsl:template>
30 <xsl:template name="devhelp2">
31 <xsl:variable name="title">
32 <xsl:apply-templates select="." mode="generate.devhelp2.toc.title.mode"/>
33 </xsl:variable>
34 <xsl:variable name="link">
35 <xsl:call-template name="href.target"/>
36 </xsl:variable>
37 <xsl:variable name="author">
38 <xsl:if test="articleinfo|bookinfo">
39 <xsl:apply-templates mode="generate.devhelp2.authors"
40 select="articleinfo|bookinfo"/>
41 </xsl:if>
42 </xsl:variable>
43 <xsl:variable name="toc.nodes" select="part|reference|preface|chapter|
44 appendix|article|bibliography|
45 glossary|index|refentry|
46 bridgehead|sect1"/>
48 <book title="{$title}" link="{$link}" author="{$author}" name="{$gtkdoc.bookname}" version="2" language="c">
49 <xsl:if test="$toc.nodes">
50 <chapters>
51 <xsl:apply-templates select="$toc.nodes"
52 mode="generate.devhelp2.toc.mode"/>
53 </chapters>
54 </xsl:if>
55 <functions>
56 <xsl:apply-templates select="$gtkdoc.refsect2"
57 mode="generate.devhelp2.index.mode"/>
58 <xsl:apply-templates select="$gtkdoc.refsect2/variablelist[@role='enum']/varlistentry"
59 mode="generate.devhelp2.index.mode"/>
60 </functions>
61 </book>
62 </xsl:template>
64 <xsl:template match="*" mode="generate.devhelp2.toc.mode">
65 <xsl:variable name="title">
66 <xsl:apply-templates select="." mode="generate.devhelp2.toc.title.mode"/>
67 </xsl:variable>
68 <xsl:variable name="target">
69 <xsl:variable name="anchor" select="title/anchor"/>
70 <xsl:choose>
71 <xsl:when test="$anchor">
72 <xsl:call-template name="href.target">
73 <xsl:with-param name="object" select="$anchor"/>
74 </xsl:call-template>
75 </xsl:when>
76 <xsl:otherwise>
77 <xsl:call-template name="href.target"/>
78 </xsl:otherwise>
79 </xsl:choose>
80 </xsl:variable>
82 <sub name="{$title}" link="{$target}">
83 <xsl:apply-templates select="section|sect1|
84 refentry|refsect|
85 bridgehead|part|chapter|glossary|index"
86 mode="generate.devhelp2.toc.mode"/>
87 </sub>
88 </xsl:template>
90 <xsl:template match="*" mode="generate.devhelp2.index.mode">
91 <xsl:variable name="title" select="title|term/literal"/>
92 <xsl:variable name="anchor" select="title/anchor"/>
93 <xsl:variable name="type" select="@role"/>
94 <xsl:variable name="condition" select="@condition"/>
95 <xsl:variable name="target">
96 <xsl:choose>
97 <xsl:when test="$anchor">
98 <xsl:call-template name="href.target">
99 <xsl:with-param name="object" select="$anchor"/>
100 </xsl:call-template>
101 </xsl:when>
102 <xsl:otherwise>
103 <xsl:call-template name="href.target"/>
104 </xsl:otherwise>
105 </xsl:choose>
106 </xsl:variable>
107 <keyword type="{$type}" name="{$title}" link="{$target}">
108 <xsl:if test="$condition">
109 <xsl:for-each select="str:split($condition,'|')">
110 <xsl:variable name="attrname">
111 <xsl:value-of select="substring-before(.,':')"/>
112 </xsl:variable>
113 <xsl:choose>
114 <xsl:when test="string-length($attrname)=0">
115 <xsl:variable name="attrname2">
116 <xsl:value-of select="."/>
117 </xsl:variable>
118 <xsl:attribute name="{$attrname2}"/>
119 </xsl:when>
120 <xsl:otherwise>
121 <xsl:attribute name="{$attrname}">
122 <xsl:value-of select="substring-after(.,':')"/>
123 </xsl:attribute>
124 </xsl:otherwise>
125 </xsl:choose>
126 </xsl:for-each>
127 </xsl:if>
128 </keyword>
129 </xsl:template>
131 <!-- get title -->
132 <xsl:template match="article" mode="generate.devhelp2.toc.title.mode">
133 <xsl:value-of select="articleinfo/title"/>
134 </xsl:template>
135 <xsl:template match="book" mode="generate.devhelp2.toc.title.mode">
136 <xsl:value-of select="bookinfo/title"/>
137 </xsl:template>
138 <xsl:template match="refentry" mode="generate.devhelp2.toc.title.mode">
139 <xsl:value-of select="refmeta/refentrytitle"/>
140 </xsl:template>
141 <xsl:template match="*" mode="generate.devhelp2.toc.title.mode">
142 <xsl:value-of select="title"/>
143 </xsl:template>
145 <!-- generate list of authors ... -->
146 <xsl:template match="articleinfo|bookinfo" mode="generate.devhelp2.authors">
147 <xsl:for-each select="authorgroup/author">
148 <xsl:value-of select="firstname"/>
149 <xsl:text> </xsl:text>
150 <xsl:value-of select="surname"/>
151 <xsl:if test="not(last())">
152 <xsl:text>, </xsl:text>
153 </xsl:if>
154 </xsl:for-each>
155 </xsl:template>
157 </xsl:stylesheet>