Source Files (original) (raw)

The javadoc tool generates output that originates from the following types of source files: Java language source files for classes (.java), package comment files, overview comment files, and miscellaneous unprocessed files.

This topic describes source files, test files, and template files that can also be in the source tree, but that must be sure not to document.

Class Source Files

The source file of each class can have their own documentation comments.

Overview Comment Files

Each application or set of packages that you’re documenting can have its own overview documentation comment that's kept in its own source file, which the javadoc tool then merges into the generated overview page. You typically include in this comment any documentation that applies to the entire application or set of packages.

You can name the file anything that you want, such as overview.html and place it anywhere. A typical location is at the top of the source tree.

Oracle Solaris, Linux, and macOS: For example, if the source files for the java.math package are contained in the /home/user/src/java/math directory, then you could create an overview comment file in /home/user/src/overview.html.

Windows: For example, if the source files for the java.math package are contained in the C:\user\src\java\math directory, then you could create an overview comment file in C:\user\src\overview.html.

You can have multiple overview comment files for the same set of source files in case you want to run the javadoc tool multiple times on different sets of packages. For example, you could run the javadoc tool once with -private option for internal documentation and again without that option for public documentation. In this case, you could describe the documentation as public or internal in the first sentence of each overview comment file.

The content of the overview comment file is one big documentation comment that's written in HTML. Make the first sentence a summary about the application or set of packages. Don't put a title or any other text between the <body> tag and the first sentence. All tags, except inline tags, such as an {@link} tag, must appear after the main description. If you add an @see tag, then it must have a fully qualified name.

When you run the javadoc tool, specify the overview comment file name with the -overview option. The file is then processed similarly to that of a package comment file. The javadoc tool does the following:

Unprocessed Files

Your source files can include any files that you want the javadoc tool to copy to the destination directory. These files usually include graphic files, example Java source and class files, and self standing HTML files with a lot of content that would overwhelm the documentation comment of a typical Java source file.

To include unprocessed files, put them in a directory called doc-files. The doc-files directory can be a subdirectory of any package directory that contains source files. You can have one doc-files subdirectory for each package.

Oracle Solaris, Linux, and macOS: For example, if you want to include the image of a button in the java.awt.Button class documentation, then place the image file in the /home/user/src/java/awt/doc-files/ directory. Don't place the doc-files directory at /home/user/src/java/doc-files, because java isn't a package. It doesn't contain any source files.

Windows: For example, if you want to include the image of a button in the java.awt.Button class documentation, then place the image file in the \src\java\awt\doc-files directory. Don't place the doc-files directory at \src\java\doc-files, because java is not a package. It doesn't contain any source files.

All links to the unprocessed files must be included in the code because the javadoc tool doesn't look at the files. The javadoc tool copies the directory and all of its contents to the destination. The following example shows how the link in the Button.java documentation comment might look:

/**

Test and Template Files

You can store test and template files in the source tree in the same directory with or in a subdirectory of the directory where the source files reside. To prevent test and template files from being processed, run the javadoc tool and explicitly pass in individual source file names.

Test files are valid, compilable source files. Template files aren’t valid, compatible source files, but they often have the .java suffix.

Processing the Package Comment File

When the javadoc tool runs, it searches for the package comment file. If the package comment file is found, then the javadoc tool does the following: