java:javadoc
Differences
This shows you the differences between two versions of the page.
| Previous revision | |||
| — | java:javadoc [2022/12/02 21:02] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Javadoc made easy ====== | ||
| + | |||
| + | ===== Intro ===== | ||
| + | |||
| + | This document is about adding javadoc content to your project. Because I've read the help and | ||
| + | |||
| + | ===== Example of javadoc and its result ===== | ||
| + | |||
| + | <code javadoc> | ||
| + | /** | ||
| + | * The first sentence appears separated from the | ||
| + | * rest of the document, so be careful with | ||
| + | * the first dot, who denotes the end of the | ||
| + | * first sentence. | ||
| + | | ||
| + | * <p> | ||
| + | * < | ||
| + | * <p> | ||
| + | * Portions of code can be inserted this way:</ | ||
| + | <pre> | ||
| + | public class Circle extends Shape { | ||
| + | |||
| + | } | ||
| + | </ | ||
| + | * | ||
| + | | ||
| + | * And you can use all the html stuff you want to | ||
| + | * document your classes, methods, fields, and | ||
| + | * whatever you want.</ | ||
| + | * <p> | ||
| + | * For instance, here is a table:</ | ||
| + | * < | ||
| + | * <tr> | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * </tr> | ||
| + | * </ | ||
| + | | ||
| + | * @author rluna | ||
| + | * | ||
| + | */ | ||
| + | </ | ||
| + | |||
| + | and here is the result: | ||
| + | |||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | ===== Optional: Create an overview page for the entire application or set of packages ===== | ||
| + | |||
| + | You can create a overview page of the entire application. | ||
| + | To do this, just create a file called " | ||
| + | put it where you want. | ||
| + | |||
| + | I've put it just under the " | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | **What to put in this file** | ||
| + | |||
| + | Everything you think is relevant for the whole application or library you | ||
| + | are documenting. | ||
| + | |||
| + | __This page is not the first page of your documentation__: | ||
| + | contrary, it is only accessed trough the " | ||
| + | the upper or lower links of the page. | ||
| + | |||
| + | |||
| + | |||
| + | ==== My overview page ==== | ||
| + | |||
| + | Here goes an example of my overview page: | ||
| + | |||
| + | <code html> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | HERE CAN GO THE LICENSE, BECAUSE THIS DOESN' | ||
| + | </ | ||
| + | < | ||
| + | |||
| + | THE FIRST SENTENCE OF THE OVERVIEW, UNTIL THE LAST POINT IS DIFFERENCED | ||
| + | FROM THE REST. | ||
| + | <p> | ||
| + | Here goes the rest of the explanation. Like a normal comment, | ||
| + | you can put here link tags, and see tags if you need it. | ||
| + | |||
| + | @since 1.0 | ||
| + | @see java.lang.String | ||
| + | @author PUT THE AUTHOR IF YOU WANT | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== And how it looks like ==== | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | |||
| + | ===== Optional: Document the package ===== | ||
| + | |||
| + | You can create a file called " | ||
| + | order to document it. Put this file with the rest of java classes | ||
| + | of the package. | ||
| + | |||
| + | This is the content of my file: | ||
| + | |||
| + | < | ||
| + | /** | ||
| + | * HERE GOES A SINGLE LINE THAT DESCRIBES THE PACKAGE; THE FINAL | ||
| + | * DOT SPECIFIES WHEN IT SHOULD END THIS FIRST STATEMENT, SO | ||
| + | * BEWARE USING DOTS INSIDE THE LINE. | ||
| + | * <p> | ||
| + | * And here is a more descriptive HTML content about the | ||
| + | * package. You can use {@link com.supermanhamuerto.test.Rectangle} | ||
| + | * for inserting links and see tags | ||
| + | | ||
| + | * @author PUT HERE THE AUTHOR | ||
| + | * @since 1.0 | ||
| + | * @see com.supermanhamuerto.test.Shape | ||
| + | * @version 1.0 | ||
| + | */ | ||
| + | package com.supermanhamuerto.test; | ||
| + | </ | ||
| + | |||
| + | And this is how it looks like: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ===== Optional: where to put other files belonging to the docummentation ===== | ||
| + | |||
| + | You can create a directory called " | ||
| + | might need for the documentation. You can create this directory for every | ||
| + | directory package. | ||
| + | |||
| + | ==== To include an image for the documentation ==== | ||
| + | |||
| + | Let's say that in the documentation of our '' | ||
| + | an image: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | This would be done through the following javadoc comment: | ||
| + | |||
| + | <code javadoc> | ||
| + | /** | ||
| + | * This class outputs the classical message when run: | ||
| + | | ||
| + | * <img src=" | ||
| + | | ||
| + | * @author rluna | ||
| + | * | ||
| + | */ | ||
| + | </ | ||
| + | |||
| + | And you can add the image file '' | ||
| + | in the package where the '' | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | ===== An explanation of the tags, in javadoc ===== | ||
| + | |||
| + | As an example, I will document here the tags available in javadoc and the | ||
| + | corresponding result of this documentation as a javadoc: | ||
| + | |||
| + | <code html> | ||
| + | /** | ||
| + | * Examples and usage of javadoc tags. | ||
| + | * <br/> | ||
| + | * <br/> | ||
| + | * <table border=" | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * To insert code snippets in the comments.</ | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * instance, to refer an image: <img src=" | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * to copy more general comments from its parent classes and then | ||
| + | * copy to is derivated classes.</ | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * will show a link with the text of the " | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * normal font instead of code font.</ | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * {literal 3 < 5 > 7}</ | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * used to better describe the return of some method.</ | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * of reference may be: | ||
| + | * <ul> | ||
| + | * < | ||
| + | | ||
| + | | ||
| + | * </ul> | ||
| + | * </td> | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * specified since-text in it.</ | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * <tr> | ||
| + | * < | ||
| + | * < | ||
| + | * </tr> | ||
| + | * </ | ||
| + | | ||
| + | * @author rluna | ||
| + | * | ||
| + | */ | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | {{ : | ||
| + | |||
| + | ===== To make javadoc to skip a directory ===== | ||
| + | |||
| + | You can make javadoc to skip a directory simply by put a hyphen in this. This is | ||
| + | usually made for instance to skip test source files. | ||
| + | |||
| + | ===== Steps to generate a javadoc in eclipse ===== | ||
| + | |||
| + | Project -> generate javadoc: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | Fill the information in the first step. Normally you will have to | ||
| + | provide: | ||
| + | |||
| + | * select wich project (or package, or source file) do you want | ||
| + | the javadoc will generate documentation. Please attention to | ||
| + | this because | ||
| + | * identify the location of the javadoc tool (if you don't know, probably you need more basic reading: it's in the JDk directory) | ||
| + | * identify where do you want to store the html documents (in my case, I've selected the " | ||
| + | | ||
| + | {{ : | ||
| + | |||
| + | In the next step you will find a placeholder for the overview | ||
| + | page, set this if it is your case. | ||
| + | |||
| + | The following steps are more or less straightforward. | ||
| + | |||
| + | |||
| + | ===== Last but not least: the eclipse project I've used for this example ===== | ||
| + | |||
| + | {{: | ||
| + | |||
