Skip to content

Commit

Permalink
refactor(docs-infra): support initializer API functions (angular#54925)
Browse files Browse the repository at this point in the history
This commit ensures that extracted initializer API functions are
showing up in angular.dev and can be filtered.

PR Close angular#54925
  • Loading branch information
devversion authored and ilirbeqirii committed Apr 6, 2024
1 parent 2efcf2b commit e3061ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ <h1 tabindex="-1">API Reference</h1>
</div>
<ul class="adev-reference-list-legend">
@for (itemType of itemTypes; track itemType) {
<li
class="adev-reference-list-legend-item"
[class.adev-reference-list-legend-item-active]="type() === itemType"
(click)="filterByItemType(itemType)"
>
<docs-api-item-label [type]="itemType" mode="short" class="docs-api-item-label" />
<span>{{ itemType | adevApiLabel : 'full' }}</span>
</li>
<li
class="adev-reference-list-legend-item"
[class.adev-reference-list-legend-item-active]="type() === itemType"
(click)="filterByItemType(itemType)"
>
<docs-api-item-label [type]="itemType" mode="short" class="docs-api-item-label" />
<span class="docs-api-item-label-full">{{ itemType | adevApiLabel : 'full' }}</span>
</li>
}
</ul>
</form>

@if (featuredGroup().items.length) {
<adev-api-items-section [group]="featuredGroup()" class="adev-featured-list" />
} @for (group of filteredGroups(); track group) {
<adev-api-items-section [group]="group" />
<adev-api-items-section [group]="featuredGroup()" class="adev-featured-list" />
}
@for (group of filteredGroups(); track group) {
<adev-api-items-section [group]="group" />
}

<span id="deprecated-description" class="docs-deprecated-description">Deprecated</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@
.docs-deprecated-description {
display: none;
}

.docs-api-item-label-full {
white-space: nowrap;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export enum ApiItemType {
PIPE = 'pipe',
NG_MODULE = 'ng_module',
TYPE_ALIAS = 'type_alias',
INITIALIZER_API_FUNCTION = 'initializer_api_function',
}
3 changes: 3 additions & 0 deletions adev/src/app/features/references/pipes/api-label.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import {Pipe, PipeTransform} from '@angular/core';

import {ApiItemType} from '../interfaces/api-item-type';

@Pipe({
Expand All @@ -27,6 +28,7 @@ export class ApiLabel implements PipeTransform {
[ApiItemType.PIPE]: 'P',
[ApiItemType.NG_MODULE]: 'M',
[ApiItemType.TYPE_ALIAS]: 'T',
[ApiItemType.INITIALIZER_API_FUNCTION]: 'IA',
};

private readonly fullLabelsMap: Record<ApiItemType, string> = {
Expand All @@ -42,6 +44,7 @@ export class ApiLabel implements PipeTransform {
[ApiItemType.PIPE]: 'Pipe',
[ApiItemType.NG_MODULE]: 'Module',
[ApiItemType.TYPE_ALIAS]: 'Type Alias',
[ApiItemType.INITIALIZER_API_FUNCTION]: 'Initializer API',
};

transform(value: ApiItemType, labelType: 'short' | 'full'): string {
Expand Down

0 comments on commit e3061ba

Please sign in to comment.