mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Merge pull request #133 from hegemonic/parser-exception
Fix parser.js so it doesn't throw exceptions when parsing itself
This commit is contained in:
commit
1899713e33
@ -143,17 +143,11 @@ function pretreat(code) {
|
||||
// make starbangstar comments look like real jsdoc comments
|
||||
.replace(/\/\*\!\*/g, '/**')
|
||||
|
||||
// make matching comment endings easier
|
||||
.replace(/\*\//g, '»')
|
||||
|
||||
// merge adjacent doclets
|
||||
.replace(/»\/\*\*+/g, '@also')
|
||||
.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, '*/');
|
||||
.replace(/(\/\*\*[^\*\/]*?@lends\b[^\*\/]*?\*\/\s*)\{/g, '$1 ____ = {') // like return @lends {
|
||||
.replace(/(\/\*\*[^\*\/]*?@lends\b[^\*\/]*?\*\/)(\s*)return(\s*)\{/g, '$2$3 return $1 ____ = {'); // like @lends return {
|
||||
}
|
||||
|
||||
var tkn = { NAMEDFUNCTIONSTATEMENT: -1001 };
|
||||
|
||||
@ -39,6 +39,18 @@ describe("jsdoc/src/parser", function() {
|
||||
parser.on('symbolFound', spy).parse(sourceCode);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should be able to parse its own source file", function() {
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
parserSrc = "javascript:" + fs.readFileSync( path.join(__dirname,
|
||||
"rhino_modules", "jsdoc", "src", "parser.js") ),
|
||||
parse = function() {
|
||||
parser.parse(parserSrc);
|
||||
};
|
||||
|
||||
expect(parse).not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user