Skip to content

build(docs): deprecated state of type alias not showing up #13449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/dgeni/common/dgeni-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {}
13 changes: 13 additions & 0 deletions tools/dgeni/processors/categorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tools/dgeni/templates/constant.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h4 id="{$ constant.name $}" class="docs-header-link docs-api-h4 docs-api-consta
<pre class="docs-markdown-pre">
<code class="docs-markdown-code">
{%- highlight "typescript" -%}
const {$ constant.name | safe $}: {$ constant.type | safe $}
const {$ constant.name | safe $}: {$ constant.type | safe $};
{%- end_highlight -%}
</code>
</pre>
17 changes: 13 additions & 4 deletions tools/dgeni/templates/type-alias.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ <h4 id="{$ alias.name $}" class="docs-header-link docs-api-h4 docs-api-type-alia
<code>{$ alias.name $}</code>
</h4>

{%- if alias.isDeprecated -%}
<div class="docs-api-type-alias-deprecated-marker" {$ macros.deprecationTitle(alias) $}>
Deprecated
</div>
{%- endif -%}

{%- if alias.description -%}
<p class="docs-api-type-alias-description">{$ alias.description | marked | safe $}</p>
{%- endif -%}

<p class="docs-api-type-alias-value">
<span class="docs-api-type-alias-value-label">Type:</span>
<code class="docs-api-type-alias-value">{$ alias.typeDefinition $}</code>
</p>
<pre class="docs-markdown-pre">
<code class="docs-markdown-code">
{%- highlight "typescript" -%}
type {$ alias.name | safe $} = {$ alias.typeDefinition | safe $};
{%- end_highlight -%}
</code>
</pre>