Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting sample XML code in Javadoc

How to put a sample XML code in Javadoc? The XML code includes angle brackets which I do not want to be processed.

I tried combinations of PRE and code but it didn't work.

like image 381
Suzan Cioc Avatar asked Oct 27 '14 13:10

Suzan Cioc


People also ask

How do you add a Javadoc code?

Place the caret at the declaration in the editor, press Alt+Enter , and select Add Javadoc from the list.

What should be included in a Javadoc?

Before using JavaDoc tool, you must include JavaDoc comments /**……………….. */ providing information about classes, methods, and constructors, etc. For creating a good and understandable document API for any java file you must write better comments for every class, method, constructor.

What does @SEE mean in Javadoc?

We can use the @see and @link tag multiple times in a class, package, or method. The @see tag declares references that point to an external link, class, or method. The @link tag can also be used multiple times for declaring inline links or in contrast with other block tags.

Can you use HTML tags in Javadoc comments?

There are no real restrictions on the use of HTML in Javadoc comments. The Javadoc documentation states: Comments are written in HTML - The text must be written in HTML, in that they should use HTML entities and can use HTML tags.


2 Answers

You can use @code javadoc tag. Take a look to this post, wich contains some examples. Hope it helps

/**
 * To use this class use this XML   
 * <pre>
 * {@code
 * <xml>
 *   <parameter>foo</parameter>
 *   <value>bar</value>
 * </xml>
 * }
 * </pre>
 */
like image 58
troig Avatar answered Nov 02 '22 11:11

troig


You have to use HTML/XML encoding like &lt; for < and &gt; for >.

If you use Eclipse, there is a Javadoc view that shows you a preview.

like image 37
Andy Avatar answered Nov 02 '22 11:11

Andy