2

I have a class which contains this method

/**
* Uses the native RegExp object and the native string.replace to replace text
* @name _replace
* @param {String} find Text string or regex to search for
* @param {String} replace Text string or regex for replacing
* @param {String} string   String to perfom the replace on
* @returns {String} Returns the string with the text replaced
*/  
this._replace = function(find, replace, str) {
    var regex;

    if(typeof find !== undefined && replace !== undefined && typeof str === 'string') {
        regex = new RegExp(find, this._getFlags()); 
        return str.replace(regex, replace, str);            
    } else {
        return false;
    }

};

It is prefixed with _ to distinguish it from the replace method which is for the public interface. Why won't JSDoc document this method when it has a _ in front? If I remove it it documents it perfectly. Is there anything I can do to make JSDoc document this method?

1 Answer 1

4

jsdoc-toolkit assumes that methods starting with _ are private. This is indeed a common convention. You can see that the method is included by running with --private option.

To force documenting it as public, include @public tag.

BTW, you don't need to use @name, the name of a function is detected automatically on most cases.

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent, thank you. I'd given up on getting a response to this question. Unusual for Stackoverflow that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.