在Javadoc中包含电子邮件的正确方法是什么?
问题描述:
我喜欢把我的电子邮件地址放在@author
标签内,并希望它们在生成的Javadoc中可点击mailto:
链接。在Javadoc中包含电子邮件的正确方法是什么?
我应该如何正确地做到这一点?
/**
* I currently do the following, but would like to have my name
* displayed as the link rather than the email itself.
*
* @author {@link "mailto:[email protected]"}
*/
public class Useless { }
/**
* I've tried this, but get warnings about unexpexted text where my name is.
*
* @author {@link "mailto:[email protected]" "Benoit St-Pierre"}
*/
public class Useless { }
答
的{@link}
是特定的Javadoc的标记。但是,Javadocs是HTML--因此您可以简单地使用
/**
* Embed HTML directly into the Javadoc.
*
* @author <a href="mailto:[email protected]">Benoit St-Pierre</a>
*/
public class Useless { }
无论这是一个好主意还是另一回事。 :-)
我个人会使用'@author我的全名'。虽然这可能需要逃避,以避免电子邮件部分被认为是HTML标签。我仍然发现在Javadoc中与HTML的紧密联系是一个非常不幸的决定:-( –
Joey
2009-10-02 14:29:19
我写的大多数代码都是为了内部目的,所以对于其他人来说,这很有用,能够轻松地给我发电子邮件,我不会为代码执行此操作在野外 – 2009-10-02 14:29:37
+1此外,Javadoc约定建议使用经济上的内联链接。{@link}应该用于指向指定包,引用类的类或成员名称的文档,不要链接到电子邮件或URL(对于你应该使用@see的URL) – JuanZe 2009-10-02 14:32:24