1 | import { IHtmlEngineHelper, IHandlebarsOptions } from './html-engine-helper.interface';
|
2 | import { JsdocTagInterface } from '../../interfaces/jsdoc-tag.interface';
|
3 |
|
4 | export class JsdocDefaultHelper implements IHtmlEngineHelper {
|
5 | public helperFunc(context: any, jsdocTags: JsdocTagInterface[], options: IHandlebarsOptions) {
|
6 | if (jsdocTags) {
|
7 | let i = 0;
|
8 | let len = jsdocTags.length;
|
9 | let tag = {} as JsdocTagInterface;
|
10 | let defaultValue = false;
|
11 |
|
12 | for (i; i < len; i++) {
|
13 | if (jsdocTags[i].tagName) {
|
14 | if (jsdocTags[i].tagName.text === 'default') {
|
15 | defaultValue = true;
|
16 | if (jsdocTags[i].typeExpression && jsdocTags[i].typeExpression.type.name) {
|
17 | tag.type = jsdocTags[i].typeExpression.type.name.text;
|
18 | }
|
19 | if (jsdocTags[i].comment) {
|
20 | tag.comment = jsdocTags[i].comment;
|
21 | }
|
22 | if (jsdocTags[i].name) {
|
23 | tag.name = jsdocTags[i].name.text;
|
24 | }
|
25 | }
|
26 | }
|
27 | }
|
28 | if (defaultValue) {
|
29 | context.tag = tag;
|
30 | return options.fn(context);
|
31 | }
|
32 | }
|
33 | }
|
34 | }
|