$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>javascript - How to write space in default values of properties in jsdoc - Stack Overflow|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How to write space in default values of properties in jsdoc - Stack Overflow

matteradmin11PV0评论

I can't find a way to print space when documenting properties default values in JSDOC. Example: /** * @prop {string} str='String with space' - The string. */

This will be documented as:

Name    Type      Default       Description
str     string    'String       with space' - The string

Any suggestion how to do the proper one?

I can't find a way to print space when documenting properties default values in JSDOC. Example: /** * @prop {string} str='String with space' - The string. */

This will be documented as:

Name    Type      Default       Description
str     string    'String       with space' - The string

Any suggestion how to do the proper one?

Share Improve this question asked Feb 11, 2016 at 8:32 Ardit MetiArdit Meti 5815 silver badges22 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

At least since jsdoc 3.3.0 you can do it this way.

/**
 * @prop {string} [str=String with space] - The string.
 */

I don't quite have the solution, but today I was facing the same issue and found a work-around. :) The problem is that the current jsdoc parser (and regex) only handles this correctly if we use the optional brackets. And on this case, we want a default not being optional.

Inside publish.js of your template add this. I use the " - " as separator, so make this work, use " - " on your descriptions and this will post-process the parser correctly.

data().each(function(doclet) {
    if (doclet.properties) {
        doclet.properties = doclet.properties.map(function(property) {
            var separator = " - ",
                separatorLength = separator.length;

            var defaultvalue = property.defaultvalue;
            var description = property.description;

            if( property.defaultvalue !== 'undefined' && !property.optional && description.indexOf(separator) > 0) {
                var index = description.indexOf(separator);
                defaultvalue += " " + description.substr(separatorLength, index-separatorLength);
                description = "<p>" + description.substr(index + separatorLength, description.length);
            }

            return {
                defaultvalue: defaultvalue,
                description: description,
                type: property.type,
                name: property.name
            }  
        });                  
    }
});
Post a comment

comment list (0)

  1. No comments so far