Skip to content

Commit 7772112

Browse files
committed
add support for new json generator: deprecated, return values, keywords
1 parent 3642cb1 commit 7772112

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed

src/components/docs/Doc.astro

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,33 @@ import DocsFiche from "./DocsFiche.astro";
44
import DocData from "./DocData.astro";
55
import { DocType } from "./Docs.astro";
66
7+
/**
8+
* A reference to a different Documentation.
9+
*/
10+
export interface DocumentationReference {
11+
name: string;
12+
id: string;
13+
}
14+
15+
/**
16+
* A documentation entry.
17+
*/
718
export interface Documentation {
819
id: string,
920
new: boolean;
1021
type: DocType;
1122
name: string;
1223
description: string[];
24+
deprecated: boolean;
25+
cancellable: boolean | null;
1326
since: string | null;
1427
requirements: string[] | null;
15-
eventValues: string | null;
16-
returnType: string | null;
28+
eventValues: DocumentationReference[] | null;
29+
returnType: DocumentationReference | null;
1730
events: string[] | null;
1831
patterns: string[] | null;
1932
examples: string[] | null;
33+
keywords: string[] | null;
2034
}
2135
2236
interface Props {
@@ -54,7 +68,8 @@ function color(): string {
5468

5569
<div class="flex flex-col gap-1">
5670
<div class="flex flex-row gap-3 flex-wrap">
57-
<h2>{docType.name}</h2>
71+
{docType.deprecated ? <h2 class="opacity-50 line-through">{docType.name}</h2> : <h2>{docType.name}</h2>}
72+
{[docType.deprecated].filter(x => x).map(x => <DocsFiche text="Deprecated" color="520f0f"/>)}
5873
{[docType.new].filter(x => x).map(x => <DocsFiche text="New" color="B10003"/>)}
5974

6075
<DocsFiche text={docType.type} color={color()}/>
@@ -67,7 +82,7 @@ function color(): string {
6782
</svg>
6883
</button>
6984
</div>
70-
{docType.description.map((line: string) => <p><Fragment set:html={line}/></p>)}
85+
{docType.description?.map((line: string) => <p><Fragment set:html={line}/></p>)}
7186
</div>
7287

7388
{[docType.patterns]
@@ -76,10 +91,11 @@ function color(): string {
7691

7792
<div>
7893
<DocData text="Since" value={docType.since}/>
94+
<DocData text="Cancellable" value={docType.cancellable != null ? (docType.cancellable ? "Yes" : "No") : null}/>
7995
<DocData text="Requirements" value={docType.requirements}/>
80-
<DocData text="Event values" value={docType.eventValues}/>
96+
<DocData text="Event values" value={docType.eventValues?.map(x => x.name.toLowerCase()) ?? null}/>
8197
<DocData text="Supported events" value={docType.events}/>
82-
<DocData text="Returns" value={docType.returnType}/>
98+
<DocData text="Returns" value={docType.returnType?.name ?? null}/>
8399
</div>
84100

85101
{[docType.examples]
@@ -98,5 +114,6 @@ function color(): string {
98114
{[docType.examples]
99115
.filter(x => x !== null)
100116
.map(x => <Code code={`${x?.join("\n")}`} lang="applescript"/>)}
117+
<span class="hidden">{docType.keywords?.filter(x => x)}</span>
101118
</div>
102119
</section>

src/components/docs/Docs.astro

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ const docTypes: Documentation[] = all.map(doc => ({
1818
: [doc.since]).some(since => since?.includes(latest)),
1919
2020
type: type(doc),
21-
since: (doc as any)["since"] || null,
22-
description: (doc as any)["description"] || null,
23-
examples: (doc as any)["examples"] || null,
24-
patterns: (doc as any)["patterns"] || null,
25-
requirements: (doc as any)["requirements"] || null,
26-
eventValues: null,
27-
returnType: (doc as any)["return-type"] || null,
28-
events: (doc as any)["events"] || null,
21+
since: (doc as any)["since"] ?? null,
22+
description: (doc as any)["description"] ?? null,
23+
examples: (doc as any)["examples"] ?? null,
24+
patterns: (doc as any)["patterns"] ?? null,
25+
requirements: (doc as any)["requirements"] ?? null,
26+
eventValues: (doc as any)["eventValues"] ?? null,
27+
returnType: (doc as any)["returnType"] ?? null,
28+
events: (doc as any)["events"] ?? null,
29+
deprecated: (doc as any)["deprecated"] ?? null,
30+
keywords: (doc as any)["keywords"] ?? null,
31+
cancellable: (doc as any)["cancellable"] ?? null
2932
}));
3033
3134
export enum DocType {
@@ -134,7 +137,8 @@ function type(doc: any): DocType {
134137
isNew: syntax.new,
135138
type: syntax.type,
136139
since: syntax.since!!,
137-
name: syntax.name
140+
name: syntax.name,
141+
deprecated: syntax.deprecated
138142
}
139143
})}/>
140144

src/components/docs/DocsSyntax.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Syntax {
77
type: DocType;
88
since: string;
99
name: string;
10+
deprecated: boolean;
1011
}
1112
1213
interface Props {
@@ -18,6 +19,7 @@ const { syntax }: Props = Astro.props;
1819

1920
<a href={`#${syntax.id}`}
2021
data-new={syntax.isNew} data-type={syntax.type} data-since={syntax.since}
21-
class="syntax">
22+
class="syntax"
23+
style={syntax.deprecated ? 'text-decoration: line-through; opacity: 0.5;' : ''}>
2224
{syntax.name}
2325
</a>

0 commit comments

Comments
 (0)