HackWeight
HackWeight

Reputation: 316

In Javascript, where do I put XML comment on a var so it shows in intellisense?

I am using intellisense successfully in my javascript code for functions, but I don't know how to get it to work for a var or if I should be designing this class differently so I can document it effectively.

(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);

Upvotes: 1

Views: 182

Answers (1)

Wet Noodles
Wet Noodles

Reputation: 805

I know this question is kind of old, but in case someone else has the same question...

I would use the <field> tag. It goes above the field it describes, unlike function documentation which goes on the inside.

    (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);

Typically, <var> tags are only used in var declarations, but they also go above the var they describe.

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

Upvotes: 1

Related Questions