aboutsummaryrefslogtreecommitdiff
path: root/pow/POW-0.7/docs/doc.xsl
blob: 61b956704556fd676eefd9ccc8b447829734625a (plain) (blame)
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?xml version="1.0"?>

<xsl:stylesheet 
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   version="1.0"
>
   <xsl:template match="/">
      <book>
         <bookinfo>
            <title>The POW Package</title>
            <author><firstname>Peter</firstname> <surname>Shannon</surname></author>
         </bookinfo>
         <xsl:for-each select="collection/moduleSet">
            <xsl:call-template name="processModule"/>
         </xsl:for-each>
      </book>
   </xsl:template>

   <xsl:template name="processModule">
      <chapter>
         <title>The <xsl:value-of select="moduleDescription/header/name"/> Module</title>
         <sect1>
            <title>Introduction</title>
            <xsl:copy-of select="moduleDescription/body/*"/>
         </sect1>
         <xsl:if test="modulefunction">
            <sect1>
               <title>Module Functions</title>
               <xsl:call-template name="functionPrototypes"/>
               <xsl:call-template name="functionDescriptions"/>
            </sect1>
         </xsl:if>
         <sect1>
            <title>Module Classes</title>
            <xsl:call-template name="moduleClasses"/>
         </sect1>
      </chapter>
   </xsl:template>

   <xsl:template name="functionPrototypes">
      <sect2>
         <title>Function Prototypes</title>
         <funcsynopsis>
            <xsl:for-each select="modulefunction">
               <funcprototype>
                  <funcdef>def <function><xsl:value-of select="header/name"/></function></funcdef>
                  <xsl:call-template name="functionParameter"/>
               </funcprototype>
            </xsl:for-each>
         </funcsynopsis>
      </sect2>
   </xsl:template>

   <xsl:template name="functionDescriptions">
      <sect2>
         <title>Function Descriptions</title>
         <xsl:for-each select="modulefunction">
            <sect3>
               <title>The <function><xsl:value-of select="header/name"/></function> Function</title>

               <funcsynopsis>
                  <funcprototype>
                     <funcdef>def <function><xsl:value-of select="header/name"/></function></funcdef>
                     <xsl:call-template name="functionParameter"/>
                  </funcprototype>
               </funcsynopsis>

               <xsl:copy-of select="body/*"/>
            </sect3>
         </xsl:for-each>
      </sect2>
   </xsl:template>


   <xsl:template name="moduleClasses">
      <xsl:for-each select="class">
         <xsl:variable name="class">
            <xsl:value-of select="header/name"/>
         </xsl:variable>
         <sect2>
            <title>The <classname><xsl:value-of select="$class"/></classname> Class</title>

            <xsl:copy-of select="body/*"/>

            <sect3>
               <title>Class Prototypes</title> 
               <xsl:call-template name="methodPrototypes">
                  <xsl:with-param name="class">
                     <xsl:value-of select="$class"/>
                  </xsl:with-param>
               </xsl:call-template>
            </sect3> 

            <xsl:call-template name="methodDescriptions">
               <xsl:with-param name="class">
                  <xsl:value-of select="$class"/>
               </xsl:with-param>
            </xsl:call-template>

         </sect2>
      </xsl:for-each>
   </xsl:template>

   <xsl:template name="methodPrototypes">
      <xsl:param name="class"/>
      <classsynopsis>
         <xsl:attribute name="language">python</xsl:attribute>
         <ooclass><classname><xsl:value-of select="$class"/></classname></ooclass> 
         <xsl:if test="header/super">
            <xsl:for-each select="header/super">
               <ooclass><classname><xsl:value-of select="."/></classname></ooclass>
            </xsl:for-each>
         </xsl:if>
         <xsl:if test="..//header[memberof=$class]">
            <xsl:for-each select="../constructor[header/memberof=$class]">
               <constructorsynopsis>
                  <methodname><xsl:value-of select="$class"/></methodname> 
                  <xsl:call-template name="methodParameter"/>
               </constructorsynopsis> 
            </xsl:for-each>
            <xsl:for-each select="../method[header/memberof=$class]">
               <methodsynopsis>
                  <methodname><xsl:value-of select="header/name"/></methodname> 
                  <xsl:call-template name="methodParameter"/>
               </methodsynopsis> 
            </xsl:for-each>
         </xsl:if>
      </classsynopsis> 
   </xsl:template>

   <xsl:template name="functionParameter">
      <xsl:choose>
         <xsl:when test="header/parameter">
            <xsl:for-each select="header/parameter">
               <paramdef>
                  <parameter>
                     <xsl:value-of select="self::node()"/>
                  </parameter> 
               </paramdef> 
            </xsl:for-each>
         </xsl:when>
         <xsl:otherwise>
            <void/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

   <xsl:template name="methodParameter">
      <xsl:choose>
         <xsl:when test="header/parameter">
            <xsl:for-each select="header/parameter">
               <methodparam>
                  <parameter>
                     <xsl:value-of select="self::node()"/>
                  </parameter> 
               </methodparam> 
            </xsl:for-each>
         </xsl:when>
         <xsl:otherwise>
            <void/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

   <xsl:template name="methodDescriptions">
      <xsl:param name="class"/>

      <xsl:for-each select="../constructor[header/memberof=$class]">
         <xsl:if test="body">
            <sect3>
               <title>The <function>__init__</function> Method</title>
               <xsl:copy-of select="body/*"/>
            </sect3>
         </xsl:if>
      </xsl:for-each>

      <xsl:for-each select="../method[header/memberof=$class]">
         <xsl:if test="body">
            <sect3>
               <title>The <function><xsl:value-of select="header/name"/></function> Method</title>
               <xsl:copy-of select="body/*"/>
            </sect3>
         </xsl:if>
      </xsl:for-each>

   </xsl:template>

</xsl:stylesheet>