The Sun Doc Check doclet (DocCheck) is an API doc-comment checker for Java source files. DocCheck is a Javadoc doclet that identifies errors and generates templates for missing comments and comment-tags. It has multiple severity levels so you can focus on the most important errors first, and it provides both summary counts and a statistical breakdown of errors found. DocCheck process directories are recursively, so you don't need to specify a long list of packages. (You can also specify packages and classes to skip using the pattern-matching classes for filenames.)
DocCheck generates a series of Html files. Summaries are provided by package, by package group, and by class, with links to increasing levels of detail. In the detail pages, error message are shown on the left, and generated templates are shown on the right. On the right side, text that generated an errror is shown in red. Suggested-template text is shown in black.
Sample Output - For examples of the generated documents, see sampleOut/index.html.
For a list of errors that DocCheck finds, as well as those that it cannot find, and those it might possibly find in the future, see Errors Identified by DocCheck.
This section gives an overview of DocCheck's runtime options. These options are explained in detail below.
Sample Script - See the Sample script that produced the output given above.
You run DocCheck using the Javadoc -doclet and -docletpath switches:
javadoc -doclet com.sun.tools.doclets.doccheck.DocCheck \packagenames
-docletpath /home/user/doccheck1.2b2/doccheck.jar
\
[ ] [ sourcefilenames ] [ -subpackages pkg1:pkg2 ] [ options ]
Notes:
- On Windows, the line continuation character is
^(caret).- Instead of using -docletpath, you can put that path in your search path.
- -subpackages is a standard Javadoc option. See the Javadoc tool reference page.
Doclet options:
-classlist -docletID -authorID name -versionID string -skipPkg p1:p2:... -skipClass c1:c2:... -evident level -execDepth level -d target -help
Javadoc options:
-public -protected -sourcepath -docletpath
Additional options for control of generated text:
-ifcTxt -getTxt -setTxt -isTxt -valTxt -cnrTxt -objTxt -bSetTxt -bValTxt
Sample command line:
javadoc -J-Xmx200m \
-doclet com.sun.tools.doclets.doccheck.DocCheck \
-docletpath /home/user/doccheck1.2b2/doccheck.jar \
-d jdkout2 \
-classlist \
-docletID \
-title "Java 2 Platform, v1.3" \
-skipPkg 'org.omg.CosNaming.*' \
-execDepth 2 \
-skipClass 'org.omg.*.*Helper:org.omg.*.*Holder' \
-sourcepath /home/user/src \
com.package1 com.package2 MyClass.java
These commands are illustrated in the makeSample command script (written using the Unix CSH command shell). When run on the packages in sampleSrc directory, they produce the results shown in sampleOut.
Note: The options can be saved in a file and sent to javadoc with the @filename option. That reduces the command line to:
javadoc @filenameWithin the file, options can be on separate lines. (But an option that takes arguments must be on the same line with its arguments.) This option is most useful for specifying a long list of packages for Javadoc to process.
1.3 09/27/99".-skipPkg org.omg.CosNaming.*
(See Skip List Specifications.)-skipClass
org.omg.*.*Helper:org.omg.*.*Holder (See Skip List
Specifications.)getComponentName() would qualify as a (reasonably)
self-evident method. It would have this comment generated for it: "Returns
the component name". By default, such comments are treated the same as
any other missing comment (error level 2: Missing comment). Using the -evident
switch, you can reassign that error level to level 3 (tag error), 4 (text
error), or 5 (warning).| Unix | The Unix line-terminator. See NL, below. |
| Dos | The DOS line-terminator. See CR+LF, below. |
| NL | The Unix line-terminator, "NewLine" (\n). Recognized by many DOS utilities, as well. This is the default value. |
| CR+LF | The DOS line-terminator, "CarriageReturn + LineFeed" (\r + \n). |
| LF | Same as NL. (On Unix systems, DOS LF is usually known as NL.) |
| CR | For completeness, in case some system uses it. |
| LF+CR | For completeness, in case some system uses it. |
These options are provided by Javadoc. There are other options, as well, described at http://java.sun.com/products/jdk/1.2/docs/tooldocs/solaris/javadoc.html. But these are the main ones you'll need:
For methods like getX(), setX(), and isX(), DocCheck
generates a complete template with initial comment text and all tags fully specified.
DocCheck includes a variety of options that let you control the text that is
generated for the first line of an API comment. In each case, you follow the
option with the word or phrase you want to use in that position. For example:
-ifcTxt "This interface dictates that ...". The definitions
below show some standard alternatives you can use, or you can make up your own.
getFoo().
The default phrase is "Returns the foo value". The -getTxt
option replaces "Returns the".setFoo()
that sets a non-boolean variable. The default phrase is "Specifies the
foo value". The -setTxt option replaces "Specifies
the".isFoo().
The default phrase is "Returns true if this object is foo". The
-isTxt option replaces "Returns true of this object is".getFoo()
that returns a non-boolean variable. The default phrase is "Returns the
foo value". The -valTxt option replaces "value".-cnrTxt option replaces
"Constructs". (Typically, you will want to modify this phrase to
identify what is unique about this constructor relative to other constructors.)-objTxt option replaces
"object".setFoo()
that sets a boolean variable. The default phrase is "Identifies
this object as foo". The -bSetTxt option replaces "Identifies
this object as".isFoo()
and for a method named setFoo() that sets a boolean
variable. The default value is the null string that follows "foo"
in "Returns true if the value is foo" and "Identifies this
object as foo".-bSetTxt
and -isTxt similar to those shown above for -getTxt
and -setText
A list of packages to skip can be specified with -skipPkg.
A list of classes/interfaces to skip can be specified with -skipClass.
For both options, "*" wildcards can be specified, as defined
by the PathSpecifier class in pattern-matching
classes for filenames.
Entries in the list are divided by the path separator for the current system
(":" for Unix, ";" for DOS). Each entry in the list must be fully qualified,
however, patterns can be specified. Patterns can be specified for each part
of the path. So, "j*.s*" matches java.security as well as javax.swing. When
the directory path ends with "*", all subdirecories are implied. So "-skipClass
javax.swing.*.Foo" ignores all classes and interfaces named Foo in javax.swing
and all sub-sub-(etc)-packages of javax.swing. To limit the specification to
a single layer of packages, use "?*". Specifying javax.swing.?*.Foo would therefore
skip classes and interfaces named Foo in subpackages of javax.swing, but not
in sub-sub-packages. Here is the table of -skipPkg options for
processing various combinations of packages from the swing hierarchy:
swing
|
+---+---+
table text
|
html
Note that ignored classes, interfaces, and packages do not factor into the total number of packages, classes, and members processed. The statistics and percentages that are reported reflect only those items that are actually processed.
When you are having trouble using DocCheck, look here for insights.
-sourcepath option
is invalid or missing. The named file always ends with a "dot",
but that is simply a period. (When it occurs by itself, it looks like the
OS shortcut for "current directory", but it is still just a period.)
If the specified file(s) exist in the the current directory, or if the fully
qualified package name starts in the current directory, you don't need to
use the -sourcepath option. Otherwise, you need it. Check the
Doclet Options section for more details on this
option.
CR/LF-terminated
files on a Unix system, you can get some truly weird output running across
your screen. Don't do that.
package foo.bar;).
Some notes on DocCheck's features: how they work and how to use them:
@param foo an int that...
and
@param foo the most recent int value...
@param an <a href="...">URL</a>
as well as
@param an <a href="...">URL[]</a>
* @return true if ...
an array of Object)
//Inherited from java.awt.event.ActionListener.
(In the standard doclet such methods inherit their comments from the interface.)
The generated // comments can then be added to the source file to say, in
effect, "This space intentionally left blank." (There is as yet
no way for the doclet to check for the existence of such comments, so any
class containing such methods is listed in the -classlist file, so the file
can be inspected to see if the comments need to be added.)