chore(doc-gen): move typeParams and heritage rendering to template
Partially solves #2452
This commit is contained in:
parent
a187c782aa
commit
659adf83dc
|
@ -116,23 +116,30 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
|
||||||
}
|
}
|
||||||
|
|
||||||
function createExportDoc(name, exportSymbol, moduleDoc, basePath, typeChecker) {
|
function createExportDoc(name, exportSymbol, moduleDoc, basePath, typeChecker) {
|
||||||
|
var typeParamString = '';
|
||||||
|
var heritageString = '';
|
||||||
|
|
||||||
exportSymbol.declarations.forEach(function(decl) {
|
exportSymbol.declarations.forEach(function(decl) {
|
||||||
var sourceFile = ts.getSourceFileOfNode(decl);
|
var sourceFile = ts.getSourceFileOfNode(decl);
|
||||||
|
|
||||||
if (decl.typeParameters) {
|
if (decl.typeParameters) {
|
||||||
name = name + '<' + getText(sourceFile, decl.typeParameters) + '>';
|
typeParamString = '<' + getText(sourceFile, decl.typeParameters) + '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decl.heritageClauses) {
|
if (decl.heritageClauses) {
|
||||||
decl.heritageClauses.forEach(function(heritage) {
|
decl.heritageClauses.forEach(function(heritage) {
|
||||||
|
|
||||||
if (heritage.token == ts.SyntaxKind.ExtendsKeyword) {
|
if (heritage.token == ts.SyntaxKind.ExtendsKeyword) {
|
||||||
name = name + " extends ";
|
heritageString += " extends ";
|
||||||
heritage.types.forEach(function(typ, idx) {
|
heritage.types.forEach(function(typ, idx) {
|
||||||
name = name + (idx > 0 ? ', ' : '') + typ.getFullText();
|
heritageString += (idx > 0 ? ', ' : '') + typ.getFullText();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heritage.token == ts.SyntaxKind.ImplementsKeyword) {
|
if (heritage.token == ts.SyntaxKind.ImplementsKeyword) {
|
||||||
name = name + " implements ";
|
heritageString += " implements ";
|
||||||
heritage.types.forEach(function(typ, idx) {
|
heritage.types.forEach(function(typ, idx) {
|
||||||
name = name + (idx > 0 ? ', ' : '') + typ.getFullText();
|
heritageString += (idx > 0 ? ', ' : '') + typ.getFullText();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -143,7 +150,9 @@ module.exports = function readTypeScriptModules(tsParser, readFilesProcessor, mo
|
||||||
docType: getExportDocType(exportSymbol),
|
docType: getExportDocType(exportSymbol),
|
||||||
name: name,
|
name: name,
|
||||||
id: name,
|
id: name,
|
||||||
aliases: [name],
|
typeParams: typeParamString,
|
||||||
|
heritage: heritageString,
|
||||||
|
aliases: [name, name + typeParamString],
|
||||||
moduleDoc: moduleDoc,
|
moduleDoc: moduleDoc,
|
||||||
content: getContent(exportSymbol),
|
content: getContent(exportSymbol),
|
||||||
fileInfo: getFileInfo(exportSymbol, basePath),
|
fileInfo: getFileInfo(exportSymbol, basePath),
|
||||||
|
|
|
@ -47,7 +47,7 @@ declare module "{$ module.id $}" {
|
||||||
{%- if export.content -%}
|
{%- if export.content -%}
|
||||||
{$ commentBlock(export, 3) $}
|
{$ commentBlock(export, 3) $}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{$ export.docType $} {$ export.name $}
|
{$ export.docType $} {$ export.name $}{$ export.typeParams $}{$ export.heritage $}
|
||||||
{%- if export.docType == 'class' or export.docType == 'interface' %} {
|
{%- if export.docType == 'class' or export.docType == 'interface' %} {
|
||||||
{%- for member in export.members -%}
|
{%- for member in export.members -%}
|
||||||
{$ commentBlock(member, 5) $}
|
{$ commentBlock(member, 5) $}
|
||||||
|
|
Loading…
Reference in New Issue