4.3. Generating the API Documentation Website¶
The Javadoc tool (javadoc
) reads/parses the Javadoc comments in a set of
Java source files and produces a corresponding set of HTML pages
describing classes, interfaces, constructors, methods, and fields. This
effectively creates a website for the API documentation.
Note
You don’t have to understand website design to create a documentation
website because the javadoc
tool does the website creation!
Make sure you are in cs1302-javadoc
. Use the command presented
below to generate the API documentation website for the code
contained in this tutorial and place it in the doc
subdirectory.
javadoc -d doc -sourcepath src -subpackages cs1302
Understanding the Command
Here is a brief description of the command-line options that were used:
-d
– specifies the destination directory wherejavadoc
saves the generated HTML files;-sourcepath
– specifies the search paths for finding source files (.java
); and-subpackages
– specifies the packages for which documentation should be generated.
Check Your Work
Take a minute to watch the video below to see the expected output from the commands so far in this chapter:
You likely noticed that the javadoc
command generated a few warning
messages. That’s okay for now. It’s just letting us know that we are
missing comments for some of our code. We will fix that soon.
For now, run ls doc
to make sure files were generated. These files
contain our API Documentation website! Don’t worry, you won’t need
to open those files. However, we will want to make them visible
on the Web. We will do that in the next section!