File: tagfile-to-devhelp2.xsl

package info (click to toggle)
atkmm1.6 2.24.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,564 kB
  • sloc: sh: 11,269; xml: 5,642; perl: 236; cpp: 142; makefile: 84
file content (139 lines) | stat: -rw-r--r-- 6,316 bytes parent folder | download | duplicates (55)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.devhelp.net/book"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <!--
  Copyright (c) 2009  Daniel Elstner <daniel.kitta@gmail.com>

  XSL transformation from a Doxygen tag file to DevHelp 2 format.

  This script is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published
  by the Free Software Foundation, either version 2 of the License,
  or (at your option) any later version.

  This script is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this script.  If not, see <http://www.gnu.org/licenses/>.
  -->
  <xsl:strip-space elements="*"/>
  <xsl:output method="xml" version="1.0" indent="yes" encoding="UTF-8"/>

  <xsl:param name="book_title"/>
  <xsl:param name="book_name"/>
  <xsl:param name="book_base"/>

  <!-- Define keys to filter compounds that are members of other compounds -->
  <xsl:key name="nested-group" match="compound[@kind='group']" use="subgroup"/>
  <xsl:key name="nested-scope" match="compound[@kind='namespace']" use="namespace|class"/>
  <xsl:key name="nested-scope" match="compound[@kind='class' or @kind='struct' or @kind='union']"
           use="class"/>

  <xsl:template match="/">
    <book title="{$book_title}" name="{$book_name}" base="{$book_base}"
          link="index.html" version="2" language="c++">
      <chapters>
        <xsl:variable name="modules" select="tagfile/compound[@kind='group']"/>
        <xsl:if test="$modules">
          <sub name="Modules" link="modules.html">
            <!-- Select the top-level group compounds -->
            <xsl:apply-templates select="$modules[not(key('nested-group', name))]"
                                 mode="module-list">
              <xsl:sort lang="en" select="title"/>
            </xsl:apply-templates>
          </sub>
        </xsl:if>
        <xsl:variable name="namespaces" select="tagfile/compound[@kind='namespace']"/>
        <xsl:if test="$namespaces">
          <sub name="Namespaces" link="namespaces.html">
            <!-- Generate a flat list of fully qualified namespaces -->
            <xsl:for-each select="$namespaces">
              <xsl:sort lang="en" case-order="upper-first" select="name"/>
              <sub name="{name}" link="{filename}"/>
            </xsl:for-each>
          </sub>
        </xsl:if>
        <xsl:if test="tagfile/compound[@kind='class' or @kind='struct' or @kind='union']">
          <sub name="Classes" link="classes.html">
            <!-- Select the top-level C++ compounds -->
            <xsl:apply-templates select="tagfile/compound[not(key('nested-scope', name))]"
                                 mode="class-list">
              <xsl:sort lang="en" case-order="upper-first" select="name"/>
            </xsl:apply-templates>
          </sub>
        </xsl:if>
      </chapters>
      <functions>
        <xsl:apply-templates select="tagfile/compound" mode="keyword-list"/>
      </functions>
    </book>
  </xsl:template>

  <xsl:template match="compound" mode="module-list">
    <xsl:variable name="children" select="subgroup"/>
    <sub name="{title}" link="{filename}">
      <!-- Select any subgroup compounds by name -->
      <xsl:apply-templates select="../compound[@kind='group' and name=$children]"
                           mode="module-list">
        <xsl:sort lang="en" select="title"/>
      </xsl:apply-templates>
    </sub>
  </xsl:template>

  <xsl:template match="compound[@kind='namespace' or @kind='class' or @kind='struct' or @kind='union']"
                mode="class-list">
    <!-- The scope prefix to strip from the name -->
    <xsl:param name="scope"/>
    <xsl:variable name="fullname" select="name"/>
    <xsl:variable name="children" select="namespace|class"/>
    <sub name="{substring-after($fullname, $scope)}" link="{filename}">
      <!-- Select any nested C++ compounds by name -->
      <xsl:apply-templates select="../compound[name=$children]" mode="class-list">
        <xsl:sort lang="en" case-order="upper-first" select="name"/>
        <xsl:with-param name="scope" select="concat($fullname, '::')"/>
      </xsl:apply-templates>
    </sub>
  </xsl:template>
  <!-- Ignore any other kind of compound -->
  <xsl:template match="*" mode="class-list"/>

  <xsl:template match="compound[@kind='namespace']" mode="keyword-list">
    <!-- Process members, but do not list the namespace itself as a keyword -->
    <xsl:apply-templates select="member" mode="keyword-list"/>
  </xsl:template>
  <xsl:template match="compound[@kind='class' or @kind='struct' or @kind='union']"
                mode="keyword-list">
    <!-- List the compound type itself as a keyword and process its members -->
    <keyword type="struct" name="{name}" link="{filename}"/>
    <xsl:apply-templates select="member" mode="keyword-list"/>
  </xsl:template>
  <!-- Match leaf compound members -->
  <xsl:template match="member[@kind='typedef']" mode="keyword-list">
    <keyword type="typedef" xsl:use-attribute-sets="keyword-member"/>
  </xsl:template>
  <xsl:template match="member[@kind='function' or @kind='friend']" mode="keyword-list">
    <keyword type="function" xsl:use-attribute-sets="keyword-member"/>
  </xsl:template>
  <xsl:template match="member[@kind='enumeration']" mode="keyword-list">
    <keyword type="enum" xsl:use-attribute-sets="keyword-member"/>
  </xsl:template>
  <xsl:template match="member[@kind='enumvalue' or @kind='define']" mode="keyword-list">
    <keyword type="macro" xsl:use-attribute-sets="keyword-member"/>
  </xsl:template>
  <!-- Ignore unknown keyword types -->
  <xsl:template match="*" mode="keyword-list"/>

  <!-- Qualify member name and link anchor -->
  <xsl:attribute-set name="keyword-member">
    <xsl:attribute name="name">
      <xsl:value-of select="concat(../name, '::', name)"/>
    </xsl:attribute>
    <xsl:attribute name="link">
      <xsl:value-of select="concat(anchorfile, '#', anchor)"/>
    </xsl:attribute>
  </xsl:attribute-set>

</xsl:stylesheet>