API documentation generator
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 18 Feb 2006 04:57:20 +0000 (04:57 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 18 Feb 2006 04:57:20 +0000 (04:57 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3111 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/docgen.xsl [new file with mode: 0644]

diff --git a/Open-ILS/src/extras/docgen.xsl b/Open-ILS/src/extras/docgen.xsl
new file mode 100644 (file)
index 0000000..7305f96
--- /dev/null
@@ -0,0 +1,259 @@
+<?xml-stylesheet type="text/xsl"  href="#"?> 
+<xsl:stylesheet
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:res="http://example.com/test"
+  version="1.0"
+  >
+  <xsl:template match="xsl:stylesheet">
+    <html>
+      <head>
+        <style type="text/css">
+body { background-color:#F0F0F0; font: 9pt Verdana, Arial, "Arial Unicode MS", Helvetica, sans-serif;}
+input.button { font:8pt Verdana, Arail, "Arial Unicode MS", Helvetica, sans-serif;}
+input.text {}
+div.DDB { position:absolute; top:20pt; left:15pt; visibility:visible; }
+div.DLC { position:absolute; top:20pt; left:15pt; visibility:hidden; }
+div.numFound { position:absolute; top:0px; left:0pt; font-weight:bold;}
+
+table { background-color:lightgray; font-size:10pt; margin:10pt 0pt 15pt 0pt; width:90%; border-collapse: collapse; spacing:0; padding:0;}
+td { background-color:#f0f0f0; border: solid lightgray 1px; }
+td.fulltag { background-color:#f0f0f0;}
+td.fullind { background-color:#f0f0f0;  width:20pt;}
+td.fullfield{ background-color:#f0f0f0; width:100%;}
+
+table.signature { background-color:lightgray; font-size:10pt; margin:0; width:100%; border:none; padding:0;}
+table.params { background-color:lightgray; font-size:10pt; margin:3px 0px 3px 0px; width:100%; border: solid black 1px; padding:0;}
+td.params { background-color:lightgray; font-size:10pt; border: solid black 1px;}
+
+h1 { text-decoration: underline; }
+
+td.header { font-weight:bold; color:black; font-size:14pt; border-bottom: solid gray 2px}
+td.label { vertical-align:top; padding-left:10pt; width:120pt; font-weight:normal; color:darkblue;}
+td.value { vertical-align:top; text-align:left; font-weight: bold;}
+span.subcode { color:darkblue;}        </style>
+
+      </head>
+      <body>
+        <a name="top"/>
+
+<!--#if expr='"$QUERY_STRING" = /service=([^&]+)/' -->
+  <!--#set var="service" value="$1" -->
+<!--#endif -->
+
+<!--#if expr="$QUERY_STRING = /param=%22([^&]+)%22/" -->
+  <!--#set var="param" value="$1" -->
+<!--#endif -->
+
+        <xsl:if test="not(res:content)">
+         <br/><br/><br/><br/><br/><br/>
+         <br/><br/><br/><br/><br/><br/>
+       </xsl:if>
+
+        <form method="GET" action='<!--#echo var="DOCUMENT_URI" -->' onsubmit='this.param.value = "\"" + this.param.value + "\"";'>
+          <xsl:if test="not(res:content)">
+           <xsl:attribute name="style">
+             <xsl:value-of select="'text-align:center;'"/>
+           </xsl:attribute>
+         </xsl:if>
+          Service:
+         <input name="service" type="text" value='<!--#echo var="service" -->'>
+            <xsl:if test="not(res:content)">
+              <xsl:attribute name="value">
+               <xsl:value-of select="''"/>
+             </xsl:attribute>
+           </xsl:if>
+         </input>&#160; 
+          Method Name Regex:
+         <input name="param" type="text" value='<!--#echo var="param" -->'>
+            <xsl:if test="not(res:content)">
+             <xsl:attribute name="value">
+               <xsl:value-of select="''"/>
+             </xsl:attribute>
+           </xsl:if>
+         </input>&#160; 
+          <button name="method" value="opensrf.system.method">Find 'em</button>
+        </form>
+
+        <xsl:if test="res:content">
+         <hr/>
+
+          <xsl:apply-templates select="res:content/res:response"/>
+
+         <hr/>
+          <form method="GET" action='<!--#echo var="DOCUMENT_URI" -->' onsubmit='this.param.value = "\"" + this.param.value + "\"";'>
+            <xsl:if test="not(res:content)">
+             <xsl:attribute name="style">
+               <xsl:value-of select="'text-align:center;'"/>
+             </xsl:attribute>
+           </xsl:if>
+            Service:
+           <input name="service" type="text" value='<!--#echo var="service" -->'>
+              <xsl:if test="not(res:content)">
+                <xsl:attribute name="value">
+                 <xsl:value-of select="''"/>
+               </xsl:attribute>
+             </xsl:if>
+           </input>&#160; 
+            Method Name Regex:
+           <input name="param" type="text" value='<!--#echo var="param" -->'>
+              <xsl:if test="not(res:content)">
+               <xsl:attribute name="value">
+                 <xsl:value-of select="''"/>
+               </xsl:attribute>
+             </xsl:if>
+           </input>&#160; 
+            <button name="method" value="opensrf.system.method">Find 'em</button>
+          </form>
+
+       </xsl:if>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="res:api_name">
+    <a>
+      <xsl:attribute name="href">#<xsl:value-of select="./text()"/></xsl:attribute>
+      <xsl:value-of select="./text()"/>
+    </a>
+    <br/>
+  </xsl:template>
+
+  <xsl:template match="res:response">
+    <xsl:if test="count(//res:api_name) > 1">
+      <h1>Method Index</h1>
+      <xsl:apply-templates select="//res:api_name"/>
+
+      <h1>Method Definitions</h1>
+    </xsl:if>
+
+    <xsl:apply-templates select="res:hash/res:pair[res:key/text()='payload']/res:value/res:array/res:datum/res:Object"/>
+  </xsl:template>
+
+
+  <xsl:template match="res:Object">
+    <xsl:if test="res:remote/text()='0'">
+
+      <xsl:if test="count(//res:api_name) > 1">
+        <a>
+          <xsl:attribute name="name"><xsl:value-of select="res:api_name/text()"/></xsl:attribute>
+        </a>
+        <a href="#top">Top</a>
+      </xsl:if>
+
+      <table>
+        <tr>
+          <td colspan="3" class="header"><xsl:value-of select="res:api_name"/></td>
+        </tr>
+        <tr>
+          <td class="label">API Level:</td>
+          <td colspan="2" class="value"><xsl:value-of select="res:api_level"/></td>
+        </tr>
+        <tr>
+          <td class="label">Package:</td>
+          <td colspan="2" class="value"><xsl:value-of select="res:package"/></td>
+        </tr>
+        <tr>
+          <td class="label">Required argument count:</td>
+          <td colspan="2" class="value"><xsl:value-of select="res:argc"/></td>
+        </tr>
+        <xsl:if test="normalize-space(res:signature/res:desc/text()) != normalize-space(res:notes/text())">
+          <tr>
+            <td class="label">
+              <xsl:attribute name='rowspan'>
+                <xsl:value-of select='count(res:signature/res:params/res:hash) + 6'/>
+              </xsl:attribute>
+              Signature:
+            </td>
+          </tr>
+          <xsl:apply-templates select="res:signature"/>
+        </xsl:if>
+        <tr>
+          <td class="label">Streaming method:</td>
+          <td colspan="2" class="value">
+            <xsl:if test="res:stream/text()='1'">Yes</xsl:if>
+            <xsl:if test="res:stream/text()='0'">No</xsl:if>
+          </td>
+        </tr>
+        <xsl:if test="res:notes">
+          <tr>
+            <td class="label">Notes:</td>
+            <td colspan="2" class="value"><pre style="font-weight:normal;font-size:10px;"><xsl:value-of select="res:notes"/></pre></td>
+          </tr>
+        </xsl:if>
+      </table>
+    </xsl:if>
+  </xsl:template>
+
+
+  <xsl:template match="res:pair">
+    <tr>
+      <td class="label params">
+        <xsl:if test="res:key/text()='name'">Name:</xsl:if>
+        <xsl:if test="res:key/text()='desc'">Description:</xsl:if>
+        <xsl:if test="res:key/text()='type'">Data type:</xsl:if>
+        <xsl:if test="res:key/text()='class'">Object class:</xsl:if>
+      </td>
+      <td class="value params"><xsl:value-of select="res:value"/></td>
+    </tr>
+  </xsl:template>
+
+
+  <xsl:template match="res:hash">
+    <tr>
+      <td>
+        <table class="params">
+          <xsl:apply-templates select="res:pair[res:key/text()='name']"/>
+          <xsl:apply-templates select="res:pair[res:key/text()='desc']"/>
+          <xsl:apply-templates select="res:pair[res:key/text()='type']"/>
+          <xsl:apply-templates select="res:pair[res:key/text()='class']"/>
+        </table>
+      </td>
+    </tr>
+  </xsl:template>
+
+
+  <xsl:template match="res:signature">
+      <xsl:if test="res:desc">
+        <tr>
+          <td class="label">Description:</td>
+          <td class="value"><xsl:value-of select="res:desc"/></td>
+        </tr>
+      </xsl:if>
+      <xsl:if test="res:params/res:hash">
+        <tr>
+          <td class="label">
+            <xsl:attribute name='rowspan'>
+              <xsl:value-of select='count(res:params/res:hash) + 1'/>
+            </xsl:attribute>
+            Parameters:</td>
+        </tr>
+      </xsl:if>
+      <xsl:apply-templates select="res:params/res:hash"/>
+      <xsl:if test="res:return">
+        <tr>
+          <td class="label">Returns:</td>
+          <td class="value"><xsl:value-of select="res:return/res:desc"/></td>
+        </tr>
+        <tr>
+          <td class="label">Return type:</td>
+          <td class="value"><xsl:value-of select="res:return/res:type"/></td>
+        </tr>
+        <tr>
+          <td class="label">Return type class:</td>
+          <td class="value"><xsl:value-of select="res:return/res:class"/></td>
+        </tr>
+      </xsl:if>
+  </xsl:template>
+
+
+  <!--#if expr="$QUERY_STRING = /param=%22[^&]+%22/" -->
+    <!--#if expr="$QUERY_STRING = /service=[^&]+/" -->
+      <content xmlns="http://example.com/test">
+        <!--#include virtual="/restgateway?${QUERY_STRING}"-->
+      </content>
+    <!--#endif -->
+  <!--#endif -->
+
+
+</xsl:stylesheet>
+