Javadoc重用预定义的文本 [英] Javadoc reuse predefined text

查看:48
本文介绍了Javadoc重用预定义的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能创建类似这样的内容:

Is it possible somehow to create something like:

/** #define COMMON_NOTE_1="This note I want to re-use in several places" */
int varA; /** variable A (COMMON_NOTE_1) */
int varB; /** variable B (COMMON_NOTE_1) */

有些建议3年前可能无法实现,您知道是否可能在现代?

Some suggested 3 years ago it may not been possible do you know if it is possible in modern age?

如果仍然不可能,则建议使用C预处理程序.知道C预处理程序是否可以与IntelliJ集成吗?或者我也对编译前自动执行的python脚本感到满意.我知道Intelli J可以配置为在编译之前运行Ant.如果有现成的解决方案,我也会接受.但是我不想自己编写/修改蚂蚁脚本.

If still not possible, there were suggestions to use C preprocessor. Any idea if C preprocessor can be integrated with IntelliJ? Or I would be happy also with python script automatically executed before compilation. I know Intelli J can be configured to run Ant before compilation. If ready made solution I would take it as well. But I do not want to write/modify ant script myself.

推荐答案

所以我确实找到了一种丑陋且受限的方法.但是,到目前为止,最好的事情还是. 比以前建议的DUMMY变量好得多. DUMMY变量的主要缺点是在您的类和文档中将存在DUMMY变量.而且,即使您在代码中吞下了凌乱的DUMMY变量,也不会直接看到"Note",而只会链接到它.

So I did find one ugly and limited way. But the best thing so far anyway. Lot better than previously proposed DUMMY variables. The major ugliness of DUMMY variables is that there would be DUMMY variables in your class and in your documentation. And even when you swallow messy DUMMY variables in your code you won't see "Note" directly but only link to it.

更好的方法是使用标签@value.首先创建像DocCommon这样的丑陋类,其中所有注释都将被隐藏.例如:

The better approach would be to use tag @value. First create ugly class like DocCommon where all notes will be hidden. eg.:

public class DocCommon {
    public static final String note1 = "Note: This is common note";
    public static final String note2 = "Note: This is common note2";
}

您可以从任何地方链接它:

The you link it from anywhere like :

/** A: {@value com.whoever.DocCommon#note1} B*/

然后它将直接在文档中显示,如下所示:

It will then shows in documentation directly like this:

A: "Note: This is common note" B

缺点是它将显示带有引号"的字符.另一个缺点是它将不接受任何HTML标记.例如.当您放置<br>时,它将在javadoc编译期间引发错误.所以这行不通:

The disadvantage is that it will show with quotation marks " ". Another disadvantage is that it won't accept any HTML tags. Eg. when you put <br> it would throw error during javadoc compiling. So this wont work:

public static final String note1 = "Note: <br> This is common note";

有人有更好的建议吗?我注意到可能还有Javadoc以外的其他文档工具.关于支持多行#define的特定提示吗?

Anyone has any better proposal? I noticed there might be other documentation tools than Javadoc. Any hint about particular one supporting multiline #defines?

这篇关于Javadoc重用预定义的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆