【问题标题】:In Javascript, where do I put XML comment on a var so it shows in intellisense?在 Javascript 中,我在哪里将 XML 注释放在 var 上以便它以智能感知显示?
【发布时间】:2012-06-16 21:47:28
【问题描述】:

我在我的 javascript 代码中成功地使用了智能感知功能,但我不知道如何让它为 var 工作,或者我是否应该以不同的方式设计这个类,以便我可以有效地记录它。

(function ($)
{
  $.myNamespace.MyClass = {

    m_varIWantToCommentOn: null,
    /// <summary locid="m_varIWantToCommentOn">
    ///     *This doesn't work here*  How should I comment on what this var is for?
    /// </summary>

    Init: function ()
    {
        /// <summary locid="Init">
        /// Called when MyClass is initialized for the first time.  this comment works fine.
        /// </summary>
        // ...use m_varIWantToCommentOn in some way...
    }
  }
})(jQuery);

【问题讨论】:

    标签: javascript-intellisense


    【解决方案1】:

    我知道这个问题有点老了,但万一其他人也有同样的问题......

    我会使用&lt;field&gt; 标签。它超出了它所描述的字段,与内部的函数文档不同。

        (function ($) {
        $.myNamespace.MyClass = {
    
            /// <field> comments here </field>
            m_varIWantToCommentOn: null,
    
            Init: function () {
                /// <summary locid="Init">
                /// Called when MyClass is initialized for the first time.  this comment works fine.
                /// </summary>
                // ...use m_varIWantToCommentOn in some way...
    
    
            }
        }
    })(jQuery);
    

    通常,&lt;var&gt; 标记仅用于 var 声明,但它们也高于它们所描述的 var。

    /// <var>comments here</var>
    var someVar = null,
    /// <var>This is a number</var>
    anotherVar = 0;
    

    【讨论】:

      猜你喜欢
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      • 2011-11-16
      • 2012-01-28
      • 2023-03-25
      • 2017-05-25
      • 2011-01-28
      • 2010-11-18
      相关资源
      最近更新 更多