Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allowed HTML tags in Javadoc

The Checkstyle rule JavadocStyle does not allow the tag <u>. According to the docs, the checks were patterned after the checks made by the DocCheck doclet available from Sun. Unfortunately, I have not found DocCheck anywhere. Neither have I found any official documentation about allowed HTML tags in Javadoc. Is there any?

like image 645
Marco Eckstein Avatar asked May 10 '13 11:05

Marco Eckstein


People also ask

How do you add a tag in Javadoc?

Go to Project > Generate Javadoc.. in Eclipse (Indigo in my case). You should notice that the "Extra Javadoc options.." text box has the value you must add for the Javadoc exporter to create the HTML equivalent of your tag.

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 is the format for Javadoc?

Javadoc is a tool which comes with JDK and it is used for generating Java code documentation in HTML format from Java source code, which requires documentation in a predefined format. Following is a simple example where the lines inside /*…. */ are Java multi-line comments.


1 Answers

Javadoc permits only a subset of HTML tags, as of Java 8.

Javadoc's doclint component enforces this restriction. You can disable all doclint warnings by passing -Xdoclint:none to javadoc, though you should consider fixing your Javadoc comments because otherwise the generated HTML API documentation may look bad or may omit content. (I usually use -Xdoclint:all,-missing to get warnings about everything except missing Javadoc @ tags.)

I have not found public documentation of the tags that doclint permits, but here is a list of its allowed HTML tags, which I gleaned from Java 8's file langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java.

A B BIG BLOCKQUOTE BODY BR CAPTION CENTER CITE CODE DD DFN DIV DL DT EM FONT FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IMG LI LINK MENU META NOFRAMES NOSCRIPT OL P PRE SCRIPT SMALL SPAN STRONG SUB SUP TABLE TBODY TD TFOOT TH THEAD TITLE TR TT U UL VAR 

Update for JDK 9

JDK 9 permits a different set of tags than JDK 8 does. Here is a list of tags for both JDKs, with notes about those permitted by only one of the JDKs. Again, the data comes from the HTMLTag.java file.

A BIG       // JDK 8 only B         // JDK 8 only BLOCKQUOTE BODY BR CAPTION CENTER CITE      // JDK 8 only CODE DD DFN       // JDK 8 only DIR       // JDK 9 only DIV DL DT EM FONT FOOTER    // JDK 9 only FRAME     // JDK 8 only FRAMESET  // JDK 8 only H1 H2 H3 H4 H5 H6 HEAD HEADER     // JDK 9 only HR HTML I IFRAME     // JDK 9 only IMG INPUT      // JDK 9 only LI LINK LISTING    // JDK 9 only MAIN       // JDK 9 only MENU META NAV        // JDK 9 only NOFRAMES   // JDK 8 only NOSCRIPT OL P PRE SCRIPT SECTION     // JDK 9 only SMALL SPAN STRONG SUB SUP         // JDK 8 only TABLE TBODY TD TFOOT       // JDK 8 only TH THEAD       // JDK 8 only TITLE TR TT U           // JDK 8 only UL VAR         // JDK 8 only 
like image 155
mernst Avatar answered Sep 28 '22 00:09

mernst