In
my previous post, I explained about the java documentation comments, different
javadoc tags that are used to document the java code. Just like how we document
the classes, methods, interfaces, enums etc., we can provide documentation to a
package also.
Select the project ‘javadocDemo’ and set the visibility to ‘package’ and click on Finish button.
Previous Next Home
How
to provide documentation to a java package?
There
are two ways to add documentation at package level.
a. Create a file
'package-info.java' and add the documentation in that file
b. Create package.html
file and add package comments and Javadoc tags (no package annotations.)
A
package can have single package.html file or a single package-info.java file
but not both. Place either file in the package directory in the source tree
along with your .java files.
package-info.java
/** * This is the base package for all the model classes. * * @author krishna * @since 1 * @version 1 */ package com.sample.model;
(OR)
package.html
<HTML> <BODY> <h2>This is the base package for all the model classes.</h2> @author krishna @since 1.0 @version 1 </BODY> </HTML>
Demo application.
Create
new java project ‘javadocDemo’ in eclipse.
Create
a package ‘com.sample.model’. and define some class Employee.java.
Create
a file package-info.java.
Project
structure looks like below.
Go
to Project -> Generate Javadoc
Select the project ‘javadocDemo’ and set the visibility to ‘package’ and click on Finish button.
Documentation
is generated and placed in doc folder.
Open
index.html, you can able to see below information.
Previous Next Home
No comments:
Post a Comment