2016-08-01 30 views
4

對於這樣的功能...本地變量的正確JSDoc語法是什麼?

function example() { 
    var X = 100; 

    ... 

    var Y = 'abc'; 

    ... 

    return Z; 
} 

我需要解釋的一些局部變量的目的。添加像這樣的描述...

function example() { 
    /** 
    * @description - Need to explain the purpose of X here. 
    */ 
    var X = 100; 

    ... 

    /** 
    * @description - Need to explain the purpose of Y here. 
    */ 
    var Y = 'abc'; 

    ... 

    return Z; 
} 

...似乎沒有被拾起JS Doc v3.4.0

什麼是正確的語法?

P.S.我的一些用例需要多行註釋。

回答

1

似乎JS文檔忽略了「塊」(例如類,函數等)中的註釋。我試過...

@description 
@inner 
@instance 
@member 
@memberof 
@name 
@summary 

...和其他人。我無法讓他們生成任何文檔。在整個JS Doc示例中,他們使用普通的JS評論來說明這類事情。

我得出結論,這裏沒有官方的JS Doc語法。

3

我通常在我的項目中使用類似下面的代碼。

function example() { 
    /** 
    * Need to explain the purpose of X here. 
    * @type {number} 
    */ 
    var X = 100; 

    ... 

    /** 
    * Need to explain the purpose of Y here. 
    * @type {string} 
    */ 
    var Y = 'abc'; 

    ... 

    return Z; 
}