mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Merge pull request #167 from hegemonic/augments-fix
Allow @augments to point at an undocumented dependency. Closes #160.
This commit is contained in:
commit
4adeb03c56
@ -1,7 +1,6 @@
|
|||||||
var doop = require("jsdoc/util/doop").doop;
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
var doop = require("jsdoc/util/doop").doop,
|
||||||
|
hasOwnProp = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
exports.addInherited = function(docs) {
|
exports.addInherited = function(docs) {
|
||||||
var dependencies = mapDependencies(docs.index);
|
var dependencies = mapDependencies(docs.index);
|
||||||
@ -43,6 +42,10 @@ var doop = require("jsdoc/util/doop").doop;
|
|||||||
function getAdditions(doclets, docs) {
|
function getAdditions(doclets, docs) {
|
||||||
var additions = [];
|
var additions = [];
|
||||||
var doc, parents, members, member, parts;
|
var doc, parents, members, member, parts;
|
||||||
|
|
||||||
|
// doclets will be undefined if the inherited symbol isn't documented
|
||||||
|
doclets = doclets || [];
|
||||||
|
|
||||||
for (var i=0, ii=doclets.length; i<ii; ++i) {
|
for (var i=0, ii=doclets.length; i<ii; ++i) {
|
||||||
doc = doclets[i];
|
doc = doclets[i];
|
||||||
parents = doc.augments;
|
parents = doc.augments;
|
||||||
@ -95,10 +98,6 @@ var doop = require("jsdoc/util/doop").doop;
|
|||||||
if (!(key in this.visited)) {
|
if (!(key in this.visited)) {
|
||||||
this.visited[key] = true;
|
this.visited[key] = true;
|
||||||
|
|
||||||
if (!(key in this.dependencies)) {
|
|
||||||
require('jsdoc/util/error').handle( new Error("Missing dependency: " + key) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (var path in this.dependencies[key]) {
|
for (var path in this.dependencies[key]) {
|
||||||
if ( hasOwnProp.call(this.dependencies[key], path) ) {
|
if ( hasOwnProp.call(this.dependencies[key], path) ) {
|
||||||
this.visit(path);
|
this.visit(path);
|
||||||
|
|||||||
6
test/fixtures/augmentstag2.js
vendored
6
test/fixtures/augmentstag2.js
vendored
@ -1,6 +1,6 @@
|
|||||||
// Test for @augments tags that refer to undefined symbols
|
// Test for @augments/@extends tags that refer to undefined symbols
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends Foo
|
* @extends UndocumentedThing
|
||||||
*/
|
*/
|
||||||
function Bar() {}
|
function Qux() {}
|
||||||
|
|||||||
@ -1,31 +1,4 @@
|
|||||||
/*global describe: true, env: true, it: true */
|
/*global describe: true, env: true, it: true */
|
||||||
describe("jsdoc/augment", function() {
|
describe("jsdoc/augment", function() {
|
||||||
/*jshint evil: true */
|
// TODO
|
||||||
|
|
||||||
// TODO: more tests
|
|
||||||
|
|
||||||
var lenient = !!env.opts.lenient,
|
|
||||||
log = eval(console.log);
|
|
||||||
|
|
||||||
function augmentMissingSymbol() {
|
|
||||||
var badDocSet = jasmine.getDocSetFromFile('test/fixtures/augmentstag2.js');
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
env.opts.lenient = lenient;
|
|
||||||
console.log = log;
|
|
||||||
});
|
|
||||||
|
|
||||||
it("throws an error for missing dependencies if the lenient option is not enabled", function() {
|
|
||||||
env.opts.lenient = false;
|
|
||||||
|
|
||||||
expect(augmentMissingSymbol).toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not throw an error for missing dependencies if the lenient option is enabled", function() {
|
|
||||||
console.log = function() {};
|
|
||||||
env.opts.lenient = true;
|
|
||||||
|
|
||||||
expect(augmentMissingSymbol).not.toThrow();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
describe("@augments tag", function() {
|
/*global describe: true, expect: true, it: true, jasmine: true */
|
||||||
|
describe("@augments tag", function() {
|
||||||
|
/*jshint unused: false */
|
||||||
var docSet = jasmine.getDocSetFromFile('test/fixtures/augmentstag.js'),
|
var docSet = jasmine.getDocSetFromFile('test/fixtures/augmentstag.js'),
|
||||||
foo = docSet.getByLongname('Foo')[0],
|
foo = docSet.getByLongname('Foo')[0],
|
||||||
fooProp1 = docSet.getByLongname('Foo#prop1')[0],
|
fooProp1 = docSet.getByLongname('Foo#prop1')[0],
|
||||||
@ -11,13 +13,16 @@ describe("@augments tag", function() {
|
|||||||
barProp2 = docSet.getByLongname('Bar#prop2')[0],
|
barProp2 = docSet.getByLongname('Bar#prop2')[0],
|
||||||
barProp3 = docSet.getByLongname('Bar#prop3')[0],
|
barProp3 = docSet.getByLongname('Bar#prop3')[0],
|
||||||
barMethod1 = docSet.getByLongname('Bar#method1')[0],
|
barMethod1 = docSet.getByLongname('Bar#method1')[0],
|
||||||
barMethod2 = docSet.getByLongname('Bar#method2')[0];
|
barMethod2 = docSet.getByLongname('Bar#method2')[0],
|
||||||
bazProp1 = docSet.getByLongname('Baz#prop1')[0],
|
bazProp1 = docSet.getByLongname('Baz#prop1')[0],
|
||||||
bazProp2 = docSet.getByLongname('Baz#prop2')[0],
|
bazProp2 = docSet.getByLongname('Baz#prop2')[0],
|
||||||
bazProp3 = docSet.getByLongname('Baz#prop3')[0],
|
bazProp3 = docSet.getByLongname('Baz#prop3')[0],
|
||||||
bazMethod1 = docSet.getByLongname('Baz#method1')[0],
|
bazMethod1 = docSet.getByLongname('Baz#method1')[0],
|
||||||
bazMethod2 = docSet.getByLongname('Baz#method2')[0];
|
bazMethod2 = docSet.getByLongname('Baz#method2')[0],
|
||||||
bazMethod3 = docSet.getByLongname('Baz#method3')[0];
|
bazMethod3 = docSet.getByLongname('Baz#method3')[0],
|
||||||
|
|
||||||
|
docSet2 = jasmine.getDocSetFromFile('test/fixtures/augmentstag2.js'),
|
||||||
|
qux = docSet2.getByLongname('Qux')[0];
|
||||||
|
|
||||||
it('When a symbol has an @augments tag, the doclet has a augments property that includes that value.', function() {
|
it('When a symbol has an @augments tag, the doclet has a augments property that includes that value.', function() {
|
||||||
expect(typeof bar.augments).toEqual('object');
|
expect(typeof bar.augments).toEqual('object');
|
||||||
@ -62,4 +67,9 @@ describe("@augments tag", function() {
|
|||||||
expect(bazMethod2.memberof).toEqual("Baz");
|
expect(bazMethod2.memberof).toEqual("Baz");
|
||||||
expect(bazMethod3.memberof).toEqual("Baz");
|
expect(bazMethod3.memberof).toEqual("Baz");
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
it('When a symbol has an @augments tag, and the parent is not documented, the doclet still has an augments property', function() {
|
||||||
|
expect(typeof qux.augments).toEqual('object');
|
||||||
|
expect(qux.augments[0]).toEqual('UndocumentedThing');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user