You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2005/05/01 00:24:58 UTC

svn commit: r165425 - in /struts/flow/trunk: ./ src/doc/ src/examples/WEB-INF/wizard/ src/java/ src/java/org/apache/struts/flow/ src/java/org/apache/struts/flow/core/ src/java/org/apache/struts/flow/sugar/

Author: mrdon
Date: Sat Apr 30 15:24:56 2005
New Revision: 165425

URL: http://svn.apache.org/viewcvs?rev=165425&view=rev
Log:
 * Adding custom javadoc scripts to pull javadoc comments out of
   javascript files, Rhino Scriptable Java files, Java API extension
   files, and POJO Java files, destined to be exposed as script
   variables.
   The system uses XJavaDoc
   from XDoclet and Javascript scripts to create jsdoc XML files.  At
   this point, the only XSLT transforms the XML into Struts xdoc files.
   In the future, the XML files can be transformed into standalone HTML,
   text, or whatever format.
 * Renaming internal Javascript methods to better indicate they are
   meant for internal use. 
 * Adding more javadocs
 

Added:
    struts/flow/trunk/src/doc/extensions.js   (with props)
    struts/flow/trunk/src/doc/jsobjects.js   (with props)
Removed:
    struts/flow/trunk/src/doc/extensions.xdt
Modified:
    struts/flow/trunk/build.xml
    struts/flow/trunk/src/doc/extensions2xdoc.xsl
    struts/flow/trunk/src/doc/jsdoc.js
    struts/flow/trunk/src/doc/jsdoc2xdoc.xsl
    struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js
    struts/flow/trunk/src/java/org/apache/struts/flow/Struts.java
    struts/flow/trunk/src/java/org/apache/struts/flow/core/JSFlow.java
    struts/flow/trunk/src/java/org/apache/struts/flow/core/JSLog.java
    struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java
    struts/flow/trunk/src/java/system.js

Modified: struts/flow/trunk/build.xml
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/build.xml?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/build.xml (original)
+++ struts/flow/trunk/build.xml Sat Apr 30 15:24:56 2005
@@ -138,38 +138,23 @@
         <delete   dir="${doc.dir}" />
     </target>
 
-    
+    <target name="docs" depends="doc.extensions, doc.jsdoc, doc.jsobjects" 
+            description="Generates Struts Flow docs" />
+            
    <target name="doc.extensions" depends="prepare">
         <delete dir="${build.doc}/extensions"/>
-        <taskdef name="doclet"
-            classname="xdoclet.DocletTask"
-            classpathref="base.classpath"/>
-    
-        <doclet destdir="${build.doc}/extensions" verbose="true">
-            <fileset dir="${src.java}" includes="**/*Extensions.java"/>
-            <template templateFile="${src.doc}/extensions.xdt" destinationFile="extensions.xml"/>
-        </doclet>
+        <mkdir dir="${build.doc}/extensions" />
+       <java classname="org.apache.struts.flow.sugar.SugarWrapFactory">
+         <arg value="${src.doc}/extensions.js" />
+         <arg value="${src.java}/org/apache/struts/flow/sugar"/>
+         <arg value="${build.doc}/extensions"/>
+         <classpath refid="base.classpath" />
+        </java> 
         
-         <xslt basedir="${build.doc}/extensions" includes="extensions.xml" destdir="${build.doc}"
-          extension=".xml" style="${src.doc}/extensions2xdoc.xsl" />
+        <xslt basedir="${build.doc}/extensions" includes="*.xml" destdir="${build.doc}"
+          extension=".xml" style="${src.doc}/jsdoc2xdoc.xsl" />
    </target>
    
-   <!--
-   <target name="doc.extensions" depends="prepare">
-        <delete dir="${build.doc}/jsobjects"/>
-        <taskdef name="doclet"
-            classname="xdoclet.DocletTask"
-            classpathref="base.classpath"/>
-    
-        <doclet destdir="${build.doc}/jsobjects" verbose="true">
-            <fileset dir="${src.java}" includes="org/apache/struts/flow/Struts.java"/>
-            <template templateFile="${src.doc}/jsobjects.xdt" destinationFile="struts.xml"/>
-        </doclet>
-        
-         <xslt basedir="${build.doc}/jsobjects" includes="*.xml" destdir="${build.doc}"
-          extension=".xml" style="${src.doc}/jsobjects2xdoc.xsl" />
-   </target>
-     -->
    <target name="doc.jsdoc" depends="compile">
         <delete dir="${build.doc}/jsdoc"/>
         <mkdir dir="${build.doc}/jsdoc" />
@@ -184,6 +169,27 @@
         </java> 
         
         <xslt basedir="${build.doc}/jsdoc" includes="*.xml" destdir="${build.doc}"
+          extension=".xml" style="${src.doc}/jsdoc2xdoc.xsl" />
+   </target>
+    
+   <target name="doc.jsobjects" depends="compile">
+        <delete dir="${build.doc}/jsobjects"/>
+        <mkdir dir="${build.doc}/jsobjects" />
+    
+        <java classname="org.apache.struts.flow.sugar.SugarWrapFactory">
+         <arg value="${src.doc}/jsobjects.js" />
+         <arg value="${src.java}/org/apache/struts/flow/core"/>
+         <arg value="${build.doc}/jsobjects"/>
+         <classpath refid="base.classpath" />
+        </java>
+        <java classname="org.apache.struts.flow.sugar.SugarWrapFactory">
+         <arg value="${src.doc}/jsobjects.js" />
+         <arg value="${src.java}/org/apache/struts/flow"/>
+         <arg value="${build.doc}/jsobjects"/>
+         <classpath refid="base.classpath" />
+        </java>
+        
+        <xslt basedir="${build.doc}/jsobjects" includes="*.xml" destdir="${build.doc}"
           extension=".xml" style="${src.doc}/jsdoc2xdoc.xsl" />
    </target>
     

Added: struts/flow/trunk/src/doc/extensions.js
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/doc/extensions.js?rev=165425&view=auto
==============================================================================
--- struts/flow/trunk/src/doc/extensions.js (added)
+++ struts/flow/trunk/src/doc/extensions.js Sat Apr 30 15:24:56 2005
@@ -0,0 +1,134 @@
+importPackage(Packages.xjavadoc);
+importClass(java.io.File);
+importClass(Packages.xjavadoc.filesystem.FileSourceSet);
+
+function processFile(xclass, out) {
+
+    // write the header of the output file
+    doc = xclass.doc;
+    out.append("<jsdoc>");
+    out.append('<fileName>' + out.name + '</fileName>');
+    out.append("<title>"+doc.getTag("targetClass").value+" Extensions</title>");
+    out.append(processComment(doc));
+    for (x in xclass.methods) {
+        xmethod = xclass.methods[x];
+        if (xmethod.doc.hasTag("propReturn")) {
+            out.append(processProperty(xmethod.name, xmethod));
+        } else if (xmethod.doc.hasTag("funcReturn")) {
+            out.append(processMethod(xmethod.name, xmethod));
+        }
+    }    
+	out.append('</jsdoc>');
+}
+
+
+function processProperty(name, xmethod) {
+    var doc = xmethod.doc;
+        
+	return "<property><name>" + name + "</name>" +
+        "<type>" + doc.getTag("propReturn").value + "</type>" +
+		processComment(doc) +
+        "</property>";
+}
+
+function processMethod(name, xmethod) {
+    var doc = xmethod.doc;
+        
+	out = "<function><name>" + name + "</name>";
+    
+    out += "<type>" + doc.getTag("funcReturn").value + "</type>";
+    out += "<args>" + doc.getTag("funcParams").value + "</args>"
+    out += processComment(doc) + "</function>";
+    return out;
+}
+
+function processComment(doc) {
+
+	var out = "<comment><text><![CDATA[" + doc.commentText + "]]></text>";
+    out += "<firstSentence><![CDATA[" + doc.firstSentence + "]]></firstSentence>";
+    
+    tags = doc.getTags("funcParam");
+    for (t in tags) {
+        tag = tags[t];
+		var m = new String(tag.value).match(/(\w+)\s+(.*)/);
+		out += '<param><name>' + m[1] + '</name>';
+        out += '<description><![CDATA[' + m[2] + ']]></description>';
+        out += "</param>";
+    }
+    
+    for (t in doc.tags) {
+        tag = doc.tags[t];
+        out += '<' + tag.name + '><![CDATA[' + tag.value + ']]></' + tag.name + '>';
+    }
+    out += "</comment>";
+	return out;
+}
+
+function createOutputFile(outputdir,htmlfile)
+{
+    var separator = Packages.java.io.File.separator;
+    var outname = outputdir + separator + htmlfile.substring(htmlfile.lastIndexOf(separator),htmlfile.length);
+  print("output file: " + outname);
+  var f = new java.io.File(outname);
+  f.remove();
+  f.getParentFile().mkdirs();
+  return f;
+}
+
+function processFiles(xjavadoc, dir, outputdir) {
+    var f;
+    files = dir.listFiles();
+    for (f=0; f<files.length; f++) {
+        name = new String(files[f].getName());
+        if (name.match(/\.java$/) != null) {
+            name = name.replace(/[\/\\]/g, ".");
+            name = name.substring(name.indexOf("org.apache"), name.indexOf(".java"));
+            //print("looking up class: "+name);
+            xclass = xjavadoc.getXClass(name);
+            if (xclass.doc.hasTag("targetClass")) {
+                var xmlfile = xclass.name + ".xml";
+                
+                var out = createOutputFile(outputdir,xmlfile);
+                processFile(xclass, out);
+            }
+        }
+    }
+    
+    /* Doesn't seem to work correctly
+    print("leng:"+xjavadoc.getSourceClasses().size());
+    i = xjavadoc.sourceClasses.iterator();
+    while (i.hasNext()) {
+        xclass = i.next();
+        print("class:"+xclass.name);
+        if (xclass.getDoc().hasTag("jsname")) {
+        
+            // create the output file
+            var xmlfile = xclass.name + ".xml";
+        
+            var out = createOutputFile(outputdir,xmlfile);
+            processFile(xclass, out);
+        }
+    }
+    */
+}
+
+
+function print(val) {
+    java.lang.System.out.println((val == null ? "null" : val));
+}
+
+
+// Main Script
+// first read the arguments
+
+xjavadoc = new XJavaDoc();
+dir = new java.io.File(arguments[0]);
+fs = new FileSourceSet(dir);
+xjavadoc.addSourceSet(fs);
+
+outputdir = new File(arguments[1]);
+
+processFiles(xjavadoc, dir, outputdir);
+
+
+

Propchange: struts/flow/trunk/src/doc/extensions.js
------------------------------------------------------------------------------
    svn:executable = *

Modified: struts/flow/trunk/src/doc/extensions2xdoc.xsl
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/doc/extensions2xdoc.xsl?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/doc/extensions2xdoc.xsl (original)
+++ struts/flow/trunk/src/doc/extensions2xdoc.xsl Sat Apr 30 15:24:56 2005
@@ -2,7 +2,7 @@
 <xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 >
-	<xsl:output method="xml" />
+	<xsl:output method="xml" indent="yes" />
 
     <xsl:template match="/">
       <xsl:apply-templates />
@@ -31,10 +31,10 @@
           <table>
         <xsl:for-each select="method">
             <tr>
-              <td><xsl:value-of select="type" /></td>
+              <td><code><xsl:value-of select="type" /></code></td>
               <td>
-                <a href="#{../name}_{name}"><xsl:value-of select="name" /></a>(<xsl:value-of select="params" />) - 
-                <xsl:value-of select="firstSentence" /></td>
+                <strong><code><a href="#{../name}_{name}"><xsl:value-of select="name" /></a>(<xsl:value-of select="params" />)</code></strong>
+                <br /><dd><xsl:value-of select="firstSentence" /></dd></td>
              </tr>   
         </xsl:for-each>
            </table>
@@ -58,14 +58,12 @@
 <pre>
     <xsl:value-of select="concat(type,' ',name,'(',params,')')" />
 </pre>
-          <blockquote>
           <p><xsl:value-of select="comment" disable-output-escaping="yes"/>
           </p>
           <dl>
             <dt><strong>Example:</strong></dt>
-            <dd><code><xsl:value-of select="example" /></code></dd>
+            <dd><code><xsl:value-of select="example"  disable-output-escaping="yes"/></code></dd>
           </dl>
-          </blockquote>
       </section>
     </xsl:template>
     

Modified: struts/flow/trunk/src/doc/jsdoc.js
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/doc/jsdoc.js?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/doc/jsdoc.js (original)
+++ struts/flow/trunk/src/doc/jsdoc.js Sat Apr 30 15:24:56 2005
@@ -214,10 +214,14 @@
 function processFunction(name, args, comment) {
    if (debug)
     print("Processing " + name + " " + args + " " + comment);
-	return "<function><name>" + name + "</name>" +
-		"<args>" + args + "</args>" +
-		processComment(comment,0,name) +
-        "</function>";
+   if (name.charAt(0) != '_') {
+        return "<function><name>" + name + "</name>" +
+            "<args>" + args + "</args>" +
+            processComment(comment,0,name) +
+            "</function>";
+   } else {
+       print("Skipping function "+name);
+   }
 }
 
 /**
@@ -231,10 +235,14 @@
 function processPrototypeMethod(proto, name, args, comment) {
    if (debug)
     print("Processing " + proto + ".prototype." + name + " " + args + " " + comment);
+   if (name.charAt(0) != '_') {
 	return "<prototypeFunction><type>" + proto + "</type><name>" + name + "</name>" +
 		"<args>" + args + "</args>" +
 		processComment(comment,0,name) +
 		"</protytpeFunction>";
+   } else {
+       print("Skipping prototype function "+name);
+   }    
 }
 
 
@@ -271,7 +279,7 @@
 	  indexFileArray[fname] = comment;
 	}
 
-	var out = "<comment><![CDATA[" + comment + "]]></comment>";
+	var out = "<comment><text><![CDATA[" + comment + "]]></text>";
 	if (tags["param"]) {
 		// Create a table of parameters and their descriptions.
 		var array = tags["param"];
@@ -284,11 +292,11 @@
 		
 	}
     for (tag in tags) {
-        if (tag != "param") {
+        if (tag != "param" && tag != "title") {
             var array = tags[tag];
             if (array != null && array.length > 0) {
                 for (var i=0; i < array.length; i++) {
-                    out += '<' + tag + '>' + array[i] + '</' + tag + '>';
+                    out += '<' + tag + '><![CDATA[' + array[i] + ']]></' + tag + '>';
                 }
             }
         }
@@ -303,6 +311,13 @@
 		out += '</DL><P>';
 	}
     */
+    out += "</comment>";
+    if (tags["title"]) {
+        out += "<title>" + tags["title"][0] + "</title>";
+    }
+    if (tags["returnType"]) {
+        out += "<type>" + tags["returnType"][0] + "</type>";
+    }
 
 	// additional tags can be added here (i.e., "if (tags["see"])...")
 	return out;

Modified: struts/flow/trunk/src/doc/jsdoc2xdoc.xsl
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/doc/jsdoc2xdoc.xsl?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/doc/jsdoc2xdoc.xsl (original)
+++ struts/flow/trunk/src/doc/jsdoc2xdoc.xsl Sat Apr 30 15:24:56 2005
@@ -2,7 +2,7 @@
 <xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 >
-	<xsl:output method="xml" />
+	<xsl:output method="xml" indent="yes"/>
 
     <xsl:template match="/">
       <xsl:apply-templates />
@@ -11,48 +11,88 @@
 	<xsl:template match="jsdoc">
     <xsl:variable name="name" select="substring(fileName, 0, string-length(fileName) - 3)" />
 <document url="{$name}.html">
+    <xsl:variable name="title">
+      <xsl:if test="title"><xsl:value-of select="title" /></xsl:if>
+      <xsl:if test="not(title)"><xsl:value-of select="concat('File ',fileName)" /></xsl:if>
+    </xsl:variable>
   <xsl:comment>
     WARNING: This file is automatically generated from a jsdoc processor that
-    turns javadoc-type comments of Javascript files into an xml file, which is
+    turns javadoc-type comments of Javascript and special Java files into an xml file, which is
     then processed by an xsl file to create this document. Do not modify this
     file, but rather either modify the comments or xsl file.
   </xsl:comment>
   <properties>
-    <title>File <xsl:value-of select="fileName" /></title>
+    <title><xsl:value-of select="title" /></title>
   </properties>
   <body>
-    <xsl:variable name="title">
-      <xsl:if test="title"><xsl:value-of select="title" /></xsl:if>
-      <xsl:if test="not(title)"><xsl:value-of select="concat('File ',fileName)" /></xsl:if>
-    </xsl:variable>
+   
     <section name="{title}" href="summary">
       <p>
-        <xsl:value-of select="comment" disable-output-escaping="yes"/>
+        <xsl:value-of select="comment/text" disable-output-escaping="yes"/>
       </p>
       <dl>
-      <xsl:apply-templates select="author" />
-      <xsl:apply-templates select="version" />
-      <xsl:apply-templates select="see" />
+      <xsl:apply-templates select="comment/author" />
+      <xsl:apply-templates select="comment/version" />
+      <xsl:apply-templates select="comment/see" />
       </dl>
-      <hr />
-      <strong>Functions</strong>
-      <blockquote>
-      <xsl:for-each select="function">
-        <a href="#{concat('fn_',name)}"><xsl:value-of select="name" /></a>(<xsl:value-of select="args" />)<br />
-      </xsl:for-each>
-      </blockquote>
+      <xsl:if test="property">
+        <table width="100%">
+          <tr>
+            <th colspan="2">Property Summary</th>
+          </tr>
+          <xsl:for-each select="property">
+          <tr>
+            <td width="5%"><code><xsl:value-of select="type" /></code></td>
+            <td>
+              <strong><code><a href="#{concat('prop_',name)}"><xsl:value-of select="name" /></a></code></strong>
+              <xsl:if test="comment/firstSentence">
+                <dd><xsl:value-of select="comment/firstSentence" disable-output-escaping="yes" /></dd>
+              </xsl:if>
+            </td>
+          </tr>
+        </xsl:for-each>
+        </table>
+        <br />
+      </xsl:if>  
+      <xsl:if test="function">
+        <table width="100%">
+          <tr>
+            <th colspan="2">Function Summary</th>
+          </tr>
+          <xsl:for-each select="function">
+          <tr>
+            <td width="5%"><code><xsl:value-of select="type" /></code></td>
+            <td>
+              <strong><code><a href="#{concat('fn_',name)}"><xsl:value-of select="concat(name,'(',args,')')" /></a></code></strong>
+              <xsl:if test="comment/firstSentence">
+                <dd><xsl:value-of select="comment/firstSentence"  disable-output-escaping="yes"/></dd>
+              </xsl:if>
+            </td>
+          </tr>
+        </xsl:for-each>
+        </table>
+      </xsl:if>
     </section>
-      <xsl:apply-templates select="function" />
+    <xsl:if test="property">
+      <section name="Properties">
+        <xsl:apply-templates select="property" />
+      </section>
+    </xsl:if>
+    <xsl:if test="function">
+      <section name="Functions">
+        <xsl:apply-templates select="function" />
+      </section>
+    </xsl:if>
   </body>
 </document>
     </xsl:template>
     
     <xsl:template match="author">
-      <dt><strong>Author: </strong></dt><dd><xsl:value-of select="." /></dd>
+      <dt><strong>Author: </strong></dt><dd><xsl:value-of select="."  disable-output-escaping="yes" /></dd>
     </xsl:template>
     
     <xsl:template match="see">
-      <dt><strong>See Also: </strong></dt><dd><xsl:value-of select="." /></dd>
+      <dt><strong>See Also: </strong></dt><dd><xsl:value-of select="."  disable-output-escaping="yes"/></dd>
     </xsl:template>
     
     <xsl:template match="version">
@@ -60,39 +100,54 @@
     </xsl:template>
     
     <xsl:template match="return">
-      <dt><strong>Returns: </strong></dt><dd><xsl:value-of select="." /></dd>
+      <dt><strong>Returns: </strong></dt><dd><xsl:value-of select="."  disable-output-escaping="yes"/></dd>
+    </xsl:template>
+    
+    <xsl:template match="example">
+      <dt><strong>Example: </strong></dt><dd>
+<pre>
+<xsl:value-of select="."  disable-output-escaping="yes"/>
+</pre></dd>
     </xsl:template>
 
     <xsl:template match="function">
       <section name="{name}" href="fn_{name}">
 <pre>
-    <xsl:value-of select="concat(name,'(',args,')')" />
+    <xsl:value-of select="concat(type,' ',name,'(',args,')')" />
 </pre>
-          <p><xsl:value-of select="comment" disable-output-escaping="yes"/>
+          <p><xsl:value-of select="comment/text" disable-output-escaping="yes"/>
           </p>
-          <xsl:if test="param">
-            <table>
-              <tr>
-                <th>Parameter</th>
-                <th>Description</th>
-              </tr>
-              <xsl:for-each select="param">
-              <tr>
-                <td><xsl:value-of select="name" /></td>
-                <td><xsl:value-of select="description" /></td>
-              </tr>
+          <xsl:if test="comment/param">
+          <dl>
+            <dt><strong>Parameters:</strong></dt>
+              <xsl:for-each select="comment/param">
+              <dd>
+                <code><xsl:value-of select="name" /></code> - 
+                <xsl:value-of select="description"  disable-output-escaping="yes"/>
+              </dd>
               </xsl:for-each>
-            </table>
+            </dl>
           </xsl:if>
           <dl>
-            <xsl:apply-templates select="return" />
-            <xsl:apply-templates select="version" />
-            <xsl:apply-templates select="see" />
-            <xsl:apply-templates select="throws" />
+            <xsl:apply-templates select="comment/return" />
+            <xsl:apply-templates select="comment/version" />
+            <xsl:apply-templates select="comment/see" />
+            <xsl:apply-templates select="comment/throws" />
+            <xsl:apply-templates select="comment/example" />
           </dl>
       </section>
     </xsl:template>
     
+    <xsl:template match="property">
+      <section name="{name}" href="prop_{name}">
+<pre>
+    <xsl:value-of select="concat(type,' ',name)" />
+</pre>
+          <p><xsl:value-of select="comment/text" disable-output-escaping="yes"/>
+          </p>
+      </section>
+    </xsl:template>
+        
     <xsl:template match="text()" />
     
 </xsl:stylesheet>

Added: struts/flow/trunk/src/doc/jsobjects.js
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/doc/jsobjects.js?rev=165425&view=auto
==============================================================================
--- struts/flow/trunk/src/doc/jsobjects.js (added)
+++ struts/flow/trunk/src/doc/jsobjects.js Sat Apr 30 15:24:56 2005
@@ -0,0 +1,159 @@
+importPackage(Packages.xjavadoc);
+importClass(java.io.File);
+importClass(Packages.xjavadoc.filesystem.FileSourceSet);
+
+function processFile(xclass, out) {
+
+    // write the header of the output file
+    doc = xclass.doc;
+    out.append("<jsdoc>");
+    out.append('<fileName>' + out.name + '</fileName>');
+    out.append("<title>Variable '"+doc.getTag("jsname").value+"'</title>");
+    out.append(processComment(doc));
+    
+    var scriptable = false;
+    for (x in xclass.interfaces) {
+        var inf = xclass.interfaces[x];
+        if (inf.name.equals("Scriptable")) {
+            scriptable = true;
+            break;
+        }
+    }
+    for (x in xclass.methods) {
+        xmethod = xclass.methods[x];
+        
+        if (xmethod.name.startsWith('jsGet_') && scriptable) {
+            name = xmethod.name.substring(6);
+            out.append(processProperty(name, xmethod));
+        } else if (xmethod.name.startsWith('jsFunction_') && scriptable) {
+            name = xmethod.name.substring(11);
+            out.append(processMethod(name, xmethod));
+        } else if (!scriptable) {
+            out.append(processMethod(xmethod.name, xmethod));
+        }
+    }    
+	out.append('</jsdoc>');
+}
+
+
+function processProperty(name, xmethod) {
+    var doc = xmethod.doc;
+        
+	return "<property><name>" + name + "</name>" +
+        "<type>" + xmethod.returnType.type.name + "</type>" +
+		processComment(doc) +
+        "</property>";
+}
+
+function processMethod(name, xmethod) {
+    var doc = xmethod.doc;
+        
+	out = "<function><name>" + name + "</name>";
+    
+    out += "<type>" + xmethod.returnType.type.name + "</type>";
+    out += "<args>";
+    var params = xmethod.parameters;
+    for (p in params) {
+        var param = params[p];
+        out += param.type + " " + param.name;
+        if (p != params.length - 1) {
+            out += ", ";
+        }
+    }
+    out += "</args>"; 
+    out += processComment(doc) + "</function>";
+    return out;
+}
+
+function processComment(doc) {
+
+	var out = "<comment><text><![CDATA[" + doc.commentText + "]]></text>";
+    out += "<firstSentence><![CDATA[" + doc.firstSentence + "]]></firstSentence>";
+    
+    tags = doc.getTags("param");
+    for (t in tags) {
+        tag = tags[t];
+		var m = new String(tag.value).match(/(\w+)\s+(.*)/);
+		out += '<param><name>' + m[1] + '</name>';
+        out += '<description><![CDATA[' + m[2] + ']]></description>';
+        out += "</param>";
+    }
+    
+    for (t in doc.tags) {
+        tag = doc.tags[t];
+        if (tag.name != "param") {
+            out += '<' + tag.name + '><![CDATA[' + tag.value + ']]></' + tag.name + '>';
+        }
+    }
+    out += "</comment>";
+	return out;
+}
+
+function createOutputFile(outputdir,htmlfile)
+{
+    var separator = Packages.java.io.File.separator;
+    var outname = outputdir + separator + htmlfile.substring(htmlfile.lastIndexOf(separator),htmlfile.length);
+  print("output file: " + outname);
+  var f = new java.io.File(outname);
+  f.remove();
+  f.getParentFile().mkdirs();
+  return f;
+}
+
+function processFiles(xjavadoc, dir, outputdir) {
+    var f;
+    files = dir.listFiles();
+    for (f=0; f<files.length; f++) {
+        name = new String(files[f].getName());
+        if (name.match(/\.java$/) != null) {
+            name = name.replace(/[\/\\]/g, ".");
+            name = name.substring(name.indexOf("org.apache"), name.indexOf(".java"));
+            //print("looking up class: "+name);
+            xclass = xjavadoc.getXClass(name);
+            if (xclass.doc.hasTag("jsname")) {
+                var xmlfile = xclass.name + ".xml";
+                
+                var out = createOutputFile(outputdir,xmlfile);
+                processFile(xclass, out);
+            }
+        }
+    }
+    
+    /* Doesn't seem to work correctly
+    print("leng:"+xjavadoc.getSourceClasses().size());
+    i = xjavadoc.sourceClasses.iterator();
+    while (i.hasNext()) {
+        xclass = i.next();
+        print("class:"+xclass.name);
+        if (xclass.getDoc().hasTag("jsname")) {
+        
+            // create the output file
+            var xmlfile = xclass.name + ".xml";
+        
+            var out = createOutputFile(outputdir,xmlfile);
+            processFile(xclass, out);
+        }
+    }
+    */
+}
+
+
+function print(val) {
+    java.lang.System.out.println((val == null ? "null" : val));
+}
+
+
+// Main Script
+// first read the arguments
+
+xjavadoc = new XJavaDoc();
+dir = new java.io.File(arguments[0]);
+fs = new FileSourceSet(dir);
+xjavadoc.addSourceSet(fs);
+
+outputdir = new File(arguments[1]);
+
+processFiles(xjavadoc, dir, outputdir);
+
+
+

Propchange: struts/flow/trunk/src/doc/jsobjects.js
------------------------------------------------------------------------------
    svn:executable = *

Modified: struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js (original)
+++ struts/flow/trunk/src/examples/WEB-INF/wizard/wizard.js Sat Apr 30 15:24:56 2005
@@ -96,7 +96,7 @@
     var lastWebCont = lastContinuation;
     // create a continuation, the invocation of which will resend
     // the page: this is used to implement the back button
-    var wk = startContinuation(lastWebCont);
+    var wk = _startContinuation(lastWebCont);
     log.debug("saving spot "+wk.id+" before form:"+frm);
     
     // Loop to keep showing form until validation passes and next button 

Modified: struts/flow/trunk/src/java/org/apache/struts/flow/Struts.java
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/java/org/apache/struts/flow/Struts.java?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/java/org/apache/struts/flow/Struts.java (original)
+++ struts/flow/trunk/src/java/org/apache/struts/flow/Struts.java Sat Apr 30 15:24:56 2005
@@ -50,68 +50,119 @@
         }
     }
     
+    /**
+     *  Gets a map of request parameters as Strings
+     */
     public Map getParam() {
         return ctx.getParam();
     }
     
+    /**
+     *  Gets a map of request parameters as String arrays
+     */
     public Map getParamValues() {
         return ctx.getParamValues();
     }
     
+    /**
+     *  Gets a map of request attributes
+     */
     public Map getRequestScope() {
         return ctx.getRequestScope();
     }
     
+    /**
+     *  Gets a map of session attributes
+     */
     public Map getSessionScope() {
         return ctx.getSessionScope();
     }
     
+    /**
+     *  Gets a map of application attributes
+     */
     public Map getApplicationScope() {
         return ctx.getApplicationScope();
     }
     
+    /**
+     *  Gets the servlet request
+     */
     public ServletRequest getRequest() {
         return ctx.getRequest();
     }
     
+    /**
+     *  Gets the servlet context
+     */
     public ServletContext getServletContext() {
         return ctx.getContext();
     }
 
+    /**
+     *  Gets an application resources message
+     *
+     * @param key The message key
+     */
     public String getMessage(String key) {
         MessageResources res = (MessageResources)ctx.get(Constants.MESSAGE_RESOURCES_KEY);
         return res.getMessage(key);
     }
     
+    /**
+     *  Gets the action mapping
+     */
     public ActionMapping getMapping() {
         return (ActionMapping)ctx.get(Constants.ACTION_CONFIG_KEY);
     }
     
-    public boolean isCancelled() {
+    /**
+     * Gets if the action has been canceled
+     */
+    public boolean isCanceled() {
         FlowAction action = (FlowAction)ctx.get(Constants.ACTION_KEY);
         return action.isCancelled(ctx.getRequest());
     }
     
+    /**
+     *  Gets if the current token is valid
+     */
     public boolean isTokenValid() {
         FlowAction action = (FlowAction)ctx.get(Constants.ACTION_KEY);
         return action.isTokenValid(ctx.getRequest());
     }
     
+    /**
+     *  Resets the current transation token
+     */
     public void resetToken() {
         FlowAction action = (FlowAction)ctx.get(Constants.ACTION_KEY);
         action.resetToken(ctx.getRequest());
     }
     
+    /**
+     *  Saves the action errors in the request
+     *
+     * @param errors The action errors
+     */
     public void saveErrors(ActionErrors errors) {
         FlowAction action = (FlowAction)ctx.get(Constants.ACTION_KEY);
         action.saveErrors(ctx.getRequest(), errors);
     }
     
+    /** 
+     *   Saves the action messages in the request
+     *
+     * @param msgs The action messages
+     */
     public void saveMessages(ActionMessages msgs) {
         FlowAction action = (FlowAction)ctx.get(Constants.ACTION_KEY);
         action.saveMessages(ctx.getRequest(), msgs);
     }
     
+    /**
+     *  Saves a transaction token in the request
+     */
     public void saveToken() {
         FlowAction action = (FlowAction)ctx.get(Constants.ACTION_KEY);
         action.saveToken(ctx.getRequest());

Modified: struts/flow/trunk/src/java/org/apache/struts/flow/core/JSFlow.java
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/java/org/apache/struts/flow/core/JSFlow.java?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/java/org/apache/struts/flow/core/JSFlow.java (original)
+++ struts/flow/trunk/src/java/org/apache/struts/flow/core/JSFlow.java Sat Apr 30 15:24:56 2005
@@ -39,12 +39,18 @@
 import org.mozilla.javascript.JavaScriptException;
 
 /**
- *  JavaScript interface to the chain context and other helpful objects.
+ *  This variable provides an interface to the chain context and other helpful objects.
+ *  The primary way to pass information into a script is through the chain context.
+ *  All interactions with the outside environment is through Commons Chain to help
+ *  Struts Flow to work in a Servlet, Java Service Faces, Portlet, or any other 
+ *  external context, even if that context isn't web-based.  This variable specifically
+ *  doesn't contain any Struts-related methods to allow Struts Flow to be used outside
+ *  Struts.
  *
+ *@jsname flow
  *@author     <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  *@author     <a href="snoopdave@users.sourceforge.net">Dave Johnson</a>
- *@since      March 16, 2002
- *@version    CVS $Id: JSFlow.java,v 1.3 2004/11/05 05:12:10 mrdon Exp $
+ *@see        <a href="http://jakarta.apache.org/commons/chain">Jakarta Commons Chain</a>
  */
 public class JSFlow extends ScriptableObject {
     /**  The interpreter */
@@ -125,7 +131,8 @@
 
 
     /**
-     *  Load the script file specified as argument.
+     *  Load the script file specified as argument.  The path is resolved 
+     *  from the same root as the calling script.
      *
      *@param  filename                 a <code>String</code> value
      *@return                          an <code>Object</code> value
@@ -179,7 +186,7 @@
     }
 
     /**
-     *  Exposes jsobjectToMap to scripts.
+     *  Converts a JavaScript object to a HashMap
      */
     public Map jsFunction_jsobjectToMap(Scriptable jsobject) {
         return jsobjectToMap(jsobject);

Modified: struts/flow/trunk/src/java/org/apache/struts/flow/core/JSLog.java
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/java/org/apache/struts/flow/core/JSLog.java?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/java/org/apache/struts/flow/core/JSLog.java (original)
+++ struts/flow/trunk/src/java/org/apache/struts/flow/core/JSLog.java Sat Apr 30 15:24:56 2005
@@ -20,9 +20,7 @@
 /**
  *  JavaScript interface to the log facility.
  *
- *@author     <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
- *@since      March 16, 2002
- *@version    CVS $Id: JSLog.java,v 1.2 2004/06/03 19:33:29 mrdon Exp $
+ *@jsname log
  */
 public class JSLog extends ScriptableObject {
     Logger logger;

Modified: struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java (original)
+++ struts/flow/trunk/src/java/org/apache/struts/flow/sugar/SugarWrapFactory.java Sat Apr 30 15:24:56 2005
@@ -122,7 +122,9 @@
             // Initialize the standard objects (Object, Function, etc.)
             // This must be done before scripts can be executed. Returns
             // a scope object that we use in later calls.
-            Scriptable scope = cx.initStandardObjects();
+            //Scriptable scope = cx.initStandardObjects();
+            Scriptable scope = new ImporterTopLevel(cx);
+
         
             FileReader reader = new FileReader(args[0]);
             

Modified: struts/flow/trunk/src/java/system.js
URL: http://svn.apache.org/viewcvs/struts/flow/trunk/src/java/system.js?rev=165425&r1=165424&r2=165425&view=diff
==============================================================================
--- struts/flow/trunk/src/java/system.js (original)
+++ struts/flow/trunk/src/java/system.js Sat Apr 30 15:24:56 2005
@@ -22,8 +22,9 @@
  *  Starts a continuation, linking it with the last continuation.
  * @param lastWebCont The last web continuation to link this continuation to
  * @return The created continuation
+ * @returnType Continuation
  */
-function startContinuation(lastWebCont) {
+function _startContinuation(lastWebCont) {
     var k = new Continuation();
     
     // Use default ttl value from continuation manager
@@ -40,8 +41,9 @@
  * @param func The function object to call
  * @param args The argument list to pass to the function
  * @return The result of the function
+ * @returnType Object
  */ 
-function callFunction(func, args)
+function _callFunction(func, args)
 {
    suicide = new Continuation();
    return func.apply(this, args);
@@ -59,6 +61,7 @@
  *        to be called from asynchronously from the client.  An empty array
  *        allows any function call, a null or not specified array allows none.
  * @return The continuation created used in the call
+ * @returnType Continuation
  */
 function forwardAndWait(name, atts, allowedRemoteFuncs)
 {
@@ -109,6 +112,7 @@
  * @param name The Struts forward to call
  * @param atts The business object map to make available to the page
  * @return The continuation created 
+ * @returnType Continuation
  */
 function _forwardAndWait(name, atts)
 {
@@ -133,6 +137,7 @@
  * are instantiated.
  *
  * @param kont The continuation to reload
+ * @returnType void
  */ 
 function handleContinuation(kont)
 {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org