tags:

views:

163

answers:

2

Is it possible to create a list of notes from a custom defined tag using JavaDoc? I have a business rules I want to flag throughout the code and it really doesn't fall under any of the existing tags that I know of. I suppose if there was a tag that did something similar to:

@note logic - You can only have twelve widgets in this container

It's sort of reverse documentation of constraints or requirements, and I'd like to document these because they weren't necessarily part of the original spec. One reason I'd like to document it in the source code is that the source code never seems to get lost, while the design spec, well... (not to mention nobody seems to read them)

+2  A: 

Why not just put it in the normal Javadoc comments itself? As an explanation of the summary of the class, method, etc. This is perfectly acceptable and it is how most of the JDK itself is documented.

If that's not good enough for you, perhaps you could create a custom attribute to tag members/methods/classes with, then you could easily programatically scan the classes and find all of your notes.

@CustomNote("You can only have twelve widgets in this container")
public class WidgetContainer { 
    ...
matt b
The only thing is, I wouldn't mind being able to collect them into one longer report, though I understand that some context is lost if the person writing the comments assumes they will always be read in the scope of the method.
altCognito
But otherwise, I didn't know you could do the custom note thing.
altCognito
Well, you'll just have to declare that attribute yourself..
matt b
A: 

XDoclet should be able to customized to what you want to do.

If you are using java 1.5+, you can use regular annotations, and compile them into a report. Here are instructions. That is definitely simpler than the XDoclet approach.

Yishai