Skip to content

Commit 2dac7cb

Browse files
committed
Invert singleStar option to skipSingleStar; Add --skipSingleStar flag;
1 parent bf08641 commit 2dac7cb

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

bin/dox

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ program
1616
.option('-r, --raw', 'output "raw" comments, leaving the markdown intact')
1717
.option('-a, --api', 'output markdown readme documentation')
1818
.option('-s, --skipPrefixes [prefixes]', 'skip comments prefixed with these prefixes, separated by commas')
19-
.option('-d, --debug', 'output parsed comments for debugging');
19+
.option('-d, --debug', 'output parsed comments for debugging')
20+
.option('-S, --skipSingleStar', 'set to false to ignore `/* ... */` comments');
2021

2122
// examples
2223

@@ -41,7 +42,7 @@ var buf = '';
4142
process.stdin.setEncoding('utf8');
4243
process.stdin.on('data', function(chunk){ buf += chunk; });
4344
process.stdin.on('end', function(){
44-
var obj = dox.parseComments(buf, { raw: program.raw || program.api, skipPrefixes: program.skipPrefix && program.skipPrefix.split(',') });
45+
var obj = dox.parseComments(buf, { raw: program.raw || program.api, skipPrefixes: program.skipPrefix && program.skipPrefix.split(','), skipSingleStar: !!program.skipSingleStar });
4546
if (program.debug) {
4647
process.stdout.write(util.inspect(obj, false, Infinity, true) + '\n');
4748
} else if (program.api) {

lib/dox.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ exports.parseComments = function(js, options){
5454

5555
var comments = []
5656
, raw = options.raw
57-
, singleStar = options.singleStar === undefined
58-
? true
59-
: options.singleStar
57+
, skipSingleStar = options.skipSingleStar
6058
, comment
6159
, buf = ''
6260
, ignore
@@ -73,7 +71,7 @@ exports.parseComments = function(js, options){
7371
for (var i = 0, len = js.length; i < len; ++i) {
7472
// start comment
7573
if (!withinMultiline && !withinSingle && !withinString &&
76-
'/' == js[i] && '*' == js[i+1] && (singleStar || js[i+2] == '*')) {
74+
'/' == js[i] && '*' == js[i+1] && (!skipSingleStar || js[i+2] == '*')) {
7775
lineNumStarting = lineNum;
7876
// code following previous comment
7977
if (buf.trim().length) {

test/dox.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,9 @@ module.exports = {
623623
});
624624
},
625625

626-
'test .parseComments() on single star comments with singleStar=false': function (done) {
626+
'test .parseComments() on single star comments with skipSingleStar=true': function (done) {
627627
fixture('single.js', function(err, str){
628-
var comments = dox.parseComments(str, { singleStar: false });
628+
var comments = dox.parseComments(str, { skipSingleStar: true });
629629

630630
comments.should.have.lengthOf(1);
631631
comments[0].tags.should.be.empty;

0 commit comments

Comments
 (0)