feat(docs): export type info for var and const exports

Closes #3700
This commit is contained in:
Brian Ford 2015-08-19 16:04:43 -07:00
parent 3963e0ab39
commit 9262727ae1
3 changed files with 11 additions and 3 deletions

View File

@ -51,7 +51,8 @@ module.exports = function addJadeDataDocsProcessor() {
var modulePageInfo = _.map(doc.exports, function(exportDoc) { var modulePageInfo = _.map(doc.exports, function(exportDoc) {
return { return {
name: exportDoc.name + '-' + exportDoc.docType, name: exportDoc.name + '-' + exportDoc.docType,
title: exportDoc.name title: exportDoc.name,
varType: exportDoc.symbolTypeName && titleCase(exportDoc.symbolTypeName)
}; };
}); });

View File

@ -2,7 +2,8 @@
{%- for item in doc.data %} {%- for item in doc.data %}
"{$ item.name $}" : { "{$ item.name $}" : {
"title" : "{$ item.title $}"{% if item.intro %}, "title" : "{$ item.title $}"{% if item.intro %},
"intro" : "{$ item.intro $}"{% endif %} "intro" : "{$ item.intro $}"{% endif %}{% if item.varType %},
"varType" : "{$ item.varType $}"{% endif %}
}{% if not loop.last %},{% endif %} }{% if not loop.last %},{% endif %}
{% endfor -%} {% endfor -%}
} }

View File

@ -188,6 +188,12 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
location: getLocation(exportSymbol) location: getLocation(exportSymbol)
}; };
if (exportDoc.docType === 'var' || exportDoc.docType === 'const') {
exportDoc.symbolTypeName = exportSymbol.valueDeclaration.type &&
exportSymbol.valueDeclaration.type.typeName &&
exportSymbol.valueDeclaration.type.typeName.text;
}
if(exportSymbol.flags & ts.SymbolFlags.Function) { if(exportSymbol.flags & ts.SymbolFlags.Function) {
exportDoc.parameters = getParameters(typeChecker, exportSymbol); exportDoc.parameters = getParameters(typeChecker, exportSymbol);
} }