Javadoc Summary
Javadoc comments Delemented by /** and */ Used to document – Classes – Methods – Fields Must be placed immediately above the feature it documents
Documentation Each documentation comment contains introductory text followed by tagged documentation Tags start with character First sentence should be a summary statement
Documentation HTML tags can be embedded – emphasis – for monospaced font – for images – for bulleted lists – Etc.
Common javadoc parameter explanation – This is a parameter of a method. – Use a separate tag for each explanation – The return value of a – A feature that remains for compatibility but that should not be used for new code
Common javadoc packageName.ClassName – A reference to a related documentation – The author of a class or interface – Use a separate tag for each – The version of a class or interface
Example – method documentation /** This method withdraws money from the bank account. It increments the transaction amount the amount to the balance after the IllegalArgumentException if balance is not sufficient */ public double withdraw (double amount) { ………. }
To extract the comments Run the javadoc program – javadoc sourceFile
Javadoc Command Line Options -link URL – Link to another set of Javadoc files – Include a link to standard library documentation (locally or at Sun web site – -d directory – Store the output in directory – Keeps current directory uncluttered
Javadoc Command Line Options -author – Include author information in the documentation – Author information is omitted by default -version – Include version information in the documentation – Version information is omitted by default
Examples javadoc –author BankAccount.java Javadoc –author –version BankAccount.java
Files Produced by javadoc Names of each HTML file created by javadoc will be displayed Produces an HTML file for the class named BankAccount.html If source file contains multiple classes or interfaces, a separate HTML document is created for each class.
Files Produced by javadoc Creates an index.html file – Starting page Creates index-all.html page – Contains alphabetical list of all classes, interfaces, methods and fields
Example javadoc –d Page –author –version Employee.java index.html