diff --git a/lib/jsdoc/src/parser.js b/lib/jsdoc/src/parser.js index 64fbc455..cd4d6715 100644 --- a/lib/jsdoc/src/parser.js +++ b/lib/jsdoc/src/parser.js @@ -144,6 +144,9 @@ exports.Parser.prototype.getVisitors = function() { function pretreat(code) { return code + // comment out hashbang at the top of the file, like: #!/usr/bin/env node + .replace(/^(\#\![\S \t]+\n)/, '// $1') + // make starbangstar comments look like real jsdoc comments .replace(/\/\*\!\*/g, '/**') diff --git a/test/specs/jsdoc/src/parser.js b/test/specs/jsdoc/src/parser.js index b8b6996a..aae0cb64 100644 --- a/test/specs/jsdoc/src/parser.js +++ b/test/specs/jsdoc/src/parser.js @@ -113,6 +113,16 @@ describe("jsdoc/src/parser", function() { expect(parse).not.toThrow(); }); + + it("should comment out a POSIX hashbang at the start of the file", function() { + function parse() { + parser.parse(parserSrc); + } + + var parserSrc = 'javascript:#!/usr/bin/env node\n/** class */function Foo() {}'; + + expect(parse).not.toThrow(); + }); }); describe("results", function() {