2013-03-13 56 views
7

我想爲使用YUIDoc的JavaScript方法編寫一些文檔。它看起來像:如何記錄一個方法的「對象」參數

/** 
    Returns an instance of className 

    @method getInstance 
    @param {string} className the of the class used to create the instance 
    @param {Object} options these are options used to create the instance 
**/ 
function getInstance(className, options) { ..... } 

現在,選擇對象可以有幾個參數,如options.idoptions.single

如何將此信息添加到這個@param的文檔?

+0

谷歌關閉編譯器將標誌着,最多爲{{ID:字符串,單:無論}}或{對象<字符串,字符串>}如果它是一個普通的字典,但我不知道這是不是通用語法或對其的擴展。看到這個頁面的底部:https://developers.google.com/closure/compiler/docs/js-for-compiler – Dave 2013-03-13 21:30:27

回答

5

從參考:http://yui.github.com/yuidoc/syntax/index.html

「如在實施例中所示,還可以巢@參數標籤這樣就可以記錄具有其自己特定的嵌套結構的對象參數」。

@param {Object} [options] Data 
    to be mixed into the event 
    facade of the `change` 
    event(s) for these attributes. 
    @param {Boolean} [options.silent] 
    If `true`, no `change` event 
    will be fired. 
5

在YUIDOC 0.3.45,這是在寫入時的當前版本中,爲了描述通過方法應首先聲明對象接收到的對象(選項,在下面的例子中),然後它是帶點符號的屬性(例如,options.url)。

/** 
* Describe your method 
* 
* @method yourMethodName 
* @param {object} options - These are the options you may pass 
* @param {string} options.url - the url 
* @param {string} options.otherOption - description of other option 
*/ 
+0

有沒有一種方法來表示這樣的必要屬性?在參數下面添加'@ required'不起作用。 – JDillon522 2016-01-12 19:11:28

相關問題