如何创建自定义 javadoc 标签?
如何创建自定义 javadoc 标签,例如 @pre / @post?我找到了一些解释它的链接,但我没有运气。这些是一些链接:
http://www. developer.com/java/other/article.php/3085991/Javadoc-Programming.html
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html
How do I create custom javadoc tags such as @pre / @post? I found some links that explain it but I haven't had luck with them. These are some of the links:
http://www.developer.com/java/other/article.php/3085991/Javadoc-Programming.html
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
java代码
java文档选项
输出
java code
java doc option
output
不应使用 HTML 创建自定义标签,因为 javadoc 可能会更改其实现或呈现数据的方式,也许他们会开始使用 Markdown 将来,Javadoc 导出器也不会捕获丢失的信息,并且您可能有空的“标签”。
首先使用您想要的任何标签:
请注意,自定义标签的格式为
@[prefix].[tagName]
,这是因为 doclet(或另一个 Eclipse 插件)可能会释放它自己的标签使用相同的名称,您的标签只会覆盖标准标签,因此我们添加一个前缀以降低发生这种情况的可能性。来自 doclet 的评论。
现在您必须告诉 Javadoc 导出器这个自定义标记
@tt.wrapper
。转到
项目>;在 Eclipse 中生成 Javadoc..
(在我的例子中为 Indigo)。配置该对话框前两个屏幕的设置后(使用“下一步”更改屏幕),您应该看到以下屏幕:
您应该注意到“Extra Javadoc options..”文本框具有您必须添加的值
供 Javadoc 导出器创建与您的标记等效的 HTML。
在我们的例子中,选项是这样的(如果您想要多个标签,请将它们放在新行中):
现在,当您导出 Javadoc 时(我还建议保存 ANT 脚本,这样您就不必每次都通过此对话框)您的自定义标签将显示为粗体,并带有说明和下面的值。
PS 我还没有找到一种方法来添加为自定义标签添加自动完成的功能,但这在 Indigo 中似乎是不可能的,也许会在未来的版本中出现(不确定 Juno 是否有)。
Custom tags should not be created using HTML because javadoc might change it's implementation or how it presents data, maybe they'll start using Markdown in the future, also the Javadoc exporter will not catch missing information and you might have empty "tags".
First use whatever tag you want:
Notice that the custom tag has the format
@[prefix].[tagName]
, this is due to the fact that doclet (or another Eclipse plugin) might release it's own tag with the same name, and your tag would just override the standard tag, so we add a prefix to make it less likely of that happening.Comment from doclet.
Now you have to tell the Javadoc exporter about this custom tag,
@tt.wrapper
.Go to
Project > Generate Javadoc..
in Eclipse (Indigo in my case).After configuring the settings for the first two screens of this dialog (using "Next" to change screens) you should see this screen:
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.
In our case the option is this (if you want multiple tags, put them on a new line):
Now when you export your Javadoc (I also recommend saving an ANT script so you don't have to go through this dialog every time) you will have your custom tag in bold with the description, and the values underneath.
P.S. I have yet to find a way to add the ability to add auto-completion for the custom tags, but it seems impossible in Indigo, maybe it'll be in future releases (not sure if Juno has it).
如果您想要多个,请执行类似于 javadoc -tag pre -tag post -tag invariant 的操作,其中要求命令行参数。不要使用 html 的东西
If you want multiple, do something like
javadoc -tag pre -tag post -tag invariant
where it asks for command line arguments. Don't use the html stuff好吧,我所做的不是最好的解决方案,但可读:
在找到正确的答案之前,希望它有所帮助!
Well what i did is not the best solution but is readable:
Till a proper answer is found, hope it helps!