Skip to content

How to Style Javadoc

sbottingota edited this page Dec 21, 2023 · 2 revisions

Guide to Javadoc (comments)

  • In front of your class (after the import statements but before the annotations), write /** and then press enter:
What the code should look like
// package stuff
// import statements


/**
*
*/

@TeleOp(name = "whatever", group = "whatever")
class Whatever extends OpMode {

}
  • Then, write one or two lines to describe what you're doing
What the code should look like
// package stuff
// import statements

/**
* Drive train code that totally exists. <br />
*/

@TeleOp(name = "whatever", group = "whatever")
class Whatever extends OpMode {

}
  • After that, use basic html elements that you should know to create an unordered list with all the controls.
  • {@link} as shown provides an inline link to a referenced part of our source code
What the code should look like
// package stuff
// import statements

/**
* Drive train code that totally exists. <br />
* 
 * Controls:
* <ul>
*     <li>Drive robot - right joystick</li>
*     <li>Do other thing - A (Circle on PlayStation)</li>
* </ul>
*
* - {@link #readFile}
*/

@TeleOp(name = "whatever", group = "whatever")
class Whatever extends OpMode {

}

Two tags we will use in methods

  • @param provides any useful description about a method’s parameter or input it should expect
  • @return provides a description of what a method will or can return
What the code should look like
/**
 * <p>This is a simple description of the method. . .
 * <a href="http://www.supermanisthegreatest.com">Superman!</a>
 * </p>
 * @param incomingDamage the amount of incoming damage
 * @return the amount of health hero has after attack
 */
public int successfullyAttacked(int incomingDamage) {
    // do things
    return 0;
}
  • When you're done, hover over the class name to check it's all formatted correctly.
  • If things that should be on different lines are on the same line, just add <br /> at the end of each line.

Clone this wiki locally