chore(doc-gen): render decorators (annotations) for exported classes
Closes #3167 Closes #3221
This commit is contained in:
parent
03fc7fe8c2
commit
45cbc430e8
|
@ -10,6 +10,19 @@ p.location-badge.
|
||||||
:markdown
|
:markdown
|
||||||
{$ doc.description | indent(2, true) $}
|
{$ doc.description | indent(2, true) $}
|
||||||
|
|
||||||
|
{%- if doc.decorators %}
|
||||||
|
.l-main-section
|
||||||
|
h2 Annotations
|
||||||
|
{%- for decorator in doc.decorators %}
|
||||||
|
.l-sub-section
|
||||||
|
h3.annotation {$ decorator.name $}
|
||||||
|
pre.prettyprint
|
||||||
|
code.
|
||||||
|
@{$ decorator.name $}{$ paramList(decorator.arguments) | indent(8, false) $}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
|
||||||
{%- if doc.constructorDoc or doc.members.length -%}
|
{%- if doc.constructorDoc or doc.members.length -%}
|
||||||
.l-main-section
|
.l-main-section
|
||||||
h2 Members
|
h2 Members
|
||||||
|
|
|
@ -9,6 +9,13 @@ defined in {$ githubViewLink(doc) $}
|
||||||
</p>
|
</p>
|
||||||
<p>{$ doc.description | marked $}</p>
|
<p>{$ doc.description | marked $}</p>
|
||||||
|
|
||||||
|
{%- if doc.decorators %}
|
||||||
|
<h2>Annotations</h2>
|
||||||
|
{%- for decorator in doc.decorators %}
|
||||||
|
<h3 class="annotation">@{$ decorator.name $}{$ paramList(decorator.arguments) $}</h3>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
{%- if doc.constructorDoc or doc.members.length -%}
|
{%- if doc.constructorDoc or doc.members.length -%}
|
||||||
<h2>Members</h2>
|
<h2>Members</h2>
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,7 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||||
id: moduleDoc.id + '/' + name,
|
id: moduleDoc.id + '/' + name,
|
||||||
typeParams: typeParamString,
|
typeParams: typeParamString,
|
||||||
heritage: heritageString,
|
heritage: heritageString,
|
||||||
|
decorators: getDecorators(exportSymbol),
|
||||||
aliases: aliasNames,
|
aliases: aliasNames,
|
||||||
moduleDoc: moduleDoc,
|
moduleDoc: moduleDoc,
|
||||||
content: getContent(exportSymbol),
|
content: getContent(exportSymbol),
|
||||||
|
@ -197,6 +198,7 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||||
docType: 'member',
|
docType: 'member',
|
||||||
classDoc: classDoc,
|
classDoc: classDoc,
|
||||||
name: memberSymbol.name,
|
name: memberSymbol.name,
|
||||||
|
decorators: getDecorators(memberSymbol),
|
||||||
content: getContent(memberSymbol),
|
content: getContent(memberSymbol),
|
||||||
fileInfo: getFileInfo(memberSymbol, basePath),
|
fileInfo: getFileInfo(memberSymbol, basePath),
|
||||||
location: getLocation(memberSymbol)
|
location: getLocation(memberSymbol)
|
||||||
|
@ -240,6 +242,23 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||||
return memberDoc;
|
return memberDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getDecorators(symbol) {
|
||||||
|
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
||||||
|
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||||
|
|
||||||
|
var decorators = declaration.decorators && declaration.decorators.map(function(decorator) {
|
||||||
|
decorator = decorator.expression;
|
||||||
|
return {
|
||||||
|
name: decorator.expression.text,
|
||||||
|
arguments: decorator.arguments && decorator.arguments.map(function(argument) {
|
||||||
|
return getText(sourceFile, argument).trim();
|
||||||
|
})
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return decorators;
|
||||||
|
}
|
||||||
|
|
||||||
function getParameters(typeChecker, symbol) {
|
function getParameters(typeChecker, symbol) {
|
||||||
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
||||||
var sourceFile = ts.getSourceFileOfNode(declaration);
|
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||||
|
|
Loading…
Reference in New Issue