Skip to content

Commit 76cb889

Browse files
griest024xelaint
andauthored
feat(dgeni,daffio): render API package descriptions (#3031)
--------- Co-authored-by: xelaint <[email protected]>
1 parent 3e1fe98 commit 76cb889

File tree

9 files changed

+38
-11
lines changed

9 files changed

+38
-11
lines changed

apps/daffio/src/app/docs/api/components/api-list-section/api-list-section-theme.scss

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@
77

88
.daffio-api-list-section {
99
&__item {
10+
color: $base-contrast;
11+
1012
&:focus {
1113
box-shadow: 0 0 0 4px rgba($base-contrast, 0.1);
1214
outline: none;
1315
}
1416

15-
&:after {
17+
&::after {
1618
background: daff-theme.daff-illuminate($base, $neutral, 2);
19+
opacity: 0;
20+
}
21+
22+
&:hover {
23+
&::after {
24+
opacity: 1;
25+
}
1726
}
1827
}
1928
}

apps/daffio/src/app/docs/api/components/api-list-section/api-list-section.component.scss

+3-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $api-list-section-item-border-radius: 4px;
2525
&__item {
2626
display: flex;
2727
align-items: center;
28+
gap: 16px;
2829
border-radius: $api-list-section-item-border-radius;
2930
font-weight: normal;
3031
justify-content: space-between;
@@ -40,15 +41,12 @@ $api-list-section-item-border-radius: 4px;
4041
top: 0;
4142
height: 100%;
4243
width: 100%;
43-
opacity: 0;
4444
transition: opacity 300ms;
4545
z-index: 1;
4646
}
4747

4848
&:hover {
49-
&::after {
50-
opacity: 1;
51-
}
49+
text-decoration: none;
5250
}
5351
}
5452

@@ -58,9 +56,8 @@ $api-list-section-item-border-radius: 4px;
5856

5957
&__item-label {
6058
@include type-mixin.type-label();
61-
height: 1.5rem;
59+
flex: 0 0 auto;
6260
padding: 4px;
63-
margin-left: 16px;
6461
}
6562

6663
&__item-name,

apps/daffio/src/app/docs/api/components/api-list-section/api-list-section.component.ts

+5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ import {
66
} from '@angular/core';
77
import { RouterLink } from '@angular/router';
88

9+
import { DaffArticleEncapsulatedDirective } from '@daffodil/design';
10+
911
import { DaffioApiReference } from '../../models/api-reference';
1012

1113
@Component({
1214
selector: 'daffio-api-list-section',
1315
templateUrl: './api-list-section.component.html',
1416
styleUrls: ['./api-list-section.component.scss'],
17+
hostDirectives: [{
18+
directive: DaffArticleEncapsulatedDirective,
19+
}],
1520
changeDetection: ChangeDetectionStrategy.OnPush,
1621
standalone: true,
1722
imports: [

apps/daffio/src/app/docs/api/models/api-doc.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DaffioDoc } from '../../models/doc';
44
* An object for an API document.
55
*/
66
export interface DaffioApiDoc extends DaffioDoc {
7+
description: string;
78
docType: string;
89
docTypeShorthand: string;
910
}

apps/daffio/src/app/docs/components/doc-viewer/doc-viewer.component.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
</button>
55
<div class="daffio-doc-viewer__grid">
66
@if (isApiPackage) {
7-
<div class="daffio-doc-viewer__content">
8-
<h1 class="daffio-doc-viewer__title">{{doc.title}}</h1>
9-
<daffio-api-list-section [children]="doc.children"></daffio-api-list-section>
10-
</div>
7+
<daff-article class="daffio-doc-viewer__content">
8+
<h1>{{doc.title}}</h1>
9+
<p>{{doc.description}}</p>
10+
<daffio-api-list-section [children]="doc.children" class="daffio-doc-viewer__api-section"></daffio-api-list-section>
11+
</daff-article>
1112
} @else {
1213
<daff-article
1314
class="daffio-doc-viewer__content"

apps/daffio/src/app/docs/components/doc-viewer/doc-viewer.component.scss

+4
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@
6262
display: none;
6363
}
6464
}
65+
66+
&__api-section {
67+
margin: 48px 0 0;
68+
}
6569
}

apps/daffio/src/scss/type-descriptors/_mixins.scss

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ $base-contrast: daff-theme.daff-map-deep-get(daff-theme.$theme, 'core.base-contr
1717
border-radius: 4px;
1818
font-family: daff.$monospace-font-family;
1919
font-size: 0.625rem;
20+
line-height: 0.875rem;
2021
box-sizing: border-box;
2122
text-transform: uppercase;
2223

tools/dgeni/src/processors/packages.ts

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import {
22
Processor,
33
Document,
44
} from 'dgeni';
5+
import * as path from 'path';
6+
7+
import { API_SOURCE_PATH } from '../transforms/config';
58

69
export class PackagesProcessor implements Processor {
710
name = 'packages';
@@ -17,6 +20,10 @@ export class PackagesProcessor implements Processor {
1720
.replace('/src', '')
1821
.replace(/^.*libs\//, '');
1922
doc.docType = 'package';
23+
try {
24+
const packageJson = require(path.resolve(API_SOURCE_PATH, doc.id, 'package.json'));
25+
doc.description = packageJson.description;
26+
} catch {}
2027
// The name is actually the full id
2128
doc.name = this.nameComputer(doc.id);
2229
}

tools/dgeni/src/transforms/daffodil-api-package/helpers/generateApiList.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface DaffDocsApiNavigationList {
66
id: string;
77
title: string;
88
path: string;
9+
description?: string;
910
docType: string;
1011
docTypeShorthand: string;
1112
children: Array<DaffDocsApiNavigationList>;
@@ -47,6 +48,7 @@ export function getPackageInfo(packageDoc): DaffDocsApiNavigationList {
4748
return {
4849
...getExportInfo(packageDoc),
4950
title: packageDoc.name,
51+
description: packageDoc.description,
5052
docType: 'package',
5153
docTypeShorthand: 'pk',
5254
children: packageDoc.exports

0 commit comments

Comments
 (0)