chore(doc-gen): fixup private constructor declarations

Closes #2883
This commit is contained in:
Peter Bacon Darwin 2015-07-07 22:05:31 +01:00 committed by Misko Hevery
parent 6c933a4485
commit d050ce20a9
2 changed files with 20 additions and 0 deletions

View File

@ -57,6 +57,7 @@ module.exports = function createTypeDefinitionFile(log) {
_.forEach(docs, function(doc) {
_.forEach(typeDefDocs, function(typeDefDoc) {
if(typeDefDoc.moduleDocs[doc.id]) {
// Add a copy, because we are going to modify it
typeDefDoc.moduleDocs[doc.id].doc = doc;
}
});
@ -68,6 +69,24 @@ module.exports = function createTypeDefinitionFile(log) {
log.error('createTypeDefinitionFile processor: no such module "' + alias + '" (Did you forget to add it to the modules to load?)');
doc = null;
}
_.forEach(modDoc.doc.exports, function(exportDoc) {
// Search for classes with a constructor marked as `@private`
if (exportDoc.docType === 'class' && exportDoc.constructorDoc && exportDoc.constructorDoc.private) {
// Convert this class to an interface with no constructor
exportDoc.docType = 'interface';
exportDoc.constructorDoc = null;
// Add the `declare var SomeClass extends InjectableReference` construct
modDoc.doc.exports.push({
docType: 'var',
name: exportDoc.name,
id: exportDoc.id,
heritage: ': InjectableReference'
});
}
});
});
if (doc) {
docs.push(doc);

View File

@ -23,6 +23,7 @@ declare module ng {
stack: string;
toString(): string;
}
interface InjectableReference {}
}
{% endblock %}