Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #167 from pfrankov/master
Browse files Browse the repository at this point in the history
feat(ngdocs): make description of @param and @returns optional
  • Loading branch information
Martin authored Jun 30, 2017
2 parents 580c525 + 699c21d commit aa1d76a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ngdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,16 @@ Doc.prototype = {
self.moduleName = match[1];
}
} else if (atName == 'param') {
match = text.match(/^\{([^}]+)\}\s+(([^\s=]+)|\[(\S+)=([^\]]+)\])\s+(.*)/);
// 1 1 23 3 4 4 5 5 2 6 6
match = text.match(/^\{([^}]+)}\s+(([^\s=]+)|\[(\S+)=([^\]]+)])(?:\s+(.*)|$)/);
// 1 1 23 3 4 4 5 5 2 6 6
if (!match) {
throw new Error("Not a valid 'param' format: " + text + ' (found in: ' + self.file + ':' + self.line + ')');
}

var optional = (match[1].slice(-1) === '=');
var param = {
name: match[4] || match[3],
description:self.markdown(text.replace(match[0], match[6])),
description: match[6] ? self.markdown(text.replace(match[0], match[6])) : '',
type: optional ? match[1].substring(0, match[1].length-1) : match[1],
optional: optional,
default: match[5]
Expand All @@ -444,13 +444,13 @@ Doc.prototype = {
self.param.push(param);
}
} else if (atName == 'returns' || atName == 'return') {
match = text.match(/^\{([^}]+)\}\s+(.*)/);
match = text.match(/^\{([^}]+)}(?:\s+(.*)|$)/);
if (!match) {
throw new Error("Not a valid 'returns' format: " + text + ' (found in: ' + self.file + ':' + self.line + ')');
}
self.returns = {
type: match[1],
description: self.markdown(text.replace(match[0], match[2]))
description: match[2] ? self.markdown(text.replace(match[0], match[2])) : ''
};
} else if(atName == 'requires') {
if (/^((({@link).+})|(\[.+\]({@link).+}))$/.test(text)) {
Expand Down Expand Up @@ -635,6 +635,7 @@ Doc.prototype = {

dom.html('</td>');
dom.html('<td>');

dom.html(param.description);
if (param.default) {
dom.html(' <p><em>(default: ' + param.default + ')</em></p>');
Expand Down

0 comments on commit aa1d76a

Please sign in to comment.