Display XML in a javadoc

Let's say you have a comment like this
/**
 * To use this class use this XML
 *
 * <xml>
 *   <parameter>foo</parameter>
 *   <value>bar</value>
 * </xml>
 *
 */
The XML will not be visible since it will embedded in the HTML as tag and not as text.

With Javadoc 1.5, you can use the {@code ... } command. :

/**
 * To use this class use this XML
 * <pre>
 * {@code
 * <xml>
 *   <parameter>foo</parameter>
 *   <value>bar</value>
 * </xml>
 * }
 * </pre>
 */
With the previous versions, one way was to add a space after the <.
/**
 * To use this class use this XML
 * <pre>
 * < xml>
 *   < parameter>foo< /parameter>
 *   < value>bar< /value>
 * < /xml>
 * }
 * </pre>
 */


http://www.rgagnon.com/javadetails/java-0623.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章