From d050ce20a9d2ee0bdb33c90f31861f57d79aec80 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 7 Jul 2015 22:05:31 +0100 Subject: [PATCH] chore(doc-gen): fixup private constructor declarations Closes #2883 --- .../processors/createTypeDefinitionFile.js | 19 +++++++++++++++++++ .../angular2/angular2.d.ts.template.html | 1 + 2 files changed, 20 insertions(+) diff --git a/docs/dgeni-package/processors/createTypeDefinitionFile.js b/docs/dgeni-package/processors/createTypeDefinitionFile.js index 67cdd94c76..c3566a6433 100644 --- a/docs/dgeni-package/processors/createTypeDefinitionFile.js +++ b/docs/dgeni-package/processors/createTypeDefinitionFile.js @@ -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); diff --git a/docs/dgeni-package/templates/angular2/angular2.d.ts.template.html b/docs/dgeni-package/templates/angular2/angular2.d.ts.template.html index a8332d7d5c..fe2051c2e9 100644 --- a/docs/dgeni-package/templates/angular2/angular2.d.ts.template.html +++ b/docs/dgeni-package/templates/angular2/angular2.d.ts.template.html @@ -23,6 +23,7 @@ declare module ng { stack: string; toString(): string; } + interface InjectableReference {} } {% endblock %}