From ca7a094355db0f3abef04283400dda1af7d882f9 Mon Sep 17 00:00:00 2001 From: Aleksandar Kamenov Date: Tue, 25 Feb 2020 10:42:28 +0200 Subject: [PATCH 1/2] feat(*): tracing of missed tags/parameters Closes #47 --- components/render-component.ts | 77 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/components/render-component.ts b/components/render-component.ts index 8c60a02..0a62725 100644 --- a/components/render-component.ts +++ b/components/render-component.ts @@ -7,6 +7,7 @@ import { AttributeType } from '../utils/enums/json-keys'; import { Constants } from '../utils/constants'; import { RendererEvent } from 'typedoc/dist/lib/output/events'; import { Parser } from '../utils/parser'; +import { LogLevel } from 'typedoc/dist/lib/utils'; @Component({ name: 'render-component'}) export class RenderComponenet extends RendererComponent { @@ -28,10 +29,6 @@ export class RenderComponenet extends RendererComponent { */ parser: Parser; - public constructor(owner) { - super(owner) - } - public initialize() { this.listenTo(this.owner, { [RendererEvent.BEGIN]: this.onRenderBegin, @@ -141,44 +138,48 @@ export class RenderComponenet extends RendererComponent { } private updateComment(reflection, dataObj) { - if (!reflection.comment || (dataObj && !dataObj[Constants.COMMENT])) { - return; - } - - let parsed; - if (reflection.comment.text) { - parsed = this.parser.joinByCharacter(dataObj[Constants.COMMENT][Constants.TEXT], '\n'); - reflection.comment.text = parsed; - } - - if (reflection.comment.shortText) { - parsed = this.parser.joinByCharacter(dataObj[Constants.COMMENT][Constants.SHORT_TEXT], '\n'); - reflection.comment.shortText = parsed; - } - - if (reflection.comment.returns) { - parsed = this.parser.joinByCharacter(dataObj[Constants.COMMENT][Constants.RETURNS], '\n'); - reflection.comment.returns = parsed; - } - - if (reflection.comment.tags && dataObj[Constants.COMMENT][Constants.TAGS]) { - reflection.comment.tags.forEach(tag => { - const tagFromJson = dataObj[Constants.COMMENT][Constants.TAGS][tag.tagName]; + if (!reflection.comment || (dataObj && !dataObj[Constants.COMMENT])) { + return; + } + + let parsed; + if (reflection.comment.text) { + parsed = this.parser.joinByCharacter(dataObj[Constants.COMMENT][Constants.TEXT], '\n'); + reflection.comment.text = parsed; + } + + if (reflection.comment.shortText) { + parsed = this.parser.joinByCharacter(dataObj[Constants.COMMENT][Constants.SHORT_TEXT], '\n'); + reflection.comment.shortText = parsed; + } + + if (reflection.comment.returns) { + parsed = this.parser.joinByCharacter(dataObj[Constants.COMMENT][Constants.RETURNS], '\n'); + reflection.comment.returns = parsed; + } + + if (reflection.comment.tags && dataObj[Constants.COMMENT][Constants.TAGS]) { + reflection.comment.tags.forEach(tag => { + const tagFromJson = dataObj[Constants.COMMENT][Constants.TAGS][tag.tagName]; + try { tag.tagName = tagFromJson[Constants.COMMENT].tagName; tag.text = this.parser.joinByCharacter(tagFromJson[Constants.COMMENT].text, '\n'); - return tag; + } catch (e) { + this.application.logger.log(`Could not find ${tag.tagName} tag of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn); + } }); - } - - if (reflection.parameters && dataObj[Constants.COMMENT][Constants.PARAMS]) { + } + + if (reflection.parameters && dataObj[Constants.COMMENT][Constants.PARAMS]) { reflection.parameters.forEach(param => { - const paramFromJson = dataObj[Constants.COMMENT][Constants.PARAMS][param.name]; - if (paramFromJson) { - param.comment.text = this.parser.joinByCharacter(paramFromJson[Constants.COMMENT].text, '\n'); - return param; - } - }); - } + const paramFromJson = dataObj[Constants.COMMENT][Constants.PARAMS][param.name]; + try { + param.comment.text = this.parser.joinByCharacter(paramFromJson[Constants.COMMENT].text, '\n'); + } catch(e) { + this.application.logger.log(`Could not find ${param.name} parameter of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn); + } + }); + } } /** From 30592bd15b97479675631f7b1db26c68f658ef11 Mon Sep 17 00:00:00 2001 From: Aleksandar Kamenov Date: Tue, 25 Feb 2020 10:45:02 +0200 Subject: [PATCH 2/2] fix(*): code formatting renderer component Closes #47 --- components/render-component.ts | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/components/render-component.ts b/components/render-component.ts index 0a62725..2382e95 100644 --- a/components/render-component.ts +++ b/components/render-component.ts @@ -159,26 +159,26 @@ export class RenderComponenet extends RendererComponent { } if (reflection.comment.tags && dataObj[Constants.COMMENT][Constants.TAGS]) { - reflection.comment.tags.forEach(tag => { - const tagFromJson = dataObj[Constants.COMMENT][Constants.TAGS][tag.tagName]; - try { - tag.tagName = tagFromJson[Constants.COMMENT].tagName; - tag.text = this.parser.joinByCharacter(tagFromJson[Constants.COMMENT].text, '\n'); - } catch (e) { - this.application.logger.log(`Could not find ${tag.tagName} tag of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn); - } - }); + reflection.comment.tags.forEach(tag => { + const tagFromJson = dataObj[Constants.COMMENT][Constants.TAGS][tag.tagName]; + try { + tag.tagName = tagFromJson[Constants.COMMENT].tagName; + tag.text = this.parser.joinByCharacter(tagFromJson[Constants.COMMENT].text, '\n'); + } catch (e) { + this.application.logger.log(`Could not find ${tag.tagName} tag of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn); } + }); + } - if (reflection.parameters && dataObj[Constants.COMMENT][Constants.PARAMS]) { - reflection.parameters.forEach(param => { - const paramFromJson = dataObj[Constants.COMMENT][Constants.PARAMS][param.name]; - try { - param.comment.text = this.parser.joinByCharacter(paramFromJson[Constants.COMMENT].text, '\n'); - } catch(e) { - this.application.logger.log(`Could not find ${param.name} parameter of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn); - } - }); + if (reflection.parameters && dataObj[Constants.COMMENT][Constants.PARAMS]) { + reflection.parameters.forEach(param => { + const paramFromJson = dataObj[Constants.COMMENT][Constants.PARAMS][param.name]; + try { + param.comment.text = this.parser.joinByCharacter(paramFromJson[Constants.COMMENT].text, '\n'); + } catch(e) { + this.application.logger.log(`Could not find ${param.name} parameter of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn); + } + }); } }