有没有办法定义“javadoc 类型”? - 会员的自定义参数?

发布于 2024-08-08 08:19:18 字数 779 浏览 3 评论 0原文

我能想到的用例如下:

在一个典型的应用程序中,通常有某个类别的许多成员,例如,一个Web应用程序包含许多常量属性键、Action类、服务等。对于每个类别,要维护一致性,一致地记录它们是有用的。

考虑用于属性键的常量:

/**
 * Request scope attribute key of the {@link com.acme.domain.User} object added by the {@link LoginAction}.
 */
public static final String USER_KEY = "com.acme.web.user";

每个属性键通常应该记录其范围、存储在其下的对象类型、设置它的人以及它的用途。 “javadoc type/category”的使用方式如下:

/**
 * @AttributeKey
 * @scope request
 * @type com.acme.domain.User
 * @source com.acme.web.action.LoginAction#processLogin()
 * @for HomePage.jsp
 */
public static final String USER_KEY = ...;

当然,呈现的文档标签应该翻译成英语以进行呈现。上述方案的一个重要部分是 @AttributeKey 标签 - 这将迫使文档编写者包含所有必需的字段或面临警告消息。

我几乎肯定 Java 不存在这样的东西,但是它值得吗?还有哪些其他语言/文档系统具有这样的功能?

The use case I can think of is the following:

In a typical application, there are usually many members of a certain category, e.g., a web application contains many constants attribute keys, Action classes, services, etc. For each category, to maintain consistency, it is useful to document them consistently.

Consider the constants used for attribute keys:

/**
 * Request scope attribute key of the {@link com.acme.domain.User} object added by the {@link LoginAction}.
 */
public static final String USER_KEY = "com.acme.web.user";

Each attribute key should typically document its scope, the type of Object stored under it, who sets it, and who it's for. A 'javadoc type / category' would be used as follows:

/**
 * @AttributeKey
 * @scope request
 * @type com.acme.domain.User
 * @source com.acme.web.action.LoginAction#processLogin()
 * @for HomePage.jsp
 */
public static final String USER_KEY = ...;

Of course, the rendered documentation tags should be translated to English for rendering. An important part of the above scheme is the @AttributeKey tag - this would force documentation writers to include all the required fields or face warning messages.

I'm almost positive that such a thing does not exist for Java, but would it be worthwhile and what other languages / documentation systems have such a feature?

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

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

发布评论

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

评论(1

晌融 2024-08-15 08:19:18

我应该认为 注释 会是更好的匹配对于你正在谈论的事情(语义、约束、合同等)。

I should think that annotations would be a better match for the kind of thing you're talking about (semantics, constraints, contracts, etc.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文