XDoclet dev'ers-

I'm working on a process to generate Ant's own task documentation
dynamically from the source code (perhaps with some merge points for
examples to be incorporated). Its a fair bit more complex than XDoclet's
documentation generation because an Ant task does not have to extend from
org.apache.tools.ant.Task (it just has to have an execute() method) and the
setters for attributes and adders/creators for subelements have some fairly
involved logic in determining their validity.

Ok, use-case aside, what I am looking for is some general guidelines to help
me along from the experts. I've already written a custom XDocletTagSupport
extension to handle some Ant-specific needs (forAllAttributes,
forAllElements, taskName) and this will surely grow.

But I also need to write a custom sub-task in order to pre-filter which
classes get processed, and also possibly where the resultant files get
placed.

Is there a good example I should follow for this?

What base class should I extend? [my guess: TemplateSubTask]

What methods are required for me to implement? [my guess: at least execute()
and getSubTaskName, probably engineStarted]

I notice that InfoSubTask has this constructor:
    public InfoSubTask( DocumentDocletTask documentDocletTask )

How are sub-tasks constructed?  They don't seem to require this kind of
constructor - but this gives me the task context so that I can log through
Ant's mechanisms. :)  Oops... a bit of digging while typing this message
turns up this in DocletTask:

   Class subtask_class = Class.forName( holder.getSubTaskClassName() );
   TemplateSubTask subtask = ( TemplateSubTask )
subtask_class.newInstance();

D'oh!  *darn* - I guess default constructor it is, and I see where
InfoSubTask is constructed differently.  This is one area where you guys
could steal from Ant as far as dynamic construction goes. It would be
slicker if the subtasks could have the DocumentDocletTask constructor and it
would be used instead of the no-arg constructor if it exists - then my
custom subtask could tap into the Ant task context (yes, I understand this
couples some, but hey, I'm an Ant guy and I want to log some things without
using log4j so that verbosity levels can be controlled with Ant command-line
switches! :).

Here are my specific needs:

- Do not process non-Task classes (i.e. no execute() method). How would I do
this in a custom subtask?
- Do not process inner classes. What code is needed for this?

How do I integrate this into my build file?  Here's what I've got so far:

    <document sourcepath="../../src/main"
              destdir="${gen.dir}"
              classpathref="xdoclet.classpath">
      <fileset dir="${src.dir}">
        <include name="*.java"/>
      </fileset>
      <template templateFile="${xdoc.template}"
                destinationfile="{0}.xml" extent="concrete-type"/>
    </document>

Do I just add subTaskClassName="..." to my <template> subtask to have it use
my custom subtask? [my guess: yes, this appears to be how it works]

Thanks for any advice you can provide me.  I think I'm on the right path,
but want to be sure by just tossing this out there and hearing suggestions
from folks.

Thanks,
    Erik

p.s. Thank you IDEA IntelliJ for making my research into XDoclet's core far
more pleasant and quick!


_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to