mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
support the public tag for Closure Compiler (#605)
This commit is contained in:
parent
a9a68f3442
commit
b13bb67fbb
@ -953,6 +953,16 @@ exports.closureTags = {
|
||||
}
|
||||
}
|
||||
},
|
||||
public: {
|
||||
canHaveType: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
doclet.access = 'public';
|
||||
|
||||
if (tag.value && tag.value.type) {
|
||||
setDocletTypeToValueType(doclet, tag);
|
||||
}
|
||||
}
|
||||
},
|
||||
return: cloneTagDef(baseTags.returns),
|
||||
// Closure Compiler only
|
||||
struct: {
|
||||
|
||||
7
test/fixtures/publictag.js
vendored
Normal file
7
test/fixtures/publictag.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Public class.
|
||||
*
|
||||
* @class
|
||||
* @public
|
||||
*/
|
||||
function Foo() {}
|
||||
6
test/fixtures/publictag2.js
vendored
Normal file
6
test/fixtures/publictag2.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Public variable.
|
||||
*
|
||||
* @public {string}
|
||||
*/
|
||||
var bar = 'baz';
|
||||
42
test/specs/tags/publictag.js
Normal file
42
test/specs/tags/publictag.js
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
describe('@public tag', function() {
|
||||
afterEach(function() {
|
||||
jasmine.restoreTagDictionary();
|
||||
});
|
||||
|
||||
describe('JSDoc tags', function() {
|
||||
beforeEach(function() {
|
||||
jasmine.replaceTagDictionary('jsdoc');
|
||||
});
|
||||
|
||||
it('should set the doclet\'s `access` property to `public`', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/publictag.js');
|
||||
var foo = docSet.getByLongname('Foo')[0];
|
||||
|
||||
expect(foo.access).toBe('public');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Closure Compiler tags', function() {
|
||||
beforeEach(function() {
|
||||
jasmine.replaceTagDictionary('closure');
|
||||
});
|
||||
|
||||
it('should set the doclet\'s `access` property to `public`', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/publictag2.js');
|
||||
var bar = docSet.getByLongname('bar')[0];
|
||||
|
||||
expect(bar.access).toBe('public');
|
||||
});
|
||||
|
||||
it('should include the type if one is provided', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/publictag2.js');
|
||||
var bar = docSet.getByLongname('bar')[0];
|
||||
|
||||
expect(bar.type).toBeDefined();
|
||||
expect(bar.type.names.length).toBe(1);
|
||||
expect(bar.type.names[0]).toBe('string');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user