2012-08-03 97 views
0

这是很常见的JavaScript来有以下几点:评论嵌套参数

function A (options, aaa, bbb) { 
    var ccc = options.ccc; 
    var ddd = options.ddd; 
} 

而且我目前正在评论它是这样:

/** 
* a completely useless function 
* 
* @param {Object} options where options.ccc is {Number} ccc and options.ddd is {String} ddd 
* @param {Boolean} aaa 
* @param {String} bbb 
*/ 

我不满意我描述的方式属性在选项参数

有没有一种干净的方式把它们放在“{Type} description”模式中?

回答

0

我通常在变量的名称之后放置一个TAB或两个TAB ...在描述之前。虽然我同意......我也不是一个巨大的粉丝。但是,这是jsdocs如何处理它的。如果你太过于格式化,你可能无法获得正确的文档解析。

/** 
* SLP.Modules.Codes extends the SLP.Modules object on DOM-ready. 
* @module Codes 
*/ 
SLP.Modules.Codes = { 
    /** 
    * First validate for empty fields, then check the campaign codes, 
    * making sure that they begin with T(oyota), L(exus), or S(cion). 
    * @param {object} event jQuery Event object (form submit) 
    * @return {boolean}  true if all validation passes. 
    */ 
    validateCampaignCodes: function(event){ 
     var $input, isValid = SLP.validateFormInputsNotEmpty(event); 
     if (isValid) {// Continue validation if all fields are non-empty. 
      $input = $("input").filter("[name=campaign_code]").each(function(){ 
       if (!(isValid = /^[TLS]/i.test(this.value))) { 
        return !SLP.DOM.$modalPrompt.find(".modal-body").html(// Error msg. 
         "Campaign Codes must begin with T(oyota), S(cion), or L(exus)." 
        ).end().modal("show");// On error, immediately exit (the each method). 
       } 
      }); 
     } 
     // Convert campaign codes to uppercase for submission. 
     $input.val(function(i,v){ return v.toUpperCase(); }); 
     // Enable all checkboxes to submit values with form. 
     $("input[type=checkbox]").attr("disabled", false); 
     return isValid; 
    }, 
+0

小心张贴一个或两个例子你如何做? – Max 2012-08-03 00:19:46