1 | import { JsdocTagInterface } from '../../interfaces/jsdoc-tag.interface';
|
2 | import { IHtmlEngineHelper, IHandlebarsOptions } from './html-engine-helper.interface';
|
3 |
|
4 | export class JsdocExampleHelper implements IHtmlEngineHelper {
|
5 | public helperFunc(context: any, jsdocTags: JsdocTagInterface[], options: IHandlebarsOptions) {
|
6 | let i = 0;
|
7 | let len = jsdocTags.length;
|
8 | let tags = [];
|
9 |
|
10 | for (i; i < len; i++) {
|
11 | if (jsdocTags[i].tagName) {
|
12 | if (jsdocTags[i].tagName.text === 'example') {
|
13 | let tag = {} as JsdocTagInterface;
|
14 | if (jsdocTags[i].comment) {
|
15 | tag.comment = jsdocTags[i].comment
|
16 | .replace(/<caption>/g, '<b><i>')
|
17 | .replace(/\/caption>/g, '/b></i>');
|
18 | }
|
19 | tags.push(tag);
|
20 | }
|
21 | }
|
22 | }
|
23 | if (tags.length > 0) {
|
24 | context.tags = tags;
|
25 | return options.fn(context);
|
26 | }
|
27 | }
|
28 | }
|