I'm working today on finishing up the JavaDoc for the ADF Toy Store Demo. In the past, I might have to manually search each source code file to find out what methods were missing JavaDoc, or might have to "eyeball" each method and make sure that I correctly was using the JavaDoc @param, @return, and @throws attributes.
In JDeveloper 10g, we have a new feature called "Audit" which allows you to audit your code to make sure that it follows a set of rules. JDev 10g ships with an API for defining your own custom audit rules -- a forthcoming HowTo on OTN by the product manager responsible for this feature should shed more light on that for you -- but in the meantime the product ships with a number of very-useful built-in audit rule-sets, one of which is called "JavaDoc". By running the "JavaDoc" audit on your project or workspace, you can have JDeveloper do all the hard work of finding where in your code you are missing JavaDoc or have implemented your JavaDoc incorrectly. Just like compilation errors, a log window pane appears showing you all the violations that you need to go fix, and as you are fixing them you can click the "Refresh" right mouse menu to update the list and see what's still left to fix.
On any rule violation in the list, you can select the right-mouse menu and get options that help you understand the violation and in some cases directly apply the fix to your code. For example, on one I see:
- Apply "Add Tag" (to fix the problem)
- About "Missing Required Tag" Rule...
- Hide "Missing Require Tag" Violations
There's also a menu pick at the top to "Apply Default Fixes" which I presume will fix all fixable audit problem automatically for me.
As if that weren't already a huge help, we also have a new feature called "Add JavaDoc Comments..." that's available on the right-mouse menu in the code editor so when you jump to a method that is missing JavaDoc, you just click on the method name and pick "Add JavaDoc Comments..." and correctly-formatted javadoc gets added for you. If you have forgotten a parameter name, spelled a parameter name wrong, or gotten the order of the parameters wrong, the combination of the JavaDoc audit plus the Add JavaDoc Comments... command can make quick work of fixing the problem. If you already have some JavaDoc and you pick "Add JavaDoc Comments..." it incrementally just adds the bits that are missing for you, leaving your existing comments in place.
To help you get in the habit of writing good JavaDoc comments from the start, when you begin to type a method comment with a "/**" then press [Enter] to go to the new line, JDeveloper automatically generates your JavaDoc comments with appropriate @param, @return, and @throws clauses for you. Of course, the developers needs to fill in the human-readable description of what the parameter means and what the method does, but all of the drudge work is done for you.
You can control exactly what the Add JavaDoc Comments related features add to your JavaDoc by visiting the:
Tools | Preferences... | Code Editor > Java > Javadoc
preference panel. It's really quite powerful and I can tell you first hand how much of a time-saver it is proving for me!
If you find yourself picking this right-mouse "Add JavaDoc Comments..." option many times, it might be time well spent to define a keyboard accelerator for it so you don't have to have your hands leave the keyboard to invoke the functionality. To do this, visit the:
Tools | Preferences... | Accelerators
preference page, select "Add JavaDoc Comments" in the "Actions:" list, and click into the "New Accelerator" field. Type some key combination like [Ctrl]-[Shift]-J or something, and then click (Ok). Now just press [Ctrl]-[Shift]-J will make the functionality kick in instead of having to use the mouse.
Last, but not least, once your code has JavaDoc comments as it should, anytime you click on a method in your code and want a refresher on what that method does and what it's parameters mean, you can do a right-mouse "Quick JavaDoc" and see a targeted JavaDoc entry in a floating window above your code that disappears after you've consulted it and gotten the information you need.
12:06:32 PM
|