javadoc n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Javadoc PowerPoint Presentation
Download Presentation
Javadoc

Loading in 2 Seconds...

play fullscreen
1 / 17

Javadoc - PowerPoint PPT Presentation


  • 152 Views
  • Uploaded on

Javadoc. Prasad Perera COMP 249. Comments in Java. // Can be single line comments. /* More than one line. Useful to "erase" a block of code from compilation */. /** * A Javadoc comment * To generate nice HTML documentation */. What is Javadoc?.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Javadoc' - guang


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
javadoc

Javadoc

Prasad Perera

COMP 249

comments in java
Comments in Java

// Can be single line comments

/* More than one line.

Useful to "erase" a block

of code from compilation */

/**

* A Javadoc comment

* To generate nice HTML documentation

*/

what is javadoc
What is Javadoc?
  • A standard for documenting Java programs .
  • Allows you to attach descriptions to classes, constructors, fields, interfaces and methods in the generated html documentation by placing Javadoc comments directly before their declaration statements.
  • Ex:

/**

*

* The Student class implements methods to calculate student grades.

*/

publicclass Student {

javadoc compilation
Javadoc Compilation
  • javadoc.exe
  • Generates documentation of your Java classes in a standard format
  • Comes with the JDK.
  • For each X.java, it will create an X.html plus a couple of additional pages (index, ..)
javadoc compilation cont d
Javadoc Compilation Cont’d.
  • Basic command line compilation:
    • Javadoc [options] [files]
    • some basic Javadoc options

-author

-classpath [path]  / [path];[path];

-sourcepath [path] / -sourcepathlist  [path];[path];

-version

  • Ex:
    • c:\> Javadoc -version 1.1 -sourcepath C:\Mysources –classpath C:\Mylibs
javadoc compilation cont d1
Javadoc Compilation Cont’d.
  • Generate javadoc using eclipse
general form of a javadoc comment
General form of a Javadoc comment

/**

* One sentence ending with a period describing the purpose.

* Additional lines giving

* more details (html tags can be included)

*

* javadoc tags to specify more specific information,

* such as parameters and return values for a method

*

* @Tag Description ...

* @Tag Description ...

*

*/

slide10
Tags
  • Allow you to specify specific information used in the HTML file
  • most common tags:
    • For files, classes and interfaces:

@author Name

@version Version number

    • For methods:

@param name description

@return description

@exception exceptionClass description

@deprecated description

    • For everything:

@see relatedReference (ex. other class name)

documenting java files classes and interfaces
Documenting Java Files, Classes and Interfaces

/**

* The Student class implements methods to calculate student grades.

* @authorprasad

* @version 1.1

* @see String

*/

publicclass Student {

documenting methods
Documenting Methods
  • Javadoccomments go immediately before the method definition
  • Common tags :
    • @param <name of parameter> <description>
    • @return <description>
  • ex:

/**

* Calculates the overall score for all the marks according to their weights

* @parammidExamMark mid exam mark

* @paramfinalExamMark final exam mark

* @return The final score calculated

*/

publicdoublecalculateOverallScore(intmidExamMark, intfinalExamMark){

javadoc extra
Javadoc Extra
  • Can add Html tags to the comments to add nicer formatting to the resulting document.
  • Advantages:
    • looks very nice…
    • provides a consistent look and feel to API documents
    • when source code is changed:
      • the Javadoc comments can be changed in the source, at the same time.
      • the external documentation is then easily re-generated.
javadoc extra cont d
Javadoc Extra Cont’d.

/**

* <p style="font-family:algerian;color:blue;font-size:20px;">The Student class implements methods to calculate student grades. :)</p>

* @authorprasad

* @version 1.1

* @see String

*/

publicclass Student {

references
References
  • Previous Javadoc tutorials (COMP 248)
  • http://students.cs.byu.edu/~cs240ta/fall2012/tutorials/javadoctutorial.html
  • http://www.oracle.com/technetwork/java/javase/documentation/index-jsp-135444.html