java - 如何将 javadoc 从变量复制到构造函数

标签 java javadoc copy-paste

我在使用 Javadoc 时遇到一些问题。我已经为类的变量编写了文档。然后我想在构造函数中使用相同的 javaDoc。我似乎无法使用 @link@see 来实现此目的(嗯,Netbeans 没有显示我喜欢的结果)。

复制粘贴所有内容似乎很麻烦,那么是否有一个标签/参数可以复制 javaDoc?

示例如下:

/**
 * The id for identifying this specific detectionloop. It is assumed the
 * Detectionloops are numbered in order, so Detectionloop '2' is always next to
 * Detectionloop '1'. 
 */
private int id;

/**
 * Constructor for a detectionloop. Detectionloops are real-world sensors
 * that register and identify a kart when it passes by. Please note that
 * this class is still under heavy development and the parameters of the
 * constructor may change along the way!
 *
 * @param id The id for identifying this specific detectionloop. It is assumed
 *    the Detectionloops are numbered in order, so Detectionloop '2' is always
 *    next to Detectionloop '1'. 
 * @param nextID The id of the next detectionloop is sequense.
 * @param distanceToNext The distance in meters to the next detectionloop.
 */
DetectionLoop(int id, int nextID, int distanceToNext) {
    this.distanceToNext = distanceToNext;
    this.id = id;
    if (Detectionloops.containsKey(id)) {
        throw new IllegalArgumentException("Detectionloop " + this.id
                + " already exist, please use a unused identification!");
    } else {
        Detectionloops.put(this.id, this);
    }
}

最佳答案

不幸的是,使用 standard Javadoc 是不可能的。 。作为解决方法,您可以使用 @link 标记来引用该字段,然后人们可以单击该链接来获取其文档。这需要点击一下,但至少您不必维护冗余文档:

/**
 * ...
 * @param id the value for {@link #id}

据我所知,解决此问题的唯一其他方法是编写一个自定义 doclet,它允许您定义 your own tag为了您的目的。

关于java - 如何将 javadoc 从变量复制到构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16518226/

相关文章:

vim - -- 有没有办法复制搜索词,包括该词?

javascript - 用于复制图像的 Firefox WebExtension 替代插件剪贴板 sdk

java - 如何在 Java 中交换 arrayMap 值和键

java - 阻止用户在java扫描仪中输入数字?

java - 用于 emacs 的最佳 Java 工具

vim - 如何避免将行号从 vim 复制到剪贴板?

java - TIMEr 执行后的代码不起作用

java - 如何使用JAVA在MySQL数据库中存储马拉地语(印度语)

java - 为具有(模拟的)可选/默认参数的函数编写 Javadoc

java - 存储在 netbeans ide 中的 Maven 存储库的源代码和 javadoc jar 在哪里?