Does Javadoc have the equivalent of <! [CDATA [...]]>?
Unfortunately, HTML does not have CDATA.
This is unfortunate because it would be great to add javadoc comments that include XML, so you don't have to hide <and>, for example:
/**<![CDATA[ This parses <complexType name=""> ]]>*/ However, javadoc could recognize the CDATA section and convert it to HTML for you. For example:
This parses <complexType name=""> Or it can use simpler syntax than CDATA. Since javadoc is extensible, maybe someone added this functionality; or maybe javadoc already buried somewhere inside ... Does anyone know?
You can use the JavaDoc @code tag: /** This parses {@code <complexType name="">} */
The @Fabian answer extension, I use both <pre> and {@code ...} . Here is an example with XML as source code:
/*Outputs data from a result set to an XML * with following structure: * <pre> * {@code * <row> * <FIELD1>gregh</FIELD1> * <FIELD2>487</FIELD2> * <!-- etc. --> * </row> * <!-- more rows--> * } * </pre> */ <pre> allows you to write code on multiple lines and maintain its structure.
Tested with Eclipse 3.6.1.
Close and reopen the {@code} tag around curly braces to get $ {dollar_sign_variables} correctly displayed in eclipse, despite error 206319 and error 206345 and without resorting to full HTML escaping:
/* * <pre> * {@code * <outer> * <inner1>Text</inner1> * <inner2>$}{ "script" }{@code </inner2> * </outer> * } * </pre> */ which displays in Eclipse Indigo SR2 (3.7.2) as
<outer> <inner1>Text</inner1> <inner2>${ "script" }</inner2> </outer> I tried quite a few solutions, none of which were very satisfactory for my needs. Usually pre + @code (or @literal) tags are executed:
<pre> {@literal <configFiles> <configFile> <type>LOGICAL_INDEX_CONFIG</type> </configFile> </configFiles>} </pre> The problem is that if you have $ {dollar_sign_variables} in your html? (and this often happens if your documentation uses xml examples that rely on maven filtering). Say you have $ {ITEM_INDEX_TO_LOGICAL}, Eclipse will look like this:
<configFiles> <configFile> ITEM_INDEX_TO_LOGICAL } Ultimately, I had no choice but to stick with the html-escaping method (you can use this to make it display correctly
It:
<configFiles> <configFile> <type>${ITEM_INDEX_TO_LOGICAL}</type> </configFile> </configFiles> It is displayed as follows:
</configFiles> <configFile> <type>${ITEM_INDEX_TO_LOGICAL}</type> </configFile> </configFiles> This, unfortunately, will lead you to a situation where you cannot understand that the βxml exampleβ is documented unless you provide Javadoc. Fortunately, an eclipse can do this for you on the fly ...