Skip to content
Draft
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
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ jobs:
- name: Setup Deno
uses: denoland/setup-deno@main
with:
deno-version: "2.7.11"
deno-version: "2.8.3"

- name: Install deps and generate files
run: deno task setup
- name: Install deps
run: deno ci
working-directory: site/

- name: Generate API reference
run: deno task index-versions && deno task genapi
working-directory: site/

- name: Build site
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- uses: denoland/setup-deno@main
with:
deno-version: "2.7.11"
deno-version: "2.8.3"

- name: Check Formatting
run: deno fmt --check
Expand All @@ -31,7 +31,7 @@ jobs:

- uses: denoland/setup-deno@main
with:
deno-version: "2.7.11"
deno-version: "2.8.3"

- name: Check Links
env:
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/translation-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ jobs:
labels='${{ toJSON(github.event.pull_request.labels.*.name) }}'
language_labels=(":es: ES" ":indonesia: ID" ":cn: ZH" ":ukraine: UK")


has_label() {
[ `echo $labels | jq -rcM ". | index(\"$1\")"` != "null" ]
}


if ! has_label "time-sensitive" && has_label "ready for translation"; then
if has_label "time-sensitive" || has_label "not translatable" ; then
exit 0
fi

if has_label "ready for translation"; then
for language_label in "${language_labels[@]}"; do
if ! has_label "$language_label"; then
echo "Missing language label: $language_label"
exit 1
fi
done
elif ! has_label "not translatable"; then
echo "The pull request must at least have one of the following labels: ready for translation, time-sensitive, not translatable"
exit 1
fi
exit 0
if

echo "The pull request must at least have one of the following labels: ready for translation, time-sensitive, not translatable"
exit 1
29 changes: 4 additions & 25 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Dependency directories
# deps
node_modules/
yarn.lock
pnpm-lock.yaml

# Caches
.temp
.cache
cache/
.link-checker

# dist directory
dist/

# generated API reference files
docs/ref/
!docs/ref/README.md

# build output
docs/.vitepress/dist
29 changes: 16 additions & 13 deletions site/api/api_gen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { Class } from "./components/Class.tsx";
import { Function } from "./components/Function.tsx";
import {
type DocNode,
DocNodeClass,
DocNodeFunction,
DocNodeNamespace,
} from "@deno/doc/types";
type DocNodeClass,
type DocNodeFunction,
type DocNodeNamespace,
flattenSymbols,
} from "./types.ts";
import { ToC } from "./components/ToC.tsx";
import { JSX } from "preact/jsx-runtime";
import { Interface } from "./components/Interface.tsx";
Expand Down Expand Up @@ -61,7 +62,8 @@ const refs = await Promise.all(paths.map(
async (
[id, path, slug, name, description, shortdescription],
): Promise<Ref> => {
const nodes = Object.values(await doc([id], { load: cache.load })).flat();
const nodes = Object.values(await doc([id], { load: cache.load }))
.flatMap((d) => flattenSymbols(d.symbols));
Deno.stdout.writeSync(dot);
return [
nodes.sort((a, b) => a.name.localeCompare(b.name)),
Expand All @@ -81,7 +83,7 @@ function namespaceGetLink(
getLink: (typeRef: string) => string | null,
): typeof getLink {
return (typeRef) => {
const node_ = namespace.namespaceDef.elements.find((v) =>
const node_ = flattenSymbols(namespace.def.elements).find((v) =>
v.name == typeRef && LINKABLE_KINDS.has(v.kind)
);
if (node_ !== undefined) {
Expand Down Expand Up @@ -269,20 +271,21 @@ for (const [nodes, path_, slug, name, description] of refs) {

for (const node of nodes) {
if (node.kind == "namespace") {
for (const el of node.namespaceDef.elements) {
const namespaceEls = flattenSymbols(node.def.elements);
for (const el of namespaceEls) {
createDoc(
el,
path.join(path_, node.name),
namespaceGetLink(slug, node, getLink),
slug,
undefined,
((el.kind == "class" && el.classDef.extends !== undefined)
? node.namespaceDef.elements.find((v) =>
((el.kind == "class" && el.def.extends !== undefined)
? namespaceEls.find((v) =>
v.kind == "class" &&
v.name == (el as DocNodeClass).classDef.extends
v.name == (el as DocNodeClass).def.extends
) ?? allNodes.find((v) =>
v.kind == "class" &&
v.name == (el as DocNodeClass).classDef.extends
v.name == (el as DocNodeClass).def.extends
)
: undefined) as DocNodeClass | undefined,
getOverloadCount(node, nodes),
Expand All @@ -299,10 +302,10 @@ for (const [nodes, path_, slug, name, description] of refs) {
? nodes.filter((v): v is DocNodeNamespace => v.kind == "namespace")
.find((v) => v.name == node.name)
: undefined,
((node.kind == "class" && node.classDef.extends !== undefined)
((node.kind == "class" && node.def.extends !== undefined)
? allNodes.find((v) =>
v.kind == "class" &&
v.name == (node as DocNodeClass).classDef.extends
v.name == (node as DocNodeClass).def.extends
)
: undefined) as DocNodeClass | undefined,
getOverloadCount(node, nodes),
Expand Down
32 changes: 15 additions & 17 deletions site/api/components/Class.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
type ClassConstructorParamDef,
type ClassMethodDef,
type ClassPropertyDef,
type DocNodeClass,
type JsDocTag,
type ParamIdentifierDef,
} from "@deno/doc/types";
import { type DocNodeClass } from "../types.ts";
import { Method } from "./Class/Method.tsx";
import { Properties } from "./Properties.tsx";
import { Constructors } from "./Class/Constructors.tsx";
Expand Down Expand Up @@ -34,9 +34,9 @@ export function Class(
parent: DocNodeClass | undefined;
},
) {
const typeParams = klass.classDef.typeParams;
const ctors = klass.classDef.constructors;
const props = klass.classDef.properties.filter(isVisible).concat(
const typeParams = klass.def.typeParams ?? [];
const ctors = klass.def.constructors ?? [];
const props = (klass.def.properties ?? []).filter(isVisible).concat(
// display properties defined in the constructor
ctors.flatMap((v) =>
v.params
Expand All @@ -45,20 +45,18 @@ export function Class(
(p.accessibility === "public" || p.accessibility === "protected")
)
.map((p): ClassPropertyDef => ({
isAbstract: false,
isStatic: false,
readonly: false,
location: v.location,
jsDoc: {
doc: v.jsDoc?.tags?.find((t): t is JsDocTag & { kind: "param" } =>
t.kind === "param" && t.name === p.name
)?.doc,
},
...p,
optional: p.optional || undefined,
}))
),
);
const nonPrivateMethods = klass.classDef.methods.filter(isVisible);
const nonPrivateMethods = (klass.def.methods ?? []).filter(isVisible);
const methods = nonPrivateMethods.filter((v) => !v.isStatic);
const staticMethods = nonPrivateMethods.filter((v) => v.isStatic);
const getLink = newGetLink(oldGetLink, typeParams);
Expand All @@ -80,20 +78,20 @@ export function Class(
<H1>{klass.name}</H1>
<P doc getLink={getLink} anchors={anchors}>{klass.jsDoc?.doc}</P>
<Loc>{klass}</Loc>
<Sector title="Extends" show={!!klass.classDef.extends}>
<Sector title="Extends" show={!!klass.def.extends}>
<CodeBlock>
<TypeRef getLink={getLink}>
{{
typeName: klass.classDef.extends!,
typeParams: klass.classDef.superTypeParams,
typeName: klass.def.extends!,
typeParams: klass.def.superTypeParams,
}}
</TypeRef>
</CodeBlock>
</Sector>
<Sector title="Implements" show={klass.classDef.implements.length > 0}>
<Sector title="Implements" show={(klass.def.implements?.length ?? 0) > 0}>
<CodeBlock>
{klass.classDef.implements.length > 0 &&
klass.classDef.implements.map((v) => (
{(klass.def.implements?.length ?? 0) > 0 &&
klass.def.implements!.map((v) => (
<TsType getLink={getLink}>{v}</TsType>
)).reduce((a, b) => (
(
Expand All @@ -106,7 +104,7 @@ export function Class(
</CodeBlock>
</Sector>
<Sector title="Type Parameters" show={!!typeParams.length}>
<TypeParams getLink={getLink}>{typeParams}</TypeParams>
<TypeParams typeParams={typeParams} getLink={getLink} />
</Sector>
<Sector title="Constructors" show={!!ctors.length}>
<Constructors getLink={getLink}>
Expand All @@ -132,7 +130,7 @@ export function Class(
<Method
getLink={getLink}
inheritDoc={() =>
parent?.classDef.methods.find((v_) =>
parent?.def.methods?.find((v_) =>
(v_.name == v.name) && !v_.isStatic
)?.jsDoc}
overloads={getMethodOverloads(v.name)}
Expand All @@ -154,7 +152,7 @@ export function Class(
<Method
getLink={getLink}
inheritDoc={() =>
parent?.classDef.methods.find((v_) =>
parent?.def.methods?.find((v_) =>
(v_.name == v.name) && v_.isStatic
)?.jsDoc}
overloads={getStaticMethodOverloads(v.name)}
Expand Down
24 changes: 8 additions & 16 deletions site/api/components/Class/Method.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
ClassMethodDef,
DocNodeFunction,
InterfaceMethodDef,
JsDoc,
} from "@deno/doc/types";
import { ClassMethodDef, InterfaceMethodDef, JsDoc } from "@deno/doc/types";
import { type DocNodeFunction } from "../../types.ts";
import { Params, TsType, TypeParams_ } from "../TsType.tsx";
import { LinkGetter } from "../types.ts";
import { CodeBlock } from "../CodeBlock.tsx";
Expand Down Expand Up @@ -61,14 +57,12 @@ export function Def(
getLink: LinkGetter;
},
) {
const typeParams = "functionDef" in method
? method.functionDef.typeParams
const typeParams = "def" in method
? method.def.typeParams
: method.typeParams;
const params = "functionDef" in method
? method.functionDef.params
: method.params;
const returnType = "functionDef" in method
? method.functionDef.returnType
const params = "def" in method ? method.def.params : method.params;
const returnType = "def" in method
? method.def.returnType
: method.returnType;
return (
<>
Expand All @@ -90,9 +84,7 @@ export function Def(
<span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">
{method.name}
</span>
<TypeParams_ getLink={getLink}>
{typeParams}
</TypeParams_>(
<TypeParams_ params={typeParams} getLink={getLink} />(
<Params getLink={getLink}>{params}</Params>)
{returnType
? (
Expand Down
12 changes: 6 additions & 6 deletions site/api/components/Function.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocNodeFunction } from "@deno/doc/types";
import { type DocNodeFunction } from "../types.ts";
import { LinkGetter } from "./types.ts";
import { H1 } from "./H1.tsx";
import { H2 } from "./H2.tsx";
Expand All @@ -21,8 +21,8 @@ export function Function(
overloadCount?: number;
},
) {
const params = func.functionDef.params;
const typeParams = func.functionDef.typeParams;
const params = func.def.params;
const typeParams = func.def.typeParams ?? [];
const getLink = newGetLink(oldGetLink, typeParams);

return (
Expand Down Expand Up @@ -72,18 +72,18 @@ export function Function(
show={!!typeParams.length}
h3={!!overloadCount}
>
<TypeParams getLink={getLink}>{typeParams}</TypeParams>
<TypeParams typeParams={typeParams} getLink={getLink} />
</Sector>
<Sector title="Parameters" show={!!params.length} h3={!!overloadCount}>
<Parameters getLink={getLink} doc={func.jsDoc}>{params}</Parameters>
</Sector>
<Sector
title="Return Type"
show={!!func.functionDef.returnType}
show={!!func.def.returnType}
h3={!!overloadCount}
>
<ReturnType getLink={getLink} doc={func.jsDoc}>
{func.functionDef.returnType!}
{func.def.returnType!}
</ReturnType>
</Sector>
</>
Expand Down
Loading
Loading