]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/extras/docgen.xsl
API documentation generator
[Evergreen.git] / Open-ILS / src / extras / docgen.xsl
1 <?xml-stylesheet type="text/xsl"  href="#"?> 
2 <xsl:stylesheet
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4   xmlns:res="http://example.com/test"
5   version="1.0"
6   >
7   <xsl:template match="xsl:stylesheet">
8     <html>
9       <head>
10         <style type="text/css">
11 body { background-color:#F0F0F0; font: 9pt Verdana, Arial, "Arial Unicode MS", Helvetica, sans-serif;}
12 input.button { font:8pt Verdana, Arail, "Arial Unicode MS", Helvetica, sans-serif;}
13 input.text {}
14 div.DDB { position:absolute; top:20pt; left:15pt; visibility:visible; }
15 div.DLC { position:absolute; top:20pt; left:15pt; visibility:hidden; }
16 div.numFound { position:absolute; top:0px; left:0pt; font-weight:bold;}
17
18 table { background-color:lightgray; font-size:10pt; margin:10pt 0pt 15pt 0pt; width:90%; border-collapse: collapse; spacing:0; padding:0;}
19 td { background-color:#f0f0f0; border: solid lightgray 1px; }
20 td.fulltag { background-color:#f0f0f0;}
21 td.fullind { background-color:#f0f0f0;  width:20pt;}
22 td.fullfield{ background-color:#f0f0f0; width:100%;}
23
24 table.signature { background-color:lightgray; font-size:10pt; margin:0; width:100%; border:none; padding:0;}
25 table.params { background-color:lightgray; font-size:10pt; margin:3px 0px 3px 0px; width:100%; border: solid black 1px; padding:0;}
26 td.params { background-color:lightgray; font-size:10pt; border: solid black 1px;}
27
28 h1 { text-decoration: underline; }
29
30 td.header { font-weight:bold; color:black; font-size:14pt; border-bottom: solid gray 2px}
31 td.label { vertical-align:top; padding-left:10pt; width:120pt; font-weight:normal; color:darkblue;}
32 td.value { vertical-align:top; text-align:left; font-weight: bold;}
33 span.subcode { color:darkblue;}        </style>
34
35       </head>
36       <body>
37         <a name="top"/>
38
39 <!--#if expr='"$QUERY_STRING" = /service=([^&]+)/' -->
40   <!--#set var="service" value="$1" -->
41 <!--#endif -->
42
43 <!--#if expr="$QUERY_STRING = /param=%22([^&]+)%22/" -->
44   <!--#set var="param" value="$1" -->
45 <!--#endif -->
46
47         <xsl:if test="not(res:content)">
48           <br/><br/><br/><br/><br/><br/>
49           <br/><br/><br/><br/><br/><br/>
50         </xsl:if>
51
52         <form method="GET" action='<!--#echo var="DOCUMENT_URI" -->' onsubmit='this.param.value = "\"" + this.param.value + "\"";'>
53           <xsl:if test="not(res:content)">
54             <xsl:attribute name="style">
55               <xsl:value-of select="'text-align:center;'"/>
56             </xsl:attribute>
57           </xsl:if>
58           Service:
59           <input name="service" type="text" value='<!--#echo var="service" -->'>
60             <xsl:if test="not(res:content)">
61               <xsl:attribute name="value">
62                 <xsl:value-of select="''"/>
63               </xsl:attribute>
64             </xsl:if>
65           </input>&#160; 
66           Method Name Regex:
67           <input name="param" type="text" value='<!--#echo var="param" -->'>
68             <xsl:if test="not(res:content)">
69               <xsl:attribute name="value">
70                 <xsl:value-of select="''"/>
71               </xsl:attribute>
72             </xsl:if>
73           </input>&#160; 
74           <button name="method" value="opensrf.system.method">Find 'em</button>
75         </form>
76
77         <xsl:if test="res:content">
78           <hr/>
79
80           <xsl:apply-templates select="res:content/res:response"/>
81
82           <hr/>
83           <form method="GET" action='<!--#echo var="DOCUMENT_URI" -->' onsubmit='this.param.value = "\"" + this.param.value + "\"";'>
84             <xsl:if test="not(res:content)">
85               <xsl:attribute name="style">
86                 <xsl:value-of select="'text-align:center;'"/>
87               </xsl:attribute>
88             </xsl:if>
89             Service:
90             <input name="service" type="text" value='<!--#echo var="service" -->'>
91               <xsl:if test="not(res:content)">
92                 <xsl:attribute name="value">
93                   <xsl:value-of select="''"/>
94                 </xsl:attribute>
95               </xsl:if>
96             </input>&#160; 
97             Method Name Regex:
98             <input name="param" type="text" value='<!--#echo var="param" -->'>
99               <xsl:if test="not(res:content)">
100                 <xsl:attribute name="value">
101                   <xsl:value-of select="''"/>
102                 </xsl:attribute>
103               </xsl:if>
104             </input>&#160; 
105             <button name="method" value="opensrf.system.method">Find 'em</button>
106           </form>
107
108         </xsl:if>
109       </body>
110     </html>
111   </xsl:template>
112
113   <xsl:template match="res:api_name">
114     <a>
115       <xsl:attribute name="href">#<xsl:value-of select="./text()"/></xsl:attribute>
116       <xsl:value-of select="./text()"/>
117     </a>
118     <br/>
119   </xsl:template>
120
121   <xsl:template match="res:response">
122     <xsl:if test="count(//res:api_name) > 1">
123       <h1>Method Index</h1>
124       <xsl:apply-templates select="//res:api_name"/>
125
126       <h1>Method Definitions</h1>
127     </xsl:if>
128
129     <xsl:apply-templates select="res:hash/res:pair[res:key/text()='payload']/res:value/res:array/res:datum/res:Object"/>
130   </xsl:template>
131
132
133   <xsl:template match="res:Object">
134     <xsl:if test="res:remote/text()='0'">
135
136       <xsl:if test="count(//res:api_name) > 1">
137         <a>
138           <xsl:attribute name="name"><xsl:value-of select="res:api_name/text()"/></xsl:attribute>
139         </a>
140         <a href="#top">Top</a>
141       </xsl:if>
142
143       <table>
144         <tr>
145           <td colspan="3" class="header"><xsl:value-of select="res:api_name"/></td>
146         </tr>
147         <tr>
148           <td class="label">API Level:</td>
149           <td colspan="2" class="value"><xsl:value-of select="res:api_level"/></td>
150         </tr>
151         <tr>
152           <td class="label">Package:</td>
153           <td colspan="2" class="value"><xsl:value-of select="res:package"/></td>
154         </tr>
155         <tr>
156           <td class="label">Required argument count:</td>
157           <td colspan="2" class="value"><xsl:value-of select="res:argc"/></td>
158         </tr>
159         <xsl:if test="normalize-space(res:signature/res:desc/text()) != normalize-space(res:notes/text())">
160           <tr>
161             <td class="label">
162               <xsl:attribute name='rowspan'>
163                 <xsl:value-of select='count(res:signature/res:params/res:hash) + 6'/>
164               </xsl:attribute>
165               Signature:
166             </td>
167           </tr>
168           <xsl:apply-templates select="res:signature"/>
169         </xsl:if>
170         <tr>
171           <td class="label">Streaming method:</td>
172           <td colspan="2" class="value">
173             <xsl:if test="res:stream/text()='1'">Yes</xsl:if>
174             <xsl:if test="res:stream/text()='0'">No</xsl:if>
175           </td>
176         </tr>
177         <xsl:if test="res:notes">
178           <tr>
179             <td class="label">Notes:</td>
180             <td colspan="2" class="value"><pre style="font-weight:normal;font-size:10px;"><xsl:value-of select="res:notes"/></pre></td>
181           </tr>
182         </xsl:if>
183       </table>
184     </xsl:if>
185   </xsl:template>
186
187
188   <xsl:template match="res:pair">
189     <tr>
190       <td class="label params">
191         <xsl:if test="res:key/text()='name'">Name:</xsl:if>
192         <xsl:if test="res:key/text()='desc'">Description:</xsl:if>
193         <xsl:if test="res:key/text()='type'">Data type:</xsl:if>
194         <xsl:if test="res:key/text()='class'">Object class:</xsl:if>
195       </td>
196       <td class="value params"><xsl:value-of select="res:value"/></td>
197     </tr>
198   </xsl:template>
199
200
201   <xsl:template match="res:hash">
202     <tr>
203       <td>
204         <table class="params">
205           <xsl:apply-templates select="res:pair[res:key/text()='name']"/>
206           <xsl:apply-templates select="res:pair[res:key/text()='desc']"/>
207           <xsl:apply-templates select="res:pair[res:key/text()='type']"/>
208           <xsl:apply-templates select="res:pair[res:key/text()='class']"/>
209         </table>
210       </td>
211     </tr>
212   </xsl:template>
213
214
215   <xsl:template match="res:signature">
216       <xsl:if test="res:desc">
217         <tr>
218           <td class="label">Description:</td>
219           <td class="value"><xsl:value-of select="res:desc"/></td>
220         </tr>
221       </xsl:if>
222       <xsl:if test="res:params/res:hash">
223         <tr>
224           <td class="label">
225             <xsl:attribute name='rowspan'>
226               <xsl:value-of select='count(res:params/res:hash) + 1'/>
227             </xsl:attribute>
228             Parameters:</td>
229         </tr>
230       </xsl:if>
231       <xsl:apply-templates select="res:params/res:hash"/>
232       <xsl:if test="res:return">
233         <tr>
234           <td class="label">Returns:</td>
235           <td class="value"><xsl:value-of select="res:return/res:desc"/></td>
236         </tr>
237         <tr>
238           <td class="label">Return type:</td>
239           <td class="value"><xsl:value-of select="res:return/res:type"/></td>
240         </tr>
241         <tr>
242           <td class="label">Return type class:</td>
243           <td class="value"><xsl:value-of select="res:return/res:class"/></td>
244         </tr>
245       </xsl:if>
246   </xsl:template>
247
248
249   <!--#if expr="$QUERY_STRING = /param=%22[^&]+%22/" -->
250     <!--#if expr="$QUERY_STRING = /service=[^&]+/" -->
251       <content xmlns="http://example.com/test">
252         <!--#include virtual="/restgateway?${QUERY_STRING}"-->
253       </content>
254     <!--#endif -->
255   <!--#endif -->
256
257
258 </xsl:stylesheet>
259