mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Moved inline doclet definition to external fixtures
This commit is contained in:
parent
f64ae8098b
commit
bbf6f51f77
7
test/fixtures/classdesctag.js
vendored
Normal file
7
test/fixtures/classdesctag.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Asdf.
|
||||
* @class
|
||||
* @classdesc A description of the class.
|
||||
*/
|
||||
function Foo () {
|
||||
}
|
||||
7
test/fixtures/descriptiontag.js
vendored
Normal file
7
test/fixtures/descriptiontag.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/** Blah Blah Blah
|
||||
* @desc halb halb halb
|
||||
*/
|
||||
var x;
|
||||
|
||||
/** @description lkjasdf */
|
||||
var y;
|
||||
14
test/fixtures/exampletag.js
vendored
Normal file
14
test/fixtures/exampletag.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/** @example
|
||||
* console.log("foo");
|
||||
* console.log("bar");
|
||||
*/
|
||||
var x;
|
||||
|
||||
/** @example
|
||||
* console.log("foo");
|
||||
* console.log("bar");
|
||||
* @example
|
||||
* <caption>Example 2</caption>
|
||||
* 1 + 2;
|
||||
*/
|
||||
var y;
|
||||
7
test/fixtures/functiontag.js
vendored
Normal file
7
test/fixtures/functiontag.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/** @func Foo */
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
/** @method */
|
||||
function Bar() {
|
||||
}
|
||||
2
test/fixtures/kindtag.js
vendored
Normal file
2
test/fixtures/kindtag.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/** @kind function */
|
||||
var x;
|
||||
2
test/fixtures/licensetag.js
vendored
Normal file
2
test/fixtures/licensetag.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/** @license GPL v2 */
|
||||
var x;
|
||||
5
test/fixtures/membertag.js
vendored
Normal file
5
test/fixtures/membertag.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/** @member */
|
||||
var x;
|
||||
|
||||
/** @var foobar */
|
||||
/** @var {string} baz */
|
||||
5
test/fixtures/namespacetag.js
vendored
Normal file
5
test/fixtures/namespacetag.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/** @namespace */
|
||||
var x = {
|
||||
};
|
||||
/** @namespace Foo */
|
||||
/** @namespace {function} Bar */
|
||||
10
test/fixtures/scopetags.js
vendored
Normal file
10
test/fixtures/scopetags.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/** (scope tags for global objects do not override globalness hence need a container class)
|
||||
* @module scopetags */
|
||||
/** @inner */
|
||||
var myInner;
|
||||
|
||||
/** @instance */
|
||||
var myInstance;
|
||||
|
||||
/** @static */
|
||||
var myStatic;
|
||||
3
test/fixtures/summarytag.js
vendored
Normal file
3
test/fixtures/summarytag.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/** @summary I do not like green eggs and ham! */
|
||||
function Sam() {
|
||||
}
|
||||
6
test/fixtures/todotag.js
vendored
Normal file
6
test/fixtures/todotag.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/** A function.
|
||||
* @todo something
|
||||
* @todo something else
|
||||
*/
|
||||
function x() {
|
||||
}
|
||||
5
test/fixtures/tutorialtag.js
vendored
Normal file
5
test/fixtures/tutorialtag.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/** Some documentation.
|
||||
* @tutorial tute1
|
||||
* @tutorial tute2
|
||||
*/
|
||||
var x;
|
||||
3
test/fixtures/undocumentedtag.js
vendored
Normal file
3
test/fixtures/undocumentedtag.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/** Undocumented doclet.
|
||||
* @undocumented */
|
||||
var x;
|
||||
@ -1,10 +1,11 @@
|
||||
describe("@alias tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @name Foo\n@alias Bar */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/alias.js'),
|
||||
// there are two doclets with longname myObject, we want the second one
|
||||
myObject = docSet.getByLongname('myObject')[1];
|
||||
|
||||
it("adds an 'alias' property to the doclet with the tag's value", function() {
|
||||
expect(doc.alias).toBeDefined();
|
||||
expect(doc.alias).toBe('Bar');
|
||||
expect(myObject.alias).toBeDefined();
|
||||
expect(myObject.alias).toBe('myObject');
|
||||
});
|
||||
// further tests (ensuring alias has the proper effect): documentation/alias.js
|
||||
});
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
describe("@classdesc tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** Asdf. @class Foo\n@classdesc A description of the class. */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/classdesctag.js'),
|
||||
doc = docSet.getByLongname('Foo')[0];
|
||||
|
||||
it('adds a classdesc property to the doclet with the description', function() {
|
||||
expect(doc.classdesc).toBe('A description of the class.');
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
describe("@description tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** Blah Blah Blah\n @desc halb halb halb */', {}),
|
||||
doc2 = new doclet.Doclet('/** @description lkjasdf */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/descriptiontag.js'),
|
||||
doc = docSet.getByLongname('x')[0],
|
||||
doc2 = docSet.getByLongname('y')[0];
|
||||
|
||||
it("sets the doclet's 'description' property to the description", function() {
|
||||
expect(doc2.description).toBeDefined();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
describe("@example tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/exampletag.js'),
|
||||
doc = docSet.getByLongname('x')[0],
|
||||
doc2 = docSet.getByLongname('y')[0],
|
||||
txt = 'console.log("foo");\nconsole.log("bar");',
|
||||
txt2 = '1 + 2;',
|
||||
doc = new doclet.Doclet('/** @example\n' + txt + '*/', {}),
|
||||
doc2 = new doclet.Doclet('/** @example\n' + txt + '\n@example\n' + txt2 + '*/', {});
|
||||
txt2 = '<caption>Example 2</caption>\n1 + 2;';
|
||||
|
||||
it("creates an 'examples' property on the doclet with the example", function() {
|
||||
expect(doc.examples).toBeDefined();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
describe("@function tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @func Foo */', {}),
|
||||
doc2 = new doclet.Doclet('/** @method */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/functiontag.js'),
|
||||
doc = docSet.getByLongname('Foo')[0],
|
||||
doc2 = docSet.getByLongname('Bar')[0];
|
||||
|
||||
it("sets the doclet's kind to 'function'", function() {
|
||||
expect(doc.kind).toBe('function');
|
||||
@ -10,7 +10,7 @@ describe("@function tag", function() {
|
||||
|
||||
it("sets the doclet's name to the tag value, if provided", function() {
|
||||
expect(doc.name).toBe('Foo');
|
||||
expect(doc2.name).toBeFalsy();
|
||||
expect(doc2.name).toBe('Bar');
|
||||
});
|
||||
|
||||
// parameter etc tests take place elsewhere: on its own, all @func does is
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe("@kind tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @kind function */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/kindtag.js'),
|
||||
doc = docSet.getByLongname('x')[0];
|
||||
it("sets the doclet's 'kind' property to the tag value", function() {
|
||||
expect(doc.kind).toBeDefined();
|
||||
expect(doc.kind).toBe('function');
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe("@license tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @license GPL v2 */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/licensetag.js'),
|
||||
doc = docSet.getByLongname('x')[0];
|
||||
|
||||
it("sets the doclet's 'license' property to the tag value", function() {
|
||||
expect(doc.license).toBe('GPL v2');
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
describe("@member tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @member */', {}),
|
||||
doc2 = new doclet.Doclet('/** @var foobar */', {}),
|
||||
doc3 = new doclet.Doclet('/** @var {string} baz */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/membertag.js'),
|
||||
doc = docSet.getByLongname('x')[0],
|
||||
doc2 = docSet.getByLongname('foobar')[0],
|
||||
doc3 = docSet.getByLongname('baz')[0];
|
||||
|
||||
it("sets the doclet's 'kind' property to 'member'", function() {
|
||||
expect(doc.kind).toBe('member');
|
||||
@ -11,7 +11,7 @@ describe("@member tag", function() {
|
||||
});
|
||||
|
||||
it("If specified with a name, sets the doclet's name property", function() {
|
||||
expect(doc.name).toBeFalsy();
|
||||
expect(doc.name).toBe('x');
|
||||
expect(doc2.name).toBe('foobar');
|
||||
expect(doc3.name).toBe('baz');
|
||||
});
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
describe("@namespace tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @namespace */', {}),
|
||||
doc2 = new doclet.Doclet('/** @namespace Foo */', {}),
|
||||
doc3 = new doclet.Doclet('/** @namespace {function} Bar */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/namespacetag.js'),
|
||||
doc = docSet.getByLongname('x')[0],
|
||||
doc2 = docSet.getByLongname('Foo')[0],
|
||||
doc3 = docSet.getByLongname('Bar')[0];
|
||||
|
||||
it("sets the doclet's kind to 'namespace'", function () {
|
||||
expect(doc.kind).toBe('namespace');
|
||||
@ -11,7 +11,7 @@ describe("@namespace tag", function() {
|
||||
});
|
||||
|
||||
it("sets the doclet's name to the tag value (if provided)", function() {
|
||||
expect(doc.name).toBeFalsy();
|
||||
expect(doc.name).toBe('x');
|
||||
expect(doc2.name).toBe('Foo');
|
||||
expect(doc3.name).toBe('Bar');
|
||||
});
|
||||
|
||||
@ -1,30 +1,31 @@
|
||||
// @inner, @instance, @static (@global has its own file)
|
||||
describe("@inner tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @name Foo\n@scope inner */', {});
|
||||
describe('scope tags', function () {
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/scopetags.js');
|
||||
|
||||
it("sets the doclet's 'scope' property to 'inner'", function() {
|
||||
expect(doc.scope).toBeDefined();
|
||||
expect(doc.scope).toBe('inner');
|
||||
});
|
||||
});
|
||||
|
||||
describe("@instance tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @name Foo\n@scope instance */', {});
|
||||
|
||||
it("sets the doclet's 'scope' property to 'instance'", function() {
|
||||
expect(doc.scope).toBeDefined();
|
||||
expect(doc.scope).toBe('instance');
|
||||
});
|
||||
});
|
||||
|
||||
describe("@static tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @name Foo\n@scope static */', {});
|
||||
|
||||
it("sets the doclet's 'scope' property to 'static'", function() {
|
||||
expect(doc.scope).toBeDefined();
|
||||
expect(doc.scope).toBe('static');
|
||||
// @inner, @instance, @static (@global has its own file)
|
||||
describe("@inner tag", function() {
|
||||
var doc = docSet.getByLongname('module:scopetags~myInner')[0];
|
||||
|
||||
it("sets the doclet's 'scope' property to 'inner'", function() {
|
||||
expect(doc.scope).toBeDefined();
|
||||
expect(doc.scope).toBe('inner');
|
||||
});
|
||||
});
|
||||
|
||||
describe("@instance tag", function() {
|
||||
var doc = docSet.getByLongname('module:scopetags#myInstance')[0];
|
||||
|
||||
it("sets the doclet's 'scope' property to 'instance'", function() {
|
||||
expect(doc.scope).toBeDefined();
|
||||
expect(doc.scope).toBe('instance');
|
||||
});
|
||||
});
|
||||
|
||||
describe("@static tag", function() {
|
||||
var doc = docSet.getByLongname('module:scopetags.myStatic')[0];
|
||||
|
||||
it("sets the doclet's 'scope' property to 'static'", function() {
|
||||
expect(doc.scope).toBeDefined();
|
||||
expect(doc.scope).toBe('static');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe("@summary tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @summary I do not like green eggs and ham! */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/summarytag.js'),
|
||||
doc = docSet.getByLongname('Sam')[0];
|
||||
it("sets the doclet's 'summary' property to the tag value", function() {
|
||||
expect(doc.summary).toBe('I do not like green eggs and ham!');
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe("@todo tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @todo something\n@todo something else */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/todotag.js'),
|
||||
doc = docSet.getByLongname('x')[0];
|
||||
|
||||
it("adds the entries into a 'todo' array on the doclet", function() {
|
||||
expect(doc.todo).toBeDefined();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
describe("@tutorial tag", function() {
|
||||
// these are tests for the block usage, not the inline usage. see util/templateHelper for that.
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** @tutorial tute1\n@tutorial tute2 */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/tutorialtag.js'),
|
||||
doc = docSet.getByLongname('x')[0];
|
||||
|
||||
it("adds the listed tutorials to a 'tutorials' array on the doclet", function () {
|
||||
expect(Array.isArray(doc.tutorials)).toBeTruthy();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
describe("@undocumented tag", function() {
|
||||
var doclet = require('jsdoc/doclet'),
|
||||
doc = new doclet.Doclet('/** Foo bar\n@undocumented */', {});
|
||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/undocumentedtag.js'),
|
||||
doc = docSet.getByLongname('x')[0];
|
||||
|
||||
it("sets the doclet's 'undocumented' property to true", function () {
|
||||
expect(doc.undocumented).toBeTruthy();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user