使用类似于 Javadoc 标记接口的注释

发布于 2024-10-30 19:43:19 字数 549 浏览 1 评论 0原文

我有一些概念上相关的类,并想用注释标记它们,以便我可以在 javadoc 中看到这些类的列表。

例如,MyAPI 提供一些状态变量:

/**
 * Marker for the state types exposed by MyAPI
 */
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface MyAPIState {
}

这是这些状态之一:

/**
 * Stores connection state.
 */
@MyAPIState
public class ConnectionState {
    public boolean isConnected(){...}
}

如果我对这些状态使用空标记接口(而不是注释),我将很容易看到实现类型。但是为 MyAPIState 生成的 javadoc 不会链接到用它注释的类型。

我可以让 javadoc 显示注释的 javadoc 中相关类型的链接吗?

I have some conceptually related classes and want to mark them with annotations so that I can see list of these classes in javadoc.

For example, MyAPI supplies some state variables:

/**
 * Marker for the state types exposed by MyAPI
 */
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface MyAPIState {
}

And here is one of these states:

/**
 * Stores connection state.
 */
@MyAPIState
public class ConnectionState {
    public boolean isConnected(){...}
}

Had I used an empty marker interface for these states (instead of the annotation) I would have easily seen the implementing types. But generated javadoc for MyAPIState does not link to the types which are annotated with it.

Can I make javadoc to show links to the related types in the javadoc of the annotation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丢了幸福的猪 2024-11-06 19:43:19

据我所知,如果你不想替换doclet,javadoc没有这样的功能。

除了注释之外,您还可以尝试使用自定义 javadoc 标记并将它们与自定义 taglet

这可能看起来像这样:

/**
 * Marker for the state types exposed by MyAPI.
 * @linktarget
 */
public interface MyAPIState {
}

/**
 * Stores connection state.
 * @linkfrom MyApiState
 */
public class ConnectionState {
    public boolean isConnected(){...}
}

As far as I know, there is no such feature for javadoc, if you don't want to replace the doclet.

Instead of annotations you could try to use custom javadoc tags and combine them with a custom taglet you implement for this purpose.

This could then look like this:

/**
 * Marker for the state types exposed by MyAPI.
 * @linktarget
 */
public interface MyAPIState {
}

/**
 * Stores connection state.
 * @linkfrom MyApiState
 */
public class ConnectionState {
    public boolean isConnected(){...}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文