Skip to content

Commit 3fe6740

Browse files
committed
fix: repo-ref directory display + tag cleanup
1 parent bdcb492 commit 3fe6740

File tree

5 files changed

+69
-13
lines changed

5 files changed

+69
-13
lines changed

src/app/reference/repo-ref/repo-ref.component.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
<ng-template #loadingTpl>
2-
<div>Loading...</div>
2+
<div class="max-w-sm m-auto">
3+
<p class="text-center m-8">Loading...</p>
4+
</div>
35
</ng-template>
46

5-
<ng-container *ngIf="def; else loadingTpl">
7+
<ng-template #noDefTpl>
8+
<ng-container *ngIf="!loading; else loadingTpl">
9+
<div class="max-w-sm m-auto">
10+
<p class="text-center m-8">Unable to find reference documentation.</p>
11+
</div>
12+
</ng-container>
13+
</ng-template>
14+
15+
<ng-container *ngIf="def; else noDefTpl">
616
<!-- https://github.com/angular/angular/issues/20780 -->
717
<div [ngSwitch]="def.kind">
818
<ng-container *ngSwitchCase="'datatype'">

src/app/reference/repo-ref/repo-ref.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
})
2020
export class RepoRefComponent implements OnInit {
2121
def?: DoxygenCompoundDef | DoxygenMemberDef;
22+
loading = false;
2223

2324
constructor(
2425
private search: Search,
@@ -31,8 +32,14 @@ export class RepoRefComponent implements OnInit {
3132
const repo = paramMap.get('repo');
3233
const refid = paramMap.get('refid');
3334

34-
this.def = await this.search.getDef(repo, refid);
35-
this.cdr.markForCheck();
35+
this.loading = true;
36+
try {
37+
this.def = await this.search.getDef(repo, refid);
38+
} finally {
39+
this.loading = false;
40+
this.cdr.markForCheck();
41+
}
42+
3643
});
3744
}
3845
}

src/app/reference/repo/repo.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ng-template #compoundsListTpl let-compounds>
22
<p *ngIf="compounds.length === 0">(none)</p>
3-
<ul class="list-disc list-inside">
3+
<ul class="list-disc list-inside compound-list">
44
<li
55
*ngFor="
66
let compound of sortByName(
@@ -12,8 +12,8 @@
1212
<a [doxygenRefidLink]="compound.refid" [title]="compound.name"
1313
><code>{{ compound.name }}</code></a
1414
>
15-
<span>{{ compound.kind }}</span>
16-
<span *ngIf="compound.internal">INTERNAL API</span>
15+
<span class="kind-tag bg-primary">{{ compound.kind }}</span>
16+
<span class="kind-tag bg-error" *ngIf="compound.internal">INTERNAL API</span>
1717
</li>
1818
</ul>
1919
</ng-template>
@@ -47,6 +47,7 @@ <h1 id="ref-index">Repository Reference Index</h1>
4747
<ng-container *ngSwitchCase="RepoCompoundsView.ByKind">
4848
<div class="repo-directories" *ngIf="dirs$ | async as dirs">
4949
<div
50+
[attr.title]="dir.name"
5051
*ngFor="
5152
let dir of sortByName(showInternals ? dirs : filterInternal(dirs));
5253
trackBy: trackyByRefid

src/app/reference/repo/repo.component.scss

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
}
1313

1414
li.compound-list-item {
15+
margin: 4px 0px;
1516
font-family: 'Noto Sans Mono', monospace;
1617

1718
a {
@@ -30,11 +31,46 @@ li.compound-list-item {
3031
display: grid;
3132
grid-template-columns: 1fr 1fr 1fr;
3233
gap: 16px;
33-
margin: 16px;
34+
margin: 16px 0;
3435

3536
.repo-dir {
3637
border-radius: 6px;
3738
padding: 8px;
3839
background-color: #392f5a;
40+
display: flex;
41+
flex-direction: row;
42+
overflow: hidden;
43+
a {
44+
overflow: hidden;
45+
text-overflow: ellipsis;
46+
}
47+
}
48+
}
49+
50+
.kind-tag {
51+
font-size: 70%;
52+
display: inline-block;
53+
margin: 0 4px;
54+
padding: 2px 4px;
55+
border-radius: 4px;
56+
}
57+
58+
@media(max-width: 1024px) {
59+
.repo-directories {
60+
grid-template-columns: 1fr 1fr;
61+
}
62+
}
63+
64+
@media(max-width: 599px) {
65+
.repo-directories {
66+
grid-template-columns: 1fr;
67+
}
68+
69+
.compound-list {
70+
margin: 16px 0px;
71+
}
72+
73+
li.compound-list-item {
74+
list-style: none;
3975
}
4076
}

src/search/search.service.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ function parseDoxygenMember(el: Element): DoxygenMember {
3434
function parseDoxygenCompound(el: Element): DoxygenCompound {
3535
return {
3636
...parseDoxygenBase(el),
37-
members: Array.from(el.querySelectorAll('member')).map(parseDoxygenMember),
37+
members:
38+
Array.from(el.querySelectorAll('member'))
39+
.map(parseDoxygenMember)
40+
.filter(mem => mem.name.indexOf('__') === -1),
3841
};
3942
}
4043

@@ -195,7 +198,6 @@ export class Search {
195198

196199
const index = this._refidMap[refid];
197200
if (typeof index !== 'number') {
198-
console.log(this._refidMap);
199201
throw new Error(`Unknown refid ${refid}`);
200202
}
201203

@@ -272,9 +274,9 @@ export class Search {
272274
xhr.send();
273275
});
274276

275-
const compounds = Array.from(doc.documentElement.children).map(
276-
parseDoxygenCompound,
277-
);
277+
const compounds = Array.from(doc.documentElement.children)
278+
.map(parseDoxygenCompound)
279+
.filter(compound => compound.name.indexOf('__') === -1);
278280

279281
this._compounds[repo] = compounds;
280282

0 commit comments

Comments
 (0)