From fb963224c5de71eb24c2b57a15949533e800fd55 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 5 Oct 2018 17:40:59 +0200 Subject: [PATCH] build(docs): deprecated state of type alias not showing up * Currently if a type alias is marked as `@deprecated`, we don't add an indication as for the constants. Now a similar indication will be added if a type alias is deprecated. * Similarly to the constants and `angular.io`, we will display the actual type of the `type-alias` in a better-looking & more clear way. * Also fixes that the constant code "overview" does not include the trailing semicolon (Angular.io also adds a trailing semicolon) --- tools/dgeni/common/dgeni-definitions.ts | 4 ++++ tools/dgeni/processors/categorizer.ts | 13 +++++++++++++ tools/dgeni/templates/constant.template.html | 2 +- tools/dgeni/templates/type-alias.template.html | 17 +++++++++++++---- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/tools/dgeni/common/dgeni-definitions.ts b/tools/dgeni/common/dgeni-definitions.ts index 57e66638e89b..85d27b9b4660 100644 --- a/tools/dgeni/common/dgeni-definitions.ts +++ b/tools/dgeni/common/dgeni-definitions.ts @@ -3,6 +3,7 @@ import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExpor import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc'; import {ConstExportDoc} from 'dgeni-packages/typescript/api-doc-types/ConstExportDoc'; import {PropertyMemberDoc} from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc'; +import {TypeAliasExportDoc} from 'dgeni-packages/typescript/api-doc-types/TypeAliasExportDoc'; import {ParsedDecorator} from 'dgeni-packages/typescript/services/TsParser/getDecorators'; import {FunctionExportDoc} from 'dgeni-packages/typescript/api-doc-types/FunctionExportDoc'; import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc'; @@ -55,3 +56,6 @@ export interface CategorizedFunctionExportDoc /** Extended Dgeni const export document that simplifies logic for the Dgeni template. */ export interface CategorizedConstExportDoc extends ConstExportDoc, DeprecationDoc {} + +/** Extended Dgeni type alias document that includes more information when rendering. */ +export interface CategorizedTypeAliasExportDoc extends TypeAliasExportDoc, DeprecationDoc {} diff --git a/tools/dgeni/processors/categorizer.ts b/tools/dgeni/processors/categorizer.ts index 8926f4fa808b..573f37582173 100644 --- a/tools/dgeni/processors/categorizer.ts +++ b/tools/dgeni/processors/categorizer.ts @@ -16,6 +16,7 @@ import { CategorizedFunctionExportDoc, CategorizedMethodMemberDoc, CategorizedPropertyMemberDoc, + CategorizedTypeAliasExportDoc, } from '../common/dgeni-definitions'; import {getDirectiveMetadata} from '../common/directive-metadata'; import {normalizeFunctionParameters} from '../common/normalize-function-parameters'; @@ -47,6 +48,10 @@ export class Categorizer implements Processor { docs .filter(doc => doc.docType === 'const') .forEach(doc => this.decorateConstExportDoc(doc)); + + docs + .filter(doc => doc.docType === 'type-alias') + .forEach(doc => this.decorateTypeAliasExportDoc(doc)); } /** @@ -130,6 +135,14 @@ export class Categorizer implements Processor { decorateDeprecatedDoc(doc); } + /** + * Method that will be called for each type-alias export document. We decorate the type-alias + * documents with a property that states whether the type-alias is deprecated or not. + */ + private decorateTypeAliasExportDoc(doc: CategorizedTypeAliasExportDoc) { + decorateDeprecatedDoc(doc); + } + /** * Method that will be called for each property doc. Properties that are Angular inputs or * outputs will be marked. Aliases for the inputs or outputs will be stored as well. diff --git a/tools/dgeni/templates/constant.template.html b/tools/dgeni/templates/constant.template.html index 67021c2c7f5d..c54b29a0b38f 100644 --- a/tools/dgeni/templates/constant.template.html +++ b/tools/dgeni/templates/constant.template.html @@ -18,7 +18,7 @@