Skip to content

Commit

Permalink
Merge pull request #50 from IgniteUI/source-file-extraction
Browse files Browse the repository at this point in the history
expose option enabling warnings
  • Loading branch information
Aleksandyr authored Feb 25, 2020
2 parents 7c12184 + 85fbe9a commit 6ccd791
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
11 changes: 9 additions & 2 deletions components/render-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { LogLevel } from 'typedoc/dist/lib/utils';

@Component({ name: 'render-component'})
export class RenderComponenet extends RendererComponent {
private warns: boolean;

fileOperations: FileOperations;
/**
* Contains data per every processed Object like (Class, Inteface, Enum)
Expand Down Expand Up @@ -44,6 +46,7 @@ export class RenderComponenet extends RendererComponent {
const reflections = event.project.reflections;
const options = this.application.options.getRawValues();
const localizeOpt = options[Constants.RENDER_OPTION];
this.warns = options[Constants.WARNS];
if (localizeOpt) {
this.mainDirOfJsons = localizeOpt;
this.globalFuncsData = this.fileOperations.getFileData(this.mainDirOfJsons, Constants.GLOBAL_FUNCS_FILE_NAME, 'json');
Expand Down Expand Up @@ -165,7 +168,9 @@ export class RenderComponenet extends RendererComponent {
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 (this.warns) {
this.application.logger.log(`Could not find ${tag.tagName} tag of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn);
}
}
});
}
Expand All @@ -176,7 +181,9 @@ export class RenderComponenet extends RendererComponent {
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 (this.warns) {
this.application.logger.log(`Could not find ${param.name} parameter of ${reflection.parent.name} in ${reflection.parent.parent.name}`, LogLevel.Warn);
}
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class Constants {
static readonly PARAMS = 'parameters';
static readonly RETURNS = 'returns';
static readonly TAGS = 'tags';
static readonly WARNS = 'warns';
static readonly TAG_NAME = 'tagName';
static readonly COMMENT = 'comment';
static readonly TEXT = 'text';
Expand All @@ -20,6 +21,7 @@ export class Constants {
static readonly SHORT_CONVERT_OPTION = 'gen-json';
static readonly SHORT_RENDER_OPTION = 'gen-from-json';
static readonly INCLUDE_TAGS_OPTION = 'tags';
static readonly INCLUDE_WARNS_OPTION = 'warns';
static readonly INCLUDE_PARAMS_OPTION = 'params';
static readonly LOCALIZE_OPTION = 'localize'
static readonly TEMPLATE_STRINGS_OPTION = 'templateStrings';
Expand Down
21 changes: 14 additions & 7 deletions utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,36 @@ export function pluginOptions(options: Options) {
name: Constants.RENDER_OPTION,
short: Constants.SHORT_RENDER_OPTION,
help: 'Specify from where to get the loclized json data.'
})
});

options.addDeclaration({
name: Constants.INCLUDE_TAGS_OPTION,
help: 'Specify whether to include tags per comment.',
type: ParameterType.Boolean,
defaultValue: true
})
defaultValue: false
});

options.addDeclaration({
name: Constants.INCLUDE_PARAMS_OPTION,
help: 'Specify whether to include params per comment.',
type: ParameterType.Boolean,
defaultValue: true
})
defaultValue: false
});

options.addDeclaration({
name: Constants.INCLUDE_WARNS_OPTION,
help: 'Specify whether to throw warnings of missed tags and parameters into the json\'s.',
type: ParameterType.Boolean,
defaultValue: false
});

options.addDeclaration({
name: Constants.LOCALIZE_OPTION,
help: 'Specify your localization for instance (jp)'
})
});

options.addDeclaration({
name: Constants.TEMPLATE_STRINGS_OPTION,
help: 'Path to the json file which contains your localized template strings'
})
});
}

0 comments on commit 6ccd791

Please sign in to comment.