mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
allow interface tag to have a name in the JSDoc tag dictionary (#828)
This commit is contained in:
parent
ef75f132b8
commit
869f63113f
@ -467,9 +467,12 @@ var baseTags = exports.baseTags = {
|
||||
}
|
||||
},
|
||||
interface: {
|
||||
mustNotHaveValue: true,
|
||||
canHaveName: true,
|
||||
onTagged: function(doclet, tag) {
|
||||
doclet.addTag('kind', 'interface');
|
||||
if (tag.value) {
|
||||
setDocletNameToValueName(doclet, tag);
|
||||
}
|
||||
}
|
||||
},
|
||||
kind: {
|
||||
@ -779,7 +782,10 @@ var closureTags = exports.closureTags = {
|
||||
extends: cloneTagDef(baseTags.augments),
|
||||
final: cloneTagDef(baseTags.readonly),
|
||||
implements: cloneTagDef(baseTags.implements),
|
||||
interface: cloneTagDef(baseTags.interface),
|
||||
interface: cloneTagDef(baseTags.interface, {
|
||||
canHaveName: false,
|
||||
mustNotHaveValue: true
|
||||
}),
|
||||
lends: cloneTagDef(baseTags.lends),
|
||||
license: cloneTagDef(baseTags.license),
|
||||
param: cloneTagDef(baseTags.param),
|
||||
|
||||
5
test/fixtures/interfacetag2.js
vendored
Normal file
5
test/fixtures/interfacetag2.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Virtual doclet for an interface.
|
||||
*
|
||||
* @interface VirtualInterface
|
||||
*/
|
||||
@ -1,8 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
describe('@interface tag', function() {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/interface-implements.js');
|
||||
var definitions = require('jsdoc/tag/dictionary/definitions');
|
||||
var Dictionary = require('jsdoc/tag/dictionary').Dictionary;
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/interface-implements.js');
|
||||
var testerInterface = docSet.getByLongname('ITester')[0];
|
||||
var testerImplementation = docSet.getByLongname('MyTester')[0];
|
||||
|
||||
@ -13,4 +17,49 @@ describe('@interface tag', function() {
|
||||
it('MyTester class has its kind set to "class" (not "interface")', function() {
|
||||
expect(testerImplementation.kind).toBe('class');
|
||||
});
|
||||
|
||||
describe('virtual doclets', function() {
|
||||
var tagDict;
|
||||
|
||||
beforeEach(function() {
|
||||
spyOn(logger, 'warn');
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
tagDict = new Dictionary();
|
||||
definitions.defineTags(tagDict);
|
||||
doclet._replaceDictionary(tagDict);
|
||||
});
|
||||
|
||||
it('should support virtual doclets with the JSDoc tag dictionary', function() {
|
||||
var docSet2;
|
||||
var virtualInterface;
|
||||
|
||||
tagDict = new Dictionary();
|
||||
definitions.defineTags(tagDict, definitions.jsdocTags);
|
||||
doclet._replaceDictionary(tagDict);
|
||||
|
||||
docSet2 = jasmine.getDocSetFromFile('test/fixtures/interfacetag2.js');
|
||||
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
||||
|
||||
expect(logger.warn).not.toHaveBeenCalled();
|
||||
expect(virtualInterface).toBeDefined();
|
||||
expect(virtualInterface.longname).toBe('VirtualInterface');
|
||||
});
|
||||
|
||||
it('should not support virtual doclets with the Closure tag dictionary', function() {
|
||||
var docSet2;
|
||||
var virtualInterface;
|
||||
|
||||
tagDict = new Dictionary();
|
||||
definitions.defineTags(tagDict, definitions.closureTags);
|
||||
doclet._replaceDictionary(tagDict);
|
||||
|
||||
docSet2 = jasmine.getDocSetFromFile('test/fixtures/interfacetag2.js');
|
||||
virtualInterface = docSet2.getByLongname('VirtualInterface')[0];
|
||||
|
||||
expect(logger.warn).toHaveBeenCalled();
|
||||
expect(virtualInterface).not.toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user