Skip to content

Commit d050ce2

Browse files
petebacondarwinmhevery
authored andcommitted
chore(doc-gen): fixup private constructor declarations
Closes angular#2883
1 parent 6c933a4 commit d050ce2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docs/dgeni-package/processors/createTypeDefinitionFile.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module.exports = function createTypeDefinitionFile(log) {
5757
_.forEach(docs, function(doc) {
5858
_.forEach(typeDefDocs, function(typeDefDoc) {
5959
if(typeDefDoc.moduleDocs[doc.id]) {
60+
// Add a copy, because we are going to modify it
6061
typeDefDoc.moduleDocs[doc.id].doc = doc;
6162
}
6263
});
@@ -68,6 +69,24 @@ module.exports = function createTypeDefinitionFile(log) {
6869
log.error('createTypeDefinitionFile processor: no such module "' + alias + '" (Did you forget to add it to the modules to load?)');
6970
doc = null;
7071
}
72+
_.forEach(modDoc.doc.exports, function(exportDoc) {
73+
74+
// Search for classes with a constructor marked as `@private`
75+
if (exportDoc.docType === 'class' && exportDoc.constructorDoc && exportDoc.constructorDoc.private) {
76+
77+
// Convert this class to an interface with no constructor
78+
exportDoc.docType = 'interface';
79+
exportDoc.constructorDoc = null;
80+
81+
// Add the `declare var SomeClass extends InjectableReference` construct
82+
modDoc.doc.exports.push({
83+
docType: 'var',
84+
name: exportDoc.name,
85+
id: exportDoc.id,
86+
heritage: ': InjectableReference'
87+
});
88+
}
89+
});
7190
});
7291
if (doc) {
7392
docs.push(doc);

docs/dgeni-package/templates/angular2/angular2.d.ts.template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
stack: string;
2424
toString(): string;
2525
}
26+
interface InjectableReference {}
2627
}
2728
{% endblock %}
2829

0 commit comments

Comments
 (0)