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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1509817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 16:49:43  来源:igfitidea点击:

What's the correct way to include an email within Javadoc?

javaemailjavadoc

提问by Ben S

I like to put my email address within @authortags and would like them to be clickable mailto:links in the generated Javadoc.

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

How should I go about doing this correctly?

我应该如何正确地做到这一点?

/**
 * 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 { }

回答by Andrzej Doyle

The {@link}is Javadoc-specific markup. Javadocs, though, are HTML - so you can simply use

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

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

Whether that's a good idea or not is a different matter. :-)

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