2011-05-07 86 views
5

我注意到很多的腳本有這些類型的評論:奇怪的意見

/** 
* Retrieve list of themes with theme data in theme directory. 
* 
* The theme is broken, if it doesn't have a parent theme and is missing either 
* style.css and, or index.php. If the theme has a parent theme then it is 
* broken, if it is missing style.css; index.php is optional. The broken theme 
* list is saved in the {@link $wp_broken_themes} global, which is displayed on 
* the theme list in the administration panels. 
* 
* @since 1.5.0 
* @global array $wp_broken_themes Stores the broken themes. 
* @global array $wp_themes Stores the working themes. 
* 
* @return array Theme list with theme data. 
*/ 
function get_themes() { 
    global $wp_themes, $wp_broken_themes; 

    ... 

    return $wp_themes; 
} 

它看起來像某種文檔的功能,但是這是怎麼回事用@前綴的話?

像@since,@global,@return,@access,@param等...?

我知道他們是什麼意思,但他們爲什麼有@在他們面前?他們是否需要識別某種文檔應用程序?

+0

哇我從來沒有真正看過WP源代碼,'全球$ wp_broken_themes'聽起來像一些潛在的糟糕的代碼正在發生! – 2011-05-07 23:03:32

+0

他們不是「怪異」的。 @韋斯利:WP代碼是可怕的;好吧,這是PHP所以去圖。 – 2011-05-07 23:06:29

+1

@Tomalak關於PHP討厭:它不是汽車,它是驅動程序:) – 2011-05-07 23:10:18

回答

7

這是JavaDoc標準。作者很可能選擇了它,因爲大多數IDE會自動將其格式化。

http://en.wikipedia.org/wiki/Javadoc

+0

嘿謝謝!你知道這是一個免費的IDE嗎?我正在使用「we builder 2010」,它們顯示爲註釋 – Alex 2011-05-07 23:00:42

+0

NetBeans是一個神話般的免費IDE,它支持Java(ofc。),C/++,Python,PHP以及更多通過模塊! – pkluz 2011-05-07 23:04:12

+1

我是第二個NetBeans,上週剛剛嘗試過,留下了深刻的印象。我是一個記事本+ ++的癮君子,試圖戒除這種習慣,並轉向更強大的東西。 – 2011-05-07 23:05:27

3

他們需要認同某種文檔的應用程序的?

它們對像phpDocumentor這樣的自動文檔很有用,並且通常是記錄代碼的好方法。作爲wasabi has pointed out,IDE的可以選擇它們,併爲你做一些有用的東西,比如函數參數類型的建議。即使你不記錄你的代碼,這是一個很好的習慣 - 只是不覺得有必要在一些人傾向於做的事情(記錄每一件可能的事情)。

3

這是PHPDoc,這是一個適應心愛的Javadoc格式。

由於它們的強制一致性,這些文檔格式更具可讀性,並且對於IDE和自動文檔生成器(例如phpdoc)非常有用。