Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javadoc => How to add a cool title label

Tags:

java

javadoc

I tried adding this type of title part on my javadocs, I failed to do it in a simple and useful way. The only way I could do it was with HTML and I don't think HTML should have a place in the code.

enter image description here

This is an example of a javadoc I made. I want my javadoc to look exactly like the androids, so I want the add the title part marked with a red square, without going in to HTML.

enter image description here

like image 237
Esqarrouth Avatar asked Nov 08 '13 15:11

Esqarrouth


1 Answers

If you want your generated documentation to contain links to classes like java.lang.String you have to tell javadoc where to link. E.g. on the command line you can say

-link http://docs.oracle.com/javase/7/docs/api/

This is not done automatically as you have to decide against which version to link or whether you want to link against a local mirror. There can be multiple -link on the command line to link against multiple library documentations.

Additional per method headers are not supported by the standard doclet. But you can add custom tags below the documentation text. For example, you could define your own tag like @API.level.1 and add it to documentation comments below the text (in a single line) and run javadoc with

-tag "API.level.1:a:Added in <a href='http://mycompany/Version1'>API Level 1</a>"

to create a line similar to your example (though it will be below the text).


There are no options for text formatting without using HTML besides {@code …} and {@literal …}. If you want more options you have to write Taglets for the particular option. This is the easiest way to achieve the separation between sourcecode and HTML code you seem to intent. So you can define semantic @tags and implement a particular formatting via the Taglet.

Or you write an entire Doclet to have the full control over the output but I don’t think that you want this.


But you should start first by reading the JavaDoc documentation (again) as there might be some options you have missed yet which might not give the exact results you have asked for but allow improvements to your documentation that could change your priorities. (It might help to know everything which is possible before start coding things not possible yet.)

like image 164
Holger Avatar answered Sep 27 '22 16:09

Holger