Hi, I wanted to be able to have info style doc tags on fields so I could export documentation of public static String CONSTANTS but it wanted something very similar to what the current todo tags support generates.
i.e.
/**
* @MyDocTag this is a constant that you want to generate info about
*/
public static final String USE_THIS_IN_YOUR_CODE = "SomeString"
I found that the InfoSubTask and the InfoTagsHandler we're biased against
fields so I made some mods to both and parameterized the templates that
InfoSubTask uses to make customization easier
I am pretty sure these are all backward compatible (we use the @todo tags)
and are probably worthwhile submissions
Also I added some methods to FieldTagsHandler
Here are the diffs (also attached)
Cheers,
Matthew
Index: InfoSubTask.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/doc/info/InfoSubTask.java,v
retrieving revision 1.13
diff -r1.13 InfoSubTask.java
36a37,43
> private String allPackagesTemplate;
> private String allClassesTemplate;
> private String indexTemplate;
> private String packageOverviewTemplate;
> private String classDetailTemplate;
> private String stylesheetTemplate;
> private String classesListTemplate;
48a56,69
>
> this.setStylesheetTemplate( "/xdoclet/doc/info/info.css" );
>
> this.setIndexTemplate( "/xdoclet/doc/info/index.j" );
>
> this.setAllClassesTemplate( "/xdoclet/doc/info/all-classes.j" );
>
> this.setAllPackagesTemplate( "/xdoclet/doc/info/all-packages.j" );
>
> this.setPackageOverviewTemplate(
"/xdoclet/doc/info/overview-packages.j" );
>
> this.setClassDetailTemplate( "/xdoclet/doc/info/class-details.j" );
>
> this.setClassesListTemplate( "/xdoclet/doc/info/classes-list.j" );
65a87,121
> public String getAllPackagesTemplate()
> {
> return allPackagesTemplate;
> }
>
> public String getAllClassesTemplate()
> {
> return allClassesTemplate;
> }
>
> public String getIndexTemplate()
> {
> return indexTemplate;
> }
>
> public String getPackageOverviewTemplate()
> {
> return packageOverviewTemplate;
> }
>
> public String getClassDetailTemplate()
> {
> return classDetailTemplate;
> }
>
> public String getStylesheetTemplate()
> {
> return stylesheetTemplate;
> }
>
> public String getClassesListTemplate()
> {
> return classesListTemplate;
> }
>
80a137,171
> public void setAllPackagesTemplate( String allPackagesTemplate )
> {
> this.allPackagesTemplate = allPackagesTemplate;
> }
>
> public void setAllClassesTemplate( String allClassesTemplate )
> {
> this.allClassesTemplate = allClassesTemplate;
> }
>
> public void setIndexTemplate( String indexTemplate )
> {
> this.indexTemplate = indexTemplate;
> }
>
> public void setPackageOverviewTemplate( String packageOverviewTemplate )
> {
> this.packageOverviewTemplate = packageOverviewTemplate;
> }
>
> public void setClassDetailTemplate( String classDetailTemplate )
> {
> this.classDetailTemplate = classDetailTemplate;
> }
>
> public void setStylesheetTemplate( String stylesheetTemplate )
> {
> this.stylesheetTemplate = stylesheetTemplate;
> }
>
> public void setClassesListTemplate( String classesListTemplate )
> {
> this.classesListTemplate = classesListTemplate;
> }
>
93c184
< setTemplateFile( new File( "/xdoclet/doc/info/info.css" ) );
---
> setTemplateFile( new File( this.getStylesheetTemplate() ) );
97c188
< setTemplateFile( new File( "/xdoclet/doc/info/index.j" ) );
---
> setTemplateFile( new File( this.getIndexTemplate() ) );
101c192
< setTemplateFile( new File( "/xdoclet/doc/info/all-classes.j" ) );
---
> setTemplateFile( new File( this.getAllClassesTemplate() ) );
105c196
< setTemplateFile( new File( "/xdoclet/doc/info/all-packages.j" ) );
---
> setTemplateFile( new File( this.getAllPackagesTemplate() ) );
109c200
< setTemplateFile( new File( "/xdoclet/doc/info/overview-packages.j" ) );
---
> setTemplateFile( new File( this.getPackageOverviewTemplate() ) );
117a209
> {
118a211
> }
131c224
< setTemplateFile( new File( "/xdoclet/doc/info/classes-list.j"
) );
---
> setTemplateFile( new File( this.getClassesListTemplate() ) );
139c232
< setTemplateFile( new File(
"/xdoclet/doc/info/class-details.j" ) );
---
> setTemplateFile( new File(
>this.getClassDetailTemplate() ) );
161a255,256
>
>
Index: InfoTagsHandler.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/doc/info/InfoTagsHandler.java,v
retrieving revision 1.7
diff -r1.7 InfoTagsHandler.java
4a5
> import com.sun.javadoc.FieldDoc;
11a13
> import xdoclet.tags.FieldTagsHandler;
49,50c51,52
< int a = tagCountInClass_Impl( getProperties(),
getCurrentClass(),
true );
< int b = tagCountInClass_Impl( getProperties(),
getCurrentClass(),
false );
---
> int a = tagCountInClass_Impl( getProperties(),
>getCurrentClass(), true,
false );
> int b = tagCountInClass_Impl( getProperties(),
>getCurrentClass(),
false, false );
56,57c58,59
< int a = tagCountInClass_Impl( getProperties(),
getCurrentClass(),
true );
< int b = tagCountInClass_Impl( getProperties(),
getCurrentClass(),
false );
---
> int a = tagCountInClass_Impl( getProperties(),
>getCurrentClass(), true,
false );
> int b = tagCountInClass_Impl( getProperties(),
>getCurrentClass(),
false, false );
60a63,68
> else if( "field".equals( level ) )
> {
> int a = fieldTagCountInClass_Impl( getProperties(),
getCurrentClass() );
>
> tagCount = a;
> }
91a100,104
> public String fieldTagValue() throws XDocletException
> {
> return getFieldTagsHandler().fieldTagValue( getProperties() );
> }
>
106a120,124
> public void forAllFieldTags( String template ) throws XDocletException
> {
> getFieldTagsHandler().forAllFieldTags( template, getProperties() );
> }
>
116a135,139
> public void forAllFields( String template ) throws XDocletException
> {
> getFieldTagsHandler().forAllFields( template, getProperties() );
> }
>
178a202,213
> private FieldTagsHandler getFieldTagsHandler() throws XDocletException
> {
> try
> {
> return ( ( FieldTagsHandler ) getEngine().getTagHandlerFor(
"Field" ) );
> }
> catch( TemplateException ex )
> {
> throw new XDocletException( ex, "FieldTagsHandler for
>namespace Field
not found!" );
> }
> }
>
254c289,294
< private int tagCountInClass_Impl( Properties attributes, ClassDoc
classDoc, boolean countMethods ) throws XDocletException
---
> private int tagCountInClass_Impl( Properties attributes, ClassDoc
classDoc, boolean countMethodsAndFields ) throws XDocletException
> {
> return tagCountInClass_Impl( attributes, classDoc,
countMethodsAndFields, countMethodsAndFields );
> }
>
> private int tagCountInClass_Impl( Properties attributes, ClassDoc
classDoc, boolean countMethods, boolean countFields ) throws
XDocletException
279a320,346
>
> if( countFields )
> {
>
> tagCount += fieldTagCountInClass_Impl( attributes, classDoc );
> }
>
> return tagCount;
> }
>
> private int fieldTagCountInClass_Impl( Properties attributes, ClassDoc
classDoc ) throws XDocletException
> {
> int tagCount = 0;
> String tag_name = attributes.getProperty( "tagName" );
>
> FieldDoc[] fields = classDoc.fields();
>
> for( int i = 0; i < fields.length; i++ )
> {
> Tag[] fieldTags = DocletUtil.getTagsByName( fields[i],
>tag_name );
>
> if( fieldTags != null )
> {
> tagCount += fieldTags.length;
> }
> }
>
Index: core/src/xdoclet/tags/FieldTagsHandler.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdoclet/core/src/xdoclet/tags/FieldTagsHandler.java,v
retrieving revision 1.3
diff -r1.3 FieldTagsHandler.java
21a22,52
>
> public static String getFieldTypeFor( FieldDoc field ) throws
XDocletException
> {
> return field.type().qualifiedTypeName() + field.type().dimension();
> }
>
> /**
> * Returns the type of the current field.
> *
> * @return Description of the Returned Value
> * @exception XDocletException Description of Exception
> * @doc:tag type="content"
> */
> public String fieldType() throws XDocletException
> {
> return getFieldTypeFor( getCurrentField() );
> }
>
> /**
> * Returns the name of the current method.
> *
> * @param attributes The attributes of the template tag
> * @return Description of the Returned Value
> * @exception XDocletException Description of Exception
> * @doc:tag type="content"
> */
> public String fieldName( Properties attributes ) throws XDocletException
> {
> return getCurrentField() != null ? getCurrentField().name() : "";
> }
>
diffs
Description: Binary data
