在 Javadoc 中包含电子邮件的正确方法是什么?

2022-09-01 11:57:08

我喜欢将我的电子邮件地址放在标签中,并希望它们是生成的Javadoc中的可点击链接。@authormailto:

我应该如何正确地执行此操作?

/**
 * I currently do the following, but would like to have my name 
 * displayed as the link rather than the email itself.
 *
 * @author {@link "mailto:my_email@email.example.com"}
 */
public class Useless { }

/**
 * I've tried this, but get warnings about unexpexted text where my name is.
 *
 * @author {@link "mailto:my_email@email.example.com" "Benoit St-Pierre"}
 */
public class Useless { }

答案 1

是特定于 Javadoc 的标记。但是,Javadocs是HTML - 所以你可以简单地使用{@link}

/**
 * Embed HTML directly into the Javadoc.
 *
 * @author <a href="mailto:my_email@email.exmaple.com">Benoit St-Pierre</a>
 */
public class Useless { }

这是否是一个好主意是另一回事。:-)


答案 2

推荐