[kepler-dev] ptdoclet simplification

Christopher Brooks cxh at eecs.berkeley.edu
Sun Sep 9 18:33:53 PDT 2007


Hi Ian,
Looking at the logs, it looks like we skip PtolemyTransferable
and GraphicElement so that we can generate code in situations such 
as the nightly build where we don't have a graphical head.

The code involving the $ is an attempt to avoid running
the doclet on inner classes.


Do you have a test case that replicates the bug you are
seeing?  Are your classes in your classpath when
you run ptdoclet?

_Christopher

Christopher Brooks (cxh at eecs berkeley edu) University of California
Chess Executive Director                      US Mail: 337 Cory Hall #1774
Programmer/Analyst Chess/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718	      (office: 400A Cory)
home: (F-Tu) 707.665.0131 (W-F) 510.655.5480  

Below is your patch:



Index: PtDoclet.java
===================================================================
--- PtDoclet.java	(revision 4)
+++ PtDoclet.java	(working copy)
@@ -103,6 +103,7 @@
             allNamedObjsWriter = new FileWriter(_outputDirectory
                     + File.separator + "allNamedObjs.txt");
 
+            ClassDoc typedAtomicActorDoc = root.classNamed("ptolemy.actor.TypedAtomicActor");
             Class typedIOPortClass = Class.forName("ptolemy.actor.TypedIOPort");
             Class parameterClass = Class.forName("ptolemy.data.expr.Parameter");
             // The expression in the Expression actor is a StringAttribute.
@@ -112,63 +113,18 @@
             ClassDoc[] classes = root.classes();
             for (int i = 0; i < classes.length; i++) {
                 String className = classes[i].toString();
-                //System.out.println(className);
-                Class theClass = null;
-                try {
-                    if (className
-                            .equals("ptolemy.vergil.toolbox.PtolemyTransferable")
-                            || className
-                                    .equals("ptolemy.vergil.toolbox.GraphicElement")) {
-                        throw new Exception("Skipping " + className
-                                + ",it starts up X11 and interferes with the "
-                                + "nightly build");
-                    }
-                    if (className.equals("ptolemy.matlab.Engine")) {
-                        throw new Exception("Skipping " + className
-                                + ",it tends to hang javadoc.");
-                    }
-                    theClass = Class.forName(className);
-                } catch (Throwable ex) {
-                    // Might be an inner class.
-                    // Change the last . to a $ and try again
-                    int lastDotIndex = className.lastIndexOf(".");
-                    if (lastDotIndex != -1) {
-                        String innerClassName = className.substring(0,
-                                lastDotIndex)
-                                + "$" + className.substring(lastDotIndex + 1);
-                        try {
-                            theClass = Class.forName(innerClassName);
-                        } catch (Throwable ex2) {
-                            // FIXME: Use the doclet error handling mechanism
-                            System.err.println("Failed to process " + className
-                                    + ", tried " + innerClassName);
-                            ex2.printStackTrace();
-                            continue;
-                        }
-
-                    } else {
-                        // Print a message and move on.
-                        // FIXME: Use the doclet error handling mechanism
-                        System.err.println("Failed to process " + className);
-                        ex.printStackTrace();
-                        continue;
-                    }
-                }
-                if (!_namedObjClass.isAssignableFrom(theClass)) {
-                    // The class does not extend TypedAtomicActor, so we skip.
-                    continue;
-                }
-
-                StringBuffer documentation = _generateClassLevelDocumentation(classes[i]);
-                documentation.append(_generateFieldDocumentation(classes[i],
-                        typedIOPortClass, "port"));
-                documentation.append(_generateFieldDocumentation(classes[i],
-                        parameterClass, "property"));
-                documentation.append(_generateFieldDocumentation(classes[i],
-                        stringAttributeClass, "property"));
-                documentation.append("</doc>\n");
-                _writeDoc(className, documentation.toString());
-                allNamedObjsWriter.write(className + "\n");
+				if (classes[i].subclassOf(typedAtomicActorDoc)) {
+					StringBuffer documentation = _generateClassLevelDocumentation(classes[i]);
+					documentation.append(_generateFieldDocumentation(classes[i],
+							typedIOPortClass, "port"));
+					documentation.append(_generateFieldDocumentation(classes[i],
+							parameterClass, "property"));
+					documentation.append(_generateFieldDocumentation(classes[i],
+							stringAttributeClass, "property"));
+					documentation.append("</doc>\n");
+					_writeDoc(className, documentation.toString());
+					allNamedObjsWriter.write(className + "\n");
+				}
             }
         } finally {
             if (allNamedObjsWriter != null) {

--------

    
    --0__=0FBBF9DCDFD2BDB38f9e8a93df938690918c0FBBF9DCDFD2BDB3
    Content-Type: text/plain;
    	charset="US-ASCII"
    
    Hi all,
          I've been struggling lately with getting the ptdoclet to make
    documentation for some of my own classes. The problem was with how it needs
    to instantiate the classes (class loading errors). From looking at the
    code, I think it doesn't need to do that at all though. I replaced the
    class loading code so that now it is done via the ClassDoc mechanism. The
    code is simpler and should be more robust. The remaining class loading
    could also probably be eliminated but I was trying to make the minimal
    changes that fixed my problem.
    
    Diff against the current ptolemy head code is attached.
    
    Ian
----


More information about the Kepler-dev mailing list