docblockr icon indicating copy to clipboard operation
docblockr copied to clipboard

How to handle functions beginning with an underscore which are private

Open ranveer5289 opened this issue 8 years ago • 4 comments

In my code we use a code convention that functions beginning with underscore are treated as private functions.

/**
 * Custom function name
 *
 * @param {String} test Test String
 * @private
 */
function _customFunctionName( test )
{
}

Currently, I have to manually insert the @private tag at the end of the JSDOC.

I was reading through the ReadMe file of sublime pkg https://github.com/spadgos/sublime-jsdocs#variable-documentation on which docblockr is based upon.

I came across jsdocs_notation_map setting in which we give a map to add arbitary tags. I checked docblockr settings and we also have a similar setting but I have no clue on how to use it.

As per documentation, of notation_map (Array)

An array of notation objects. Each notation object must define either a prefix OR a regex property, and a type property.

I tried giving the following input

[{"prefix": "_","type": "private"}]

But this doesn't work at all.

So, is something similar supported by dockblockr or am using jsdocs_notation_map setting in the wrong way.

ranveer5289 avatar Jan 01 '17 18:01 ranveer5289

There is some code that evaluates this setting.. (get_matching_notations(name)), but to be honest I have not the slightest clue how this code works. But it definitely looks buggy. @nikhilkalige Do you still know how this is supposed to work?

MoritzKn avatar Jan 08 '17 12:01 MoritzKn

@MoritzKn Defnitely not.. :(

nikhilkalige avatar Jan 12 '17 20:01 nikhilkalige

I was just trying to figure this out as well. The documentation doesn't specify being able to supply with "tags" like the Sublime package does to add the @private tag to a prefix.

LeonBlade avatar Jan 27 '17 21:01 LeonBlade

+1 except we use the convention of having an underscore at the end on the variable:

class MyClass {
  /**
   * @param {?Test} test Nullable Test object
   * @private
   */
  myFunc_(test) {
    ..
  }
}

DustinJSilk avatar Dec 12 '17 15:12 DustinJSilk