chore(doc-gen): move the "private class" converter into a helper service
This will allow it to be reused in other doc gen configurations
This commit is contained in:
@ -2,7 +2,7 @@ var _ = require('lodash');
|
||||
var path = require('canonical-path');
|
||||
var codeGen = require('./code_gen.js');
|
||||
|
||||
module.exports = function createTypeDefinitionFile(log) {
|
||||
module.exports = function createTypeDefinitionFile(log, convertPrivateClassesToInterfaces) {
|
||||
|
||||
return {
|
||||
$runAfter: ['processing-docs'],
|
||||
@ -63,29 +63,7 @@ module.exports = function createTypeDefinitionFile(log) {
|
||||
doc = null;
|
||||
return;
|
||||
}
|
||||
_.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;
|
||||
|
||||
if (exportDoc.heritage) {
|
||||
// convert the heritage since interfaces use `extends` not `implements`
|
||||
exportDoc.heritage = exportDoc.heritage.replace('implements', 'extends');
|
||||
}
|
||||
|
||||
// Add the `declare var SomeClass extends InjectableReference` construct
|
||||
modDoc.doc.exports.push({
|
||||
docType: 'var',
|
||||
name: exportDoc.name,
|
||||
id: exportDoc.id,
|
||||
returnType: 'InjectableReference'
|
||||
});
|
||||
}
|
||||
});
|
||||
convertPrivateClassesToInterfaces(modDoc.doc.exports, true);
|
||||
});
|
||||
return !!doc;
|
||||
});
|
||||
|
Reference in New Issue
Block a user