Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/check_pr_title_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check PR Title (Conventional Commits)
on:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
branches: [master]
branches: [master, next-major]

jobs:
check-pr-title:
Expand Down
31 changes: 29 additions & 2 deletions api-generator/api-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ const outputPath = path.resolve(
'projects/composition/src/app/api-data/'
);

// Services aren't always documented on their own dedicated page — some are
// only ever embedded into a different component's page via the `[services]`
// input (e.g. CpsCronValidationService is only ever shown on /scheduler/api).
// Linking to `/<service-name>/api` in that case would 404, so only treat a
// service name as linkable if a matching top-level route actually exists.
const getKnownRoutes = () => {
const routingFile = path.resolve(
rootDir,
'projects/composition/src/app/app-routing.module.ts'
);
try {
const content = fs.readFileSync(routingFile, 'utf8');
return new Set(
[...content.matchAll(/pathMatcher\(\s*'([^']+)'\s*\)/g)].map((m) => m[1])
);
} catch (_) {
return new Set();
}
};
const knownRoutes = getKnownRoutes();

const staticMessages = {
methods: "Defines methods that can be accessed by the component's reference.",
emits:
Expand All @@ -18,7 +39,8 @@ const staticMessages = {
props: 'Defines the input properties of the component.',
service: 'Defines the service used by the component.',
enums: 'Defines enums used by the component or service.',
classes: 'Defines classes exposed by the component or service.'
classes: 'Defines classes exposed by the component or service.',
tokens: 'Injection tokens exposed by the component or service.'
};

async function main() {
Expand Down Expand Up @@ -191,6 +213,7 @@ async function main() {
comment &&
comment.summary.map((s) => s.text || '').join(' ')
};
typesMap[componentName] = name.replace('cps-', '');

const component_props_group = component.groups.find(
(g) => g.title === 'Props'
Expand Down Expand Up @@ -469,6 +492,10 @@ async function main() {
service.comment &&
service.comment.summary.map((s) => s.text || '').join(' ')
};
const serviceSlug = name.replace('cps-', '');
if (knownRoutes.has(serviceSlug)) {
typesMap[service.name] = serviceSlug;
}
const service_methods_group = service.groups.find(
(g) => g.title === 'Method'
);
Expand Down Expand Up @@ -510,7 +537,7 @@ async function main() {

if (isProcessable(module_tokens_group)) {
const tokens = {
description: 'Injection tokens exposed by the service.',
description: staticMessages.tokens,
values: []
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
]
},
"tokens": {
"description": "Injection tokens exposed by the service.",
"description": "Injection tokens exposed by the component or service.",
"values": [
{
"name": "CPS_CRON_VALIDATION_SERVICE",
Expand Down
10 changes: 10 additions & 0 deletions projects/composition/src/app/api-data/cps-dialog.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
}
]
},
"tokens": {
"description": "Injection tokens exposed by the component or service.",
"values": [
{
"name": "CPS_DIALOG_CONFIG",
"type": "InjectionToken<CpsDialogConfig<any>>",
"description": "Injection token used to provide/inject a CpsDialogConfig value.\n\nThere is no default — it is provided per-dialog-instance by\n `CpsDialogService` , so it should only be injected from within a\ndialog's component tree."
}
]
},
"interfaces": {
"description": "Defines the custom interfaces used by the component or service.",
"values": [
Expand Down
10 changes: 10 additions & 0 deletions projects/composition/src/app/api-data/cps-icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
}
}
},
"tokens": {
"description": "Injection tokens exposed by the component or service.",
"values": [
{
"name": "ICONS_PATH",
"type": "InjectionToken<string>",
"description": "Injection token that is used to provide the path to the icons."
}
]
},
"types": {
"description": "Defines the custom types used by the component or service.",
"values": [
Expand Down
10 changes: 10 additions & 0 deletions projects/composition/src/app/api-data/cps-radio-group.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@
}
}
},
"tokens": {
"description": "Injection tokens exposed by the component or service.",
"values": [
{
"name": "CPS_RADIO_GROUP",
"type": "InjectionToken<CpsRadioGroupComponent>",
"description": "Injection token used by child radio buttons to look up their parent\n `CpsRadioGroupComponent` ."
}
]
},
"types": {
"description": "Defines the custom types used by the component or service.",
"values": [
Expand Down
37 changes: 37 additions & 0 deletions projects/composition/src/app/api-data/types_map.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,76 @@
{
"CpsAutocompleteComponent": "autocomplete",
"CpsAutocompleteAppearanceType": "autocomplete",
"CpsButtonToggleComponent": "button-toggle",
"CpsButtonToggleOption": "button-toggle",
"CpsButtonComponent": "button",
"CpsCheckboxComponent": "checkbox",
"CpsChipComponent": "chip",
"CpsDatepickerComponent": "datepicker",
"CpsDatepickerAppearanceType": "datepicker",
"CpsDatepickerDateFormat": "datepicker",
"CpsDividerComponent": "divider",
"CpsDividerType": "divider",
"CpsExpansionPanelComponent": "expansion-panel",
"CpsFileUploadComponent": "file-upload",
"CpsIconComponent": "icon",
"IconType": "icon",
"iconSizeType": "icon",
"CpsInfoCircleComponent": "info-circle",
"CpsInputComponent": "input",
"CpsInputAppearanceType": "input",
"CpsLoaderComponent": "loader",
"CpsMenuComponent": "menu",
"CpsMenuItem": "menu",
"CpsMenuAttachPosition": "menu",
"CpsMenuHideReason": "menu",
"CpsPaginatorComponent": "paginator",
"CpsProgressCircularComponent": "progress-circular",
"CpsProgressLinearComponent": "progress-linear",
"CpsRadioButtonComponent": "radio-group",
"CpsRadioGroupComponent": "radio-group",
"CpsRadioOption": "radio-group",
"CpsRadioComponent": "radio-group",
"CpsSchedulerComponent": "scheduler",
"CpsSelectComponent": "select",
"CpsSelectAppearanceType": "select",
"CpsSidebarMenuComponent": "sidebar-menu",
"CpsSidebarMenuItem": "sidebar-menu",
"CpsSwitchComponent": "switch",
"CpsTabGroupComponent": "tab-group",
"CpsTabChangeEvent": "tab-group",
"CpsTabsAnimationType": "tab-group",
"CpsTabsAlignmentType": "tab-group",
"CpsTabComponent": "tab-group",
"CpsColumnFilterCategoryOption": "table",
"CpsColumnFilterType": "table",
"CpsColumnFilterMatchMode": "table",
"CpsTableComponent": "table",
"CpsTableExportFormat": "table",
"CpsTableSize": "table",
"CpsTableToolbarSize": "table",
"CpsTableSortMode": "table",
"CpsTagComponent": "tag",
"CpsTextareaComponent": "textarea",
"CpsTimepickerComponent": "timepicker",
"CpsTime": "timepicker",
"CpsTreeAutocompleteComponent": "tree-autocomplete",
"CpsTreeAutocompleteAppearanceType": "tree-autocomplete",
"CpsTreeSelectComponent": "tree-select",
"CpsTreeSelectAppearanceType": "tree-select",
"CpsTreeTableComponent": "tree-table",
"CpsTreeTableSize": "tree-table",
"CpsTreeTableToolbarSize": "tree-table",
"CpsTreeTableSortMode": "tree-table",
"CpsBaseTreeDropdownComponent": "internal",
"CpsTooltipDirective": "tooltip",
"CpsTooltipPosition": "tooltip",
"CpsTooltipOpenOn": "tooltip",
"CpsDialogService": "dialog",
"CpsDialogConfig": "dialog",
"CpsDialogAutoFocusTarget": "dialog",
"CpsDialogRef": "dialog",
"CpsNotificationService": "notification",
"CpsNotificationConfig": "notification",
"CpsNotificationAppearance": "notification",
"CpsNotificationPosition": "notification"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,41 @@ <h2>Types</h2>
</div>
}
}
<!-- Tokens -->
@if (
componentData.tokens &&
componentData.tokens.values &&
componentData.tokens.values.length > 0
) {
<div>
<h2>Tokens</h2>
<p>{{ componentData.tokens.description }}</p>
<div>
<table class="data-table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
@for (token of componentData.tokens.values; track token.name) {
<tr>
<td class="highlighted-bg">
<span>{{ token.name }}</span>
</td>
<td class="highlighted-text">
<app-api-type [type]="token.type" [typesMap]="TypesMap" />
</td>
<td>{{ token.description }}</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
<!-- Interfaces -->
@if (
componentData.interfaces &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
InterfaceAPI,
TypesAPI
} from '../../models/component-api.model';
import { ServiceAPI } from '../../models/service-api.model';
import { ServiceAPI, TokensAPI } from '../../models/service-api.model';
import {
CpsTabComponent,
CpsTabGroupComponent,
Expand Down Expand Up @@ -37,6 +37,7 @@ export class ComponentDocsViewerComponent extends ViewerComponent {
types?: TypesAPI;
interfaces?: InterfaceAPI;
enums?: EnumsAPI;
tokens?: TokensAPI;
};

@Input() services?: ServiceAPI[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { Component, Inject, OnInit } from '@angular/core';

Check warning on line 1 in projects/composition/src/app/components/dialog-content/dialog-content.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
import {
CPS_DIALOG_CONFIG,
CpsButtonComponent,
CpsDialogConfig,
CpsDialogRef,
CpsIconComponent
CpsIconComponent,
type CpsDialogConfig
} from 'cps-ui-kit';

@Component({
Expand All @@ -12,16 +13,15 @@
templateUrl: './dialog-content.component.html',
styleUrls: ['./dialog-content.component.scss']
})
export class DialogContentComponent implements OnInit {
info = '';
icon = '';

closeDisabled = false;

// eslint-disable-next-line no-useless-constructor
constructor(
private _dialogRef: CpsDialogRef,
private _config: CpsDialogConfig
@Inject(CPS_DIALOG_CONFIG) private _config: CpsDialogConfig

Check warning on line 24 in projects/composition/src/app/components/dialog-content/dialog-content.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
) {
this.info = this._config.data.info;
this.icon = this._config.data.icon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,43 @@ <h2>Methods</h2>
</div>
</div>
}
<!-- Tokens -->
@if (
serviceData.tokens &&
serviceData.tokens.values &&
serviceData.tokens.values.length > 0
) {
<div>
<h2>Tokens</h2>
<p>{{ serviceData.tokens.description }}</p>
<div>
<table class="data-table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
@for (token of serviceData.tokens.values; track token.name) {
<tr>
<td class="highlighted-bg">
<span>{{ token.name }}</span>
</td>
<td class="highlighted-text">
<app-api-type
[type]="token.type"
[typesMap]="TypesMap" />
</td>
<td>{{ token.description }}</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
<!-- Types -->
@if (
serviceData.types &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
flex-wrap: nowrap;
display: inline-flex;
align-items: center;
gap: 0.35rem;

.type-sep {
margin-right: 0.35rem;
}
}

.type-part {
Expand Down
Loading
Loading