Permalink
Browse files

fix: crash if a class extends unexported class.

  • Loading branch information...
h13i32maru committed Jun 28, 2015
1 parent 957d61a commit bf876430c49937932b2ba07602363b6927f211cc
Showing with 40 additions and 2 deletions.
  1. +40 −2 src/Publisher/Builder/DocResolver.js
@@ -19,14 +19,15 @@ export default class DocResolver {
* resolve various properties.
*/
resolve() {
this._resolveExtendsChain();
this._resolveNecessary();
this._resolveAccess();
this._resolveUnexportIdentifier();
this._resolveUndocumentIdentifier();
this._resolveDuplication();
this._resolveIgnore();
this._resolveMarkdown();
this._resolveLink();
this._resolveExtendsChain();
this._resolveTestRelation();
}
@@ -40,7 +41,8 @@ export default class DocResolver {
let docs = this._builder._find({ignore: true});
for (let doc of docs) {
var regex = new RegExp(`^${doc.longname}[.~#]`);
let longname = doc.longname.replace(/[$]/g, '\\$');
let regex = new RegExp(`^${longname}[.~#]`);
this._data({longname: {regex: regex}}).remove();
}
this._data({ignore: true}).remove();
@@ -313,6 +315,42 @@ export default class DocResolver {
this._data.__RESOLVED_EXTENDS_CHAIN__ = true;
}
/**
* resolve necessary identifier.
*
* ```javascript
* class Foo {}
*
* export default Bar extends Foo {}
* ```
*
* ``Foo`` is not exported, but ``Bar`` extends ``Foo``.
* ``Foo`` is necessary.
* So, ``Foo`` must be exported by force.
*
* @private
*/
_resolveNecessary() {
let builder = this._builder;
this._data({export: false}).update(function() {
let doc = this;
let childNames = [];
if (doc._custom_direct_subclasses) childNames.push(...doc._custom_direct_subclasses);
if (doc._custom_indirect_subclasses) childNames.push(...doc._custom_indirect_subclasses);
if (doc._custom_direct_implemented) childNames.push(...doc._custom_direct_implemented);
if (doc._custom_indirect_implemented) childNames.push(...doc._custom_indirect_implemented);
for (let childName of childNames) {
let childDoc = builder._find({longname: childName})[0];
if (!childDoc) continue;
if (!childDoc.ignore && childDoc.export) {
doc.export = true;
return doc;
}
}
});
}
/**
* resolve test and identifier relation. add special property.
* - ``_custom_tests``: longnames of test doc.

0 comments on commit bf87643

Please sign in to comment.