我无法找到在JSDOC中记录属性默认值时打印空格的方法。例如:
/**
* @prop {string} str='String with space' - 带有空格的字符串。
*/
这将被记录为:
Name Type Default Description
str string 'String with space' - The string
有什么建议如何做正确的一个?
我无法找到在JSDOC中记录属性默认值时打印空格的方法。例如:
/**
* @prop {string} str='String with space' - 带有空格的字符串。
*/
这将被记录为:
Name Type Default Description
str string 'String with space' - The string
/**
* @prop {string} [str=String with space] - The string.
*/
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
}
});
}
});