admin管理员组文章数量:1026989
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 badges2 Answers
Reset to default 4At 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
}
});
}
});
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 badges2 Answers
Reset to default 4At 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
}
});
}
});
本文标签: javascriptHow to write space in default values of properties in jsdocStack Overflow
版权声明:本文标题:javascript - How to write space in default values of properties in jsdoc - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745665333a2162142.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论