views:

221

answers:

1

I like to put my email address within @author tags and would like them to be clickable mailto: links in the generated 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 { }
+5  A: 

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

/**
 * 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. :-)

Andrzej Doyle
I personally would use `@author My full name <my_email@address>`. Although that probably needs escaping to avoid the e-mail part being thought of as HTML tag. I still find the close ties to HTML in Javadoc a very unfortunate decision :-(
Joey
Most of the code I write is for internal purposes, so it's useful for others to be able to easily email me. I wouldn't do this for code in the wild.
Ben S
+1 Also the Javadoc conventions recommends the use of in-line links economically. The {@link} is supposed to be used to point to the documentation for the specified package, class or member name of a referenced class, not to link to e-mails or URLs (for a URL you should use @see)
JuanZe