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 &lt;complexType name=""&gt; 

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?

+23
java html xml cdata javadoc
Nov 23 '09 at 9:33
source share
4 answers

You can use the JavaDoc @code tag: /** This parses {@code <complexType name="">} */

+41
Nov 23 '09 at 9:41
source share

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.

+30
Dec 28 '11 at 10:57
source share

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> 
+6
Sep 26
source share

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:

  &lt;configFiles&gt; &lt;configFile&gt; &lt;type&gt;${ITEM_INDEX_TO_LOGICAL}&lt;/type&gt; &lt;/configFile&gt; &lt;/configFiles&gt; 

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 ...

+3
Jun 06 2018-12-06T00:
source share