Javadoc => How to add a cool title label

本小妞迷上赌 提交于 2019-12-09 11:41:47

问题


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.

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.


回答1:


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




回答2:


How about just style it this way:

<i><b>public void doSomething({@link String}).</b></i>

Looks exactly the way you want it.




回答3:


You may want to take a look at this post. I think it is similar to what you want to do. Javadoc Linking to Another Package



来源:https://stackoverflow.com/questions/19862735/javadoc-how-to-add-a-cool-title-label

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!