[kepler-dev] ptdoclet simplification

ian.brown@hsbcib.com ian.brown at hsbcib.com
Mon Sep 10 01:32:54 PDT 2007


Looking into this a bit more, the original comment is wrong - the original
code looks for classes that extend NamedObj and not (as the comment says)
TypedAtomicActor.

Thus, the root.classNamed() call needs to reference
ptolemy.kernel.util.NamedObj rather than TypedAtomicActor.

Ian



                                                                           
             ian.brown at hsbcib.                                             
             com                                                           
                                                                        To 
             10/09/2007 08:24          "Christopher Brooks"                
             Mail Size: 15301          <cxh at eecs.berkeley.edu>             
                                                                        cc 
                                       cxh at EECS.Berkeley.EDU,              
                                       kepler-dev at ecoinformatics.org       
                                                                   Subject 
                                       Re: [kepler-dev] ptdoclet           
                                       simplification                      
                                                                    Entity 
                                       Investment Banking Europe - IBEU    
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hi Christoper,
      my code uses axis and fails on loading that - the strange thing is
that axis.jar is in the path.
The problem stems from the fact that the doclet is actually trying to load
the class - this is also why it has problems with matlab and graphic
element. The thing is, I don't think you need to load the class at all (see
the patch) because you can get all the information you need from the
ClassDoc.

As for the inner classes - I think you original code is trying to load them
and not trying to ignore them. Again, this falls out if you use the
ClassDoc directly because those inner classes are already there.

My guess is that when the code was originally written, ClassDoc.subclassOf
() did not exist.

Ian




             "Christopher
             Brooks"
             <cxh at eecs.berkele                                          To
             y.edu>                    ian.brown at hsbcib.com
             Sent by:                                                   cc
             cxh at EECS.Berkeley         kepler-dev at ecoinformatics.org
             .EDU                                                  Subject
                                       Re: [kepler-dev] ptdoclet
                                       simplification
             10/09/2007 02:33                                       Entity
             Mail Size: 9475           Investment Banking Europe - IBEU










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
----



************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a
new issue, by investment clients of the firm for whom the Bank as a firm
already provides other services. It may equally decide to allocate to its
own proprietary book or with an associate of HSBC Group. This represents a
potential conflict of interest. HSBC Bank plc has internal arrangements
designed to ensure that the firm would give unbiased and full advice to the
corporate finance client about the valuation and pricing of the offering as
well as internal systems, controls and procedures to identify and manage
conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised and regulated by the Financial Services Authority.
************************************************************

-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This transmission has been issued by a member of the HSBC Group
"HSBC" for the information of the addressee only and should not be
reproduced and/or distributed to any other person. Each page
attached hereto must be read in conjunction with any disclaimer
which forms part of it. Unless otherwise stated, this transmission
is neither an offer nor the solicitation of an offer to sell or
purchase any investment. Its contents are based on information
obtained from sources believed to be reliable but HSBC makes no
representation and accepts no responsibility or liability as to its
completeness or accuracy.
_______________________________________________
Kepler-dev mailing list
Kepler-dev at ecoinformatics.org
http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev



************************************************************
HSBC Bank plc may be solicited in the course of its placement efforts for a
new issue, by investment clients of the firm for whom the Bank as a firm
already provides other services. It may equally decide to allocate to its
own proprietary book or with an associate of HSBC Group. This represents a
potential conflict of interest. HSBC Bank plc has internal arrangements
designed to ensure that the firm would give unbiased and full advice to the
corporate finance client about the valuation and pricing of the offering as
well as internal systems, controls and procedures to identify and manage
conflicts of interest.

HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ, United Kingdom
Registered in England - Number 14259
Authorised and regulated by the Financial Services Authority.
************************************************************



More information about the Kepler-dev mailing list