Added feature: @lends doc comments can now appear before the return statement, when lending a returned object literal.

This commit is contained in:
Michael Mathews 2011-10-21 00:01:34 +01:00
parent 3175288d63
commit 1abe982e2f
2 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "JSDoc", "name": "JSDoc",
"version": "3.0.0alpha", "version": "3.0.0alpha",
"revision": "1319148880850", "revision": "1319151616566",
"description": "An automatic documentation generator for javascript.", "description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ], "keywords": [ "documentation", "javascript" ],
"licenses": [ "licenses": [

View File

@ -119,12 +119,20 @@ exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
function pretreat(code) { function pretreat(code) {
return code return code
// merge adjacent doclets
.replace(/\*\/\/\*\*+/g, '@also')
// make lent objectliterals documentable by giving them a dummy name
.replace(/(\/\*\*[\s\S]*?@lends\b[\s\S]*?\*\/\s*)\{/g, '$1 ____ = {')
// make starbangstar comments look like real jsdoc comments // make starbangstar comments look like real jsdoc comments
.replace(/\/\*\!\*/g, '/**'); .replace(/\/\*\!\*/g, '/**')
// make matching comment endings easier
.replace(/\*\//g, '»')
// merge adjacent doclets
.replace(/»\/\*\*+/g, '@also')
// make lent objectliterals documentable by giving them a dummy name
.replace(/(\/\*\*[^»]*?@lends\b[^»]*?»\s*)\{/g, '$1 ____ = {') // like return @lends {
.replace(/(\/\*\*[^»]*?@lends\b[^»]*?»)(\s*)return(\s*)\{/g, '$2$3 return $1 ____ = {') // like @lends return {
// make matching comment endings harder
.replace(/»/g, '*/');
} }
/** /**