Merge pull request #167 from hegemonic/augments-fix

Allow @augments to point at an undocumented dependency. Closes #160.
This commit is contained in:
Jeff Williams 2012-08-19 19:16:21 -07:00
commit 4adeb03c56
4 changed files with 25 additions and 43 deletions

View File

@ -1,7 +1,6 @@
var doop = require("jsdoc/util/doop").doop;
(function() {
var hasOwnProp = Object.prototype.hasOwnProperty;
var doop = require("jsdoc/util/doop").doop,
hasOwnProp = Object.prototype.hasOwnProperty;
exports.addInherited = function(docs) {
var dependencies = mapDependencies(docs.index);
@ -43,6 +42,10 @@ var doop = require("jsdoc/util/doop").doop;
function getAdditions(doclets, docs) {
var additions = [];
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) {
doc = doclets[i];
parents = doc.augments;
@ -95,10 +98,6 @@ var doop = require("jsdoc/util/doop").doop;
if (!(key in this.visited)) {
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]) {
if ( hasOwnProp.call(this.dependencies[key], path) ) {
this.visit(path);

View File

@ -1,6 +1,6 @@
// Test for @augments tags that refer to undefined symbols
// Test for @augments/@extends tags that refer to undefined symbols
/**
* @constructor
* @extends Foo
* @extends UndocumentedThing
*/
function Bar() {}
function Qux() {}

View File

@ -1,31 +1,4 @@
/*global describe: true, env: true, it: true */
describe("jsdoc/augment", function() {
/*jshint evil: true */
// 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();
});
// TODO
});

View File

@ -1,4 +1,6 @@
/*global describe: true, expect: true, it: true, jasmine: true */
describe("@augments tag", function() {
/*jshint unused: false */
var docSet = jasmine.getDocSetFromFile('test/fixtures/augmentstag.js'),
foo = docSet.getByLongname('Foo')[0],
fooProp1 = docSet.getByLongname('Foo#prop1')[0],
@ -11,13 +13,16 @@ describe("@augments tag", function() {
barProp2 = docSet.getByLongname('Bar#prop2')[0],
barProp3 = docSet.getByLongname('Bar#prop3')[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],
bazProp2 = docSet.getByLongname('Baz#prop2')[0],
bazProp3 = docSet.getByLongname('Baz#prop3')[0],
bazMethod1 = docSet.getByLongname('Baz#method1')[0],
bazMethod2 = docSet.getByLongname('Baz#method2')[0];
bazMethod3 = docSet.getByLongname('Baz#method3')[0];
bazMethod2 = docSet.getByLongname('Baz#method2')[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() {
expect(typeof bar.augments).toEqual('object');
@ -62,4 +67,9 @@ describe("@augments tag", function() {
expect(bazMethod2.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');
});
});