mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
for Closure, allow the type tag to have a description (#732)
This commit is contained in:
parent
180454c3a8
commit
17fb5be064
@ -796,7 +796,11 @@ var closureTags = exports.closureTags = {
|
||||
return: cloneTagDef(baseTags.returns),
|
||||
'this': cloneTagDef(baseTags['this']),
|
||||
throws: cloneTagDef(baseTags.throws),
|
||||
type: cloneTagDef(baseTags.type),
|
||||
type: (function() {
|
||||
var tagDef = cloneTagDef(baseTags.type);
|
||||
tagDef.mustNotHaveDescription = false;
|
||||
return tagDef;
|
||||
})(),
|
||||
typedef: cloneTagDef(baseTags.typedef)
|
||||
};
|
||||
|
||||
|
||||
4
test/fixtures/typetag2.js
vendored
Normal file
4
test/fixtures/typetag2.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @type {(string|number)} A string or a number.
|
||||
*/
|
||||
var stringOrNumber;
|
||||
@ -1,4 +1,14 @@
|
||||
/*global describe, expect, it, jasmine */
|
||||
/*global afterEach, describe, expect, it, jasmine, spyOn */
|
||||
'use strict';
|
||||
|
||||
var definitions = require('jsdoc/tag/dictionary/definitions');
|
||||
var dictionary = require('jsdoc/tag/dictionary');
|
||||
var Dictionary = dictionary.Dictionary;
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
|
||||
var originalDictionary = dictionary;
|
||||
|
||||
describe('@type tag', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/typetag.js');
|
||||
|
||||
@ -21,4 +31,47 @@ describe('@type tag', function() {
|
||||
|
||||
expect(baz.nullable).toBe(false);
|
||||
});
|
||||
|
||||
describe('JSDoc tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
});
|
||||
|
||||
it('When JSDoc tags are enabled, the @type tag does not accept a description.', function() {
|
||||
var dict = new Dictionary();
|
||||
var typeDocs;
|
||||
|
||||
definitions.defineTags(dict, definitions.jsdocTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
typeDocs = jasmine.getDocSetFromFile('test/fixtures/typetag2.js');
|
||||
|
||||
expect(logger.warn).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Closure tags', function() {
|
||||
afterEach(function() {
|
||||
doclet._replaceDictionary(originalDictionary);
|
||||
});
|
||||
|
||||
it('When Closure tags are enabled, the @type tag accepts a description.', function() {
|
||||
var dict = new Dictionary();
|
||||
var stringOrNumber;
|
||||
var typeDocs;
|
||||
|
||||
definitions.defineTags(dict, definitions.closureTags);
|
||||
doclet._replaceDictionary(dict);
|
||||
spyOn(logger, 'warn');
|
||||
|
||||
typeDocs = jasmine.getDocSetFromFile('test/fixtures/typetag2.js');
|
||||
stringOrNumber = typeDocs.getByLongname('stringOrNumber')[0];
|
||||
|
||||
expect(logger.warn).not.toHaveBeenCalled();
|
||||
|
||||
expect(stringOrNumber).toBeDefined();
|
||||
expect(stringOrNumber.description).toBe('A string or a number.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user