是否可以嵌套javadoc?

问题描述 投票:0回答:0

我想嵌套 javadoc 以演示一些代码功能。然而,内部 javadoc 注释块的末尾也结束了外部注释块。

示例用例

/**
 * Sample is a utility for doing interesting stuff.
 * For example, you might use it this way:
 * 
 * <pre>{@code
 * /**
 *  * We write an Example class
 *  */
 * class Example {
 *     /**
 *      * This function does something.
 *      */
 *     void foo() {
 *         // ...
 *     }
 * 
 *     /**
 *      * This one does something else
 *      */
 *     void bar() {
 *         // ...
 *     }
 * 
 *     /**
 *      * now I'm gonna demonstrate something by calling foo() and bar() in this main method
 *      */
 *     public static void main(String[] args) {
 *         // ...
 *         foo();
 *         // ...
 *         bar();
 *         // ...
 *         // and now the kicker:
 *         Sample.baz();
 *         // everyone stands up and claps
 *         // ...
 *     }
 * }
 * }</pre>
 */
public class Sample {
    /**
     * Really cool thing that Sample does
     */
    static void baz() {
        // ...
    }
}

低于标准的解决方案

所以我可以尝试转义有问题的结束标记,但这在 javadoc 中显示得非常丑陋。

/**
 * outer doc
 * <pre>{@code
 * /**
 *  * inner doc
 *  *\/
 * }
 * </pre>
 */
public class Sample {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

产量

outer doc

 /**
  * inner doc
  *\/
java comments javadoc multiline
© www.soinside.com 2019 - 2024. All rights reserved.