mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added feature: @lends doc comments can now appear before the return statement, when lending a returned object literal.
This commit is contained in:
parent
3175288d63
commit
1abe982e2f
@ -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": [
|
||||||
|
|||||||
@ -103,7 +103,7 @@ exports.Parser.prototype._parseSourceCode = function(sourceCode, sourceName) {
|
|||||||
currentSourceName = sourceName = e.filename;
|
currentSourceName = sourceName = e.filename;
|
||||||
|
|
||||||
sourceCode = pretreat(e.source);
|
sourceCode = pretreat(e.source);
|
||||||
|
|
||||||
var ast = parserFactory().parse(sourceCode, sourceName, 1);
|
var ast = parserFactory().parse(sourceCode, sourceName, 1);
|
||||||
ast.visit(
|
ast.visit(
|
||||||
new Packages.org.mozilla.javascript.ast.NodeVisitor({
|
new Packages.org.mozilla.javascript.ast.NodeVisitor({
|
||||||
@ -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, '*/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user