Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Support private, public, protected
Browse files Browse the repository at this point in the history
  • Loading branch information
Constellation committed Mar 9, 2014
1 parent bb5f178 commit 4c75aa4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
16 changes: 16 additions & 0 deletions doctrine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,16 @@
return true;
};

TagParser.prototype.parseNone = function () {
var shouldBeEmpty = trim(sliceSource(source, index, this._last));
if (shouldBeEmpty) {
if (!this.addError("Unknown content '%0'", shouldBeEmpty)) {
return false;
}
}
return true;
};

TagParser.prototype.epilogue = function epilogue() {
var description;

Expand Down Expand Up @@ -1858,6 +1868,12 @@
'summary': ['parseDescription'],
// http://usejsdoc.org/tags-todo.html
'todo': ['parseDescription'],
// http://usejsdoc.org/tags-private.html
'private': ['parseNone'],
// http://usejsdoc.org/tags-protected.html
'protected': ['parseNone'],
// http://usejsdoc.org/tags-public.html
'public': ['parseNone'],
// http://usejsdoc.org/tags-variation.html
'variation': ['parseVariation']
};
Expand Down
42 changes: 42 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,48 @@ describe('parse', function () {
res.tags[0].errors.should.have.length(1);
res.tags[0].errors[0].should.equal('Invalid access name \'ng\'');
});

it('public', function () {
var res = doctrine.parse('/** @public */', { unwrap: true });
res.tags.should.have.length(1);
res.tags[0].should.have.property('title', 'public');
});

it('public error', function () {
var res = doctrine.parse('/** @public ng */', { unwrap: true, recoverable: true });
res.tags.should.have.length(1);
res.tags[0].should.have.property('errors');
res.tags[0].errors.should.have.length(1);
res.tags[0].errors[0].should.equal('Unknown content \'ng\'');
});

it('protected', function () {
var res = doctrine.parse('/** @protected */', { unwrap: true });
res.tags.should.have.length(1);
res.tags[0].should.have.property('title', 'protected');
});

it('protected error', function () {
var res = doctrine.parse('/** @protected ng */', { unwrap: true, recoverable: true });
res.tags.should.have.length(1);
res.tags[0].should.have.property('errors');
res.tags[0].errors.should.have.length(1);
res.tags[0].errors[0].should.equal('Unknown content \'ng\'');
});

it('private', function () {
var res = doctrine.parse('/** @private */', { unwrap: true });
res.tags.should.have.length(1);
res.tags[0].should.have.property('title', 'private');
});

it('private error', function () {
var res = doctrine.parse('/** @private ng */', { unwrap: true, recoverable: true });
res.tags.should.have.length(1);
res.tags[0].should.have.property('errors');
res.tags[0].errors.should.have.length(1);
res.tags[0].errors[0].should.equal('Unknown content \'ng\'');
});
});

describe('parseType', function () {
Expand Down

0 comments on commit 4c75aa4

Please sign in to comment.