2009-10-02 112 views
21

我喜歡把我的電子郵件地址放在@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 { } 

回答

31

{@link}是特定的Javadoc的標記。但是,Javadocs是HTML--因此您可以簡單地使用

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

無論這是一個好主意還是另一回事。 :-)

+12

我個人會使用'@author我的全名'。雖然這可能需要逃避,以避免電子郵件部分被認爲是HTML標籤。我仍然發現在Javadoc中與HTML的緊密聯繫是一個非常不幸的決定:-( – Joey 2009-10-02 14:29:19

+2

我寫的大多數代碼都是爲了內部目的,所以對於其他人來說,這很有用,能夠輕鬆地給我發電子郵件,我不會爲代碼執行此操作在野外 – 2009-10-02 14:29:37

+4

+1此外,Javadoc約定建議使用經濟上的內聯鏈接。{@link}應該用於指向指定包,引用類的類或成員名稱的文檔,不要鏈接到電子郵件或URL(對於你應該使用@see的URL) – JuanZe 2009-10-02 14:32:24

相關問題