Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for conversations 2.0 #1147

Open
wants to merge 103 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
f2dd0ea
Add first half of docs for conversations v2.x
KnorpelSenf Nov 9, 2024
b5dc3d3
delete translations
KnorpelSenf Nov 9, 2024
3876f66
Delay custom serialization
KnorpelSenf Nov 9, 2024
6f26a31
Drop .md extension from link
KnorpelSenf Nov 9, 2024
7f0fa22
Fix other links pointing to conversations
KnorpelSenf Nov 9, 2024
8fe2396
Drop .md from link
KnorpelSenf Nov 9, 2024
21b001c
Parse JSDoc symbol links
rojvv Nov 9, 2024
c19b1fa
add more docs
KnorpelSenf Nov 9, 2024
410cd11
Fix CI
rojvv Nov 9, 2024
db1de3d
more docs
KnorpelSenf Nov 10, 2024
deaa8c4
drop empty block
KnorpelSenf Nov 10, 2024
6abbcfe
fix fmt
KnorpelSenf Nov 10, 2024
5689d92
Fix https://672fe363b05111d4046671a8--grammy.netlify.app/ref/conversa…
rojvv Nov 10, 2024
bef0aa4
Fix https://672f8576aeb49a665f912876--grammy.netlify.app/ref/conversa…
rojvv Nov 11, 2024
f26931f
Fix https://672fe363b05111d4046671a8--grammy.netlify.app/ref/conversa…
rojvv Nov 11, 2024
2b69e23
done with the first iteration
KnorpelSenf Nov 12, 2024
c9d5f3f
fix link
KnorpelSenf Nov 12, 2024
c364974
Merge branch 'main' into conversations-2.0
KnorpelSenf Nov 12, 2024
47de810
fix anchor
KnorpelSenf Nov 12, 2024
a01565d
Apply suggestions from code review
KnorpelSenf Nov 12, 2024
2da4a74
fix typo
KnorpelSenf Nov 12, 2024
f523cc7
add example for storage adapter types
KnorpelSenf Nov 12, 2024
9623709
Apply suggestions from code review
KnorpelSenf Nov 13, 2024
fd4618e
fix fmt
KnorpelSenf Nov 13, 2024
956ac45
fix links
KnorpelSenf Nov 13, 2024
da5f089
fix confusion
KnorpelSenf Nov 13, 2024
06b03a2
Merge branch 'main' into conversations-2.0
KnorpelSenf Nov 13, 2024
a4e6e88
@NormandoHall is right, it should be `ctx2`
KnorpelSenf Nov 13, 2024
bb0356b
Describe storage namespaces
KnorpelSenf Nov 13, 2024
32d6a41
fix link
KnorpelSenf Nov 13, 2024
ed55de9
Merge branch 'main' into conversations-2.0
MasedMSD Nov 17, 2024
3adf49c
Merge branch 'main' into conversations-2.0
KnorpelSenf Nov 18, 2024
7a1f419
Add link
KnorpelSenf Nov 19, 2024
213ad24
Oxford comma
KnorpelSenf Nov 19, 2024
59ddbee
that which
KnorpelSenf Nov 19, 2024
67919a0
token comment
KnorpelSenf Nov 19, 2024
2000c59
Merge branch 'main' into conversations-2.0
KnorpelSenf Nov 21, 2024
0f35aea
Add type example
KnorpelSenf Nov 21, 2024
f0cd99b
Add colon
KnorpelSenf Nov 21, 2024
f949a8e
Drop bad in
KnorpelSenf Nov 21, 2024
ad4386d
Fix convo name
KnorpelSenf Nov 21, 2024
31e48ca
Refer to existing conversations
KnorpelSenf Nov 21, 2024
7d80062
Fix build
rojvv Nov 21, 2024
0a4e6a4
Fix build
rojvv Nov 21, 2024
9a41cc5
Fix docs
rojvv Nov 21, 2024
5bd0a59
Fix a last bunch of things
KnorpelSenf Nov 21, 2024
c187f62
Fix apigen
rojvv Nov 21, 2024
50f71ca
Merge branch 'conversations-2.0' of github.com:grammyjs/website into …
rojvv Nov 21, 2024
49b5dba
fmt
rojvv Nov 21, 2024
207e375
Fix apigen
rojvv Nov 21, 2024
b025bce
Drop extension
KnorpelSenf Nov 22, 2024
c038ce7
wip(id): continue from line 257
quadratz Nov 23, 2024
e7ea756
add missing space
KnorpelSenf Nov 24, 2024
407d57e
Suggest improvement to convo plugin docs (#1160)
KnorpelSenf Nov 24, 2024
13bf2f2
Yet another space
KnorpelSenf Nov 25, 2024
67973e9
oh
KnorpelSenf Nov 25, 2024
cb9dc83
oops
KnorpelSenf Nov 25, 2024
09cbc99
thanks
KnorpelSenf Nov 25, 2024
9330611
typo fix
KnorpelSenf Nov 25, 2024
b6d83e0
sync to Ukrainian
niusia-ua Nov 25, 2024
1522b02
fix uk header
KnorpelSenf Nov 25, 2024
2e64a38
Merge branch 'main' into conversations-2.0
KnorpelSenf Nov 25, 2024
5701801
wip(id): continue from line 378
quadratz Nov 26, 2024
82dd28d
Update site/docs/plugins/conversations.md
quadratz Nov 26, 2024
76531c4
Fix bad sentence
KnorpelSenf Nov 26, 2024
10629c5
wip(id): continue from line 704
quadratz Nov 27, 2024
736434a
wip(id): continue from line 964
quadratz Nov 28, 2024
c2b9429
Fix typo `exmaple`
quadratz Nov 30, 2024
3946bea
do not miss any update
KnorpelSenf Nov 30, 2024
044abfd
Update site/docs/plugins/conversations.md
KnorpelSenf Dec 1, 2024
c8b82fd
ru: sync to 371
MasedMSD Dec 2, 2024
25ae895
Make comment usage consistent
KnorpelSenf Dec 4, 2024
d4d6149
Add Spanish
habemuscode Dec 4, 2024
2506c3b
Merge branch 'conversations-2.0' of github.com:grammyjs/website into …
habemuscode Dec 4, 2024
8568338
Fix spanish link and lint
habemuscode Dec 4, 2024
b920d6e
Typo in list
habemuscode Dec 4, 2024
8e6aa0e
Merge branch 'main' into conversations-2.0
KnorpelSenf Dec 5, 2024
d1ea669
wip(id): continue from line 1324
quadratz Dec 9, 2024
fb95baf
wip(id): 887
quadratz Dec 12, 2024
b0ea95e
Update site/docs/plugins/conversations.md
quadratz Dec 14, 2024
b073198
Merge branch 'main' into conversations-2.0
KnorpelSenf Dec 14, 2024
a702d02
Sync changes to Indonesian
quadratz Dec 21, 2024
8d57223
Merge branch 'main' into conversations-2.0
KnorpelSenf Dec 21, 2024
555bd62
Merge branch 'conversations-2.0' of https://github.com/grammyjs/websi…
MasedMSD Dec 21, 2024
61fdd44
ru: sync to 511 line
MasedMSD Dec 21, 2024
0ef6a2d
Merge branch 'main' into conversations-2.0
LWJerri Dec 24, 2024
f735846
Merge branch 'main' into conversations-2.0
KnorpelSenf Dec 24, 2024
f7a5199
ru: sync to 1016 line
MasedMSD Jan 5, 2025
48d2f78
Merge branch 'main' into conversations-2.0
MasedMSD Jan 5, 2025
ad6ce5d
fix fmt and links
MasedMSD Jan 5, 2025
9a8495d
Merge branch 'conversations-2.0' of https://github.com/grammyjs/websi…
MasedMSD Jan 5, 2025
f0fa79b
fix links
MasedMSD Jan 5, 2025
ad6eaf1
sync Russian
MasedMSD Jan 6, 2025
c14cafb
fix fmt & links
MasedMSD Jan 6, 2025
4d67db5
ru: little fixes
MasedMSD Jan 8, 2025
5ebb115
Merge branch 'main' into conversations-2.0
LWJerri Jan 13, 2025
9821387
Merge branch 'main' into conversations-2.0
KnorpelSenf Jan 13, 2025
e8f6848
build: rebuild
KnorpelSenf Jan 15, 2025
1679eb6
Revert "build: rebuild"
KnorpelSenf Jan 15, 2025
ce50e3a
Apply suggestions from code review
niusia-ua Jan 16, 2025
3ad8dfa
uk: fix links
niusia-ua Jan 16, 2025
6cf85ec
Merge branch 'main' into conversations-2.0
KnorpelSenf Jan 17, 2025
3d813be
fix: bad merge
KnorpelSenf Jan 17, 2025
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
4 changes: 3 additions & 1 deletion site/api/components/Class.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ export function Class(

const methodNameSet = new Set<string>(); // to prevent duplicates
const staticMethodNameSet = new Set<string>();
const anchors = methods.map((v) => v.name)
.concat(staticMethods.map((v) => v.name));

return (
<>
<H1>{klass.name}</H1>
<P doc>{klass.jsDoc?.doc}</P>
<P doc getLink={getLink} anchors={anchors}>{klass.jsDoc?.doc}</P>
<Loc>{klass}</Loc>
<Sector title="Extends" show={!!klass.classDef.extends}>
<CodeBlock>
Expand Down
2 changes: 1 addition & 1 deletion site/api/components/Class/Constructors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function Constructors({
</span>(
<Params getLink={getLink}>{v.params}</Params>);
</CodeBlock>
{"jsDoc" in v && <P doc>{v.jsDoc?.doc}</P>}
{"jsDoc" in v && <P doc getLink={getLink}>{v.jsDoc?.doc}</P>}
<Loc>{v}</Loc>
</>
))}
Expand Down
2 changes: 1 addition & 1 deletion site/api/components/Class/Method.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function Method({
</>
))}
</CodeBlock>
<P doc>{jsDoc?.doc}</P>
<P doc getLink={getLink}>{jsDoc?.doc}</P>
<Loc>{method}</Loc>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions site/api/components/Function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function Function(
return (
<>
{(!overloadCount || overloadCount == 1) && <H1>{func.name}</H1>}
{overloadCount && <P doc>{func.jsDoc?.doc}</P>}
{overloadCount && <P doc getLink={getLink}>{func.jsDoc?.doc}</P>}
{!!overloads?.length && (
<CodeBlock>
//{" "}
Expand Down Expand Up @@ -65,7 +65,7 @@ export function Function(
</CodeBlock>
)}
{overloadCount && <H2>Overload {overloadCount}</H2>}
{!overloadCount && <P doc>{func.jsDoc?.doc}</P>}
{!overloadCount && <P doc getLink={getLink}>{func.jsDoc?.doc}</P>}
<Loc>{func}</Loc>
<Sector
title="Type Parameters"
Expand Down
2 changes: 1 addition & 1 deletion site/api/components/Function/Parameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function Parameters(
<CodeBlock>
<Param getLink={getLink}>{v}</Param>
</CodeBlock>
<P doc>
<P doc getLink={getLink}>
{doc?.tags?.find((v_): v_ is JsDocTagParam =>
v_.kind == "param" && v_.name == getTitle(v)
)?.doc}
Expand Down
2 changes: 1 addition & 1 deletion site/api/components/Function/ReturnType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function ReturnType(
<CodeBlock>
<TsType getLink={getLink}>{ret}</TsType>
</CodeBlock>
<P doc>
<P doc getLink={getLink}>
{doc?.tags?.find((v): v is JsDocTagReturn => v.kind == "return")?.doc}
</P>
</>
Expand Down
70 changes: 70 additions & 0 deletions site/api/components/Indexes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
InterfaceIndexSignatureDef,
ParamIdentifierDef,
} from "deno_doc/types.d.ts";
import { PropertyName } from "./PropertyName.tsx";
import { TsType } from "./TsType.tsx";
import { LinkGetter } from "./types.ts";
import { H3 } from "./H3.tsx";
import { CodeBlock } from "./CodeBlock.tsx";
import { P } from "./P.tsx";
import { StyleKw } from "./styles.tsx";
import { Loc } from "./Loc.tsx";

export function Indexes({
getLink,
children: i,
}: {
getLink: LinkGetter;
children: InterfaceIndexSignatureDef[];
}) {
return (
<>
{i.filter((v) =>
"accessiblity" in v ? v.accessiblity !== "private" : true
)
.map((v) => (
<>
<H3>
[{(v.params[0] as ParamIdentifierDef).name}:{" "}
{v.params[0].tsType?.repr}]
</H3>
<CodeBlock>
{"isStatic" in v && v.isStatic && <StyleKw>{"static "}</StyleKw>}
{"isAbstract" in v && v.isAbstract && (
<StyleKw>{"abstract "}</StyleKw>
)}
{v.readonly && <StyleKw>{"readonly "}</StyleKw>}
<PropertyName hasType={!!v.tsType} class>
{{
raw: (
<>
[{(v.params[0] as ParamIdentifierDef).name}
{v.params[0].tsType && (
<>
:{" "}
<TsType getLink={getLink}>
{v.params[0].tsType}
</TsType>
</>
)}]
</>
),
}}
</PropertyName>
{v.tsType && (
<>
{" "}
<TsType getLink={getLink}>{v.tsType}</TsType>
</>
)};
</CodeBlock>
{/* @ts-ignore: it works */}
{"jsDoc" in v && <P doc getLink={getLink}>{v.jsDoc}</P>}
{/* @ts-ignore: this works too */}
<Loc>{v}</Loc>
</>
))}
</>
);
}
7 changes: 6 additions & 1 deletion site/api/components/Interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CodeBlock } from "./CodeBlock.tsx";
import { TsType } from "./TsType.tsx";
import { ToC } from "./ToC.tsx";
import { Method } from "./Class/Method.tsx";
import { Indexes } from "./Indexes.tsx";

export function Interface(
{ children: iface, getLink, namespace }: {
Expand All @@ -19,6 +20,7 @@ export function Interface(
) {
const props = iface.interfaceDef.properties;
const methods = iface.interfaceDef.methods;
const indexes = iface.interfaceDef.indexSignatures;
const methodNameSet = new Set<string>(); // to prevent duplicates

const getMethodOverloads = (name: string) => {
Expand All @@ -28,7 +30,7 @@ export function Interface(
return (
<>
<H1>{iface.name}</H1>
<P doc>{iface.jsDoc?.doc}</P>
<P doc getLink={getLink}>{iface.jsDoc?.doc}</P>
<Loc>{iface}</Loc>
<Sector title="Extends" show={!!iface.interfaceDef.extends.length}>
<CodeBlock>
Expand All @@ -43,6 +45,9 @@ export function Interface(
<Sector title="Properties" show={!!props.length}>
<Properties getLink={getLink}>{props}</Properties>
</Sector>
<Sector title="Indexes" show={!!indexes.length}>
<Indexes getLink={getLink}>{indexes}</Indexes>
</Sector>
<Sector title="Methods" show={!!methods.length}>
{methods
.filter((v) => {
Expand Down
9 changes: 9 additions & 0 deletions site/api/components/P.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { ComponentChildren } from "preact";
import { replaceModuleSymbolLinks } from "./util.ts";
import { LinkGetter } from "./types.ts";

export function P(
props: { children?: ComponentChildren; doc?: false; html?: true } | {
children?: string;
doc: true;
getLink: LinkGetter;
anchors?: string[];
},
) {
if (props.doc && props.children) {
Expand All @@ -28,6 +32,11 @@ export function P(
props.children = newParts
.join("")
.replaceAll("```ts", "```ts:no-line-numbers");
props.children = replaceModuleSymbolLinks(
props.children,
props.getLink,
props.anchors,
);
return (
<>
{"\n\n"}
Expand Down
2 changes: 1 addition & 1 deletion site/api/components/Properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function Properties({
</>
)};
</CodeBlock>
{"jsDoc" in v && <P doc>{v.jsDoc?.doc}</P>}
{"jsDoc" in v && <P doc getLink={getLink}>{v.jsDoc?.doc}</P>}
<Loc>{v}</Loc>
</>
))}
Expand Down
8 changes: 5 additions & 3 deletions site/api/components/PropertyName.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
export function PropertyName({
children: { name, optional },
children,
hasType,
"class": klass,
}: {
children: { name: string; optional: boolean };
// deno-lint-ignore no-explicit-any
children: { name: string; optional: boolean } | { raw: any };
hasType: boolean;
class?: true;
}) {
const optional = "raw" in children ? false : children.optional;
return (
<>
<span style={klass ? "" : "--shiki-light:#24292E;--shiki-dark:#E1E4E8;"}>
{name}
{"raw" in children ? children.raw : children.name}
</span>
{(optional || hasType) && (
<span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">
Expand Down
9 changes: 8 additions & 1 deletion site/api/components/TsType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,16 @@ function ParamArray({
optional: boolean;
getLink: LinkGetter;
}) {
const elements = param.elements.map((e) =>
e && <Param getLink={getLink}>{e}</Param>
);
let elementsElement: JSX.Element | undefined;
if (elements.length) {
elementsElement = elements.reduce((a, b) => <>{a}, {b}</>);
}
return (
<>
[{param.elements.map((e) => e && <Param getLink={getLink}>{e}</Param>)}]
[{elementsElement || elements}]
{param.optional || optional ? "?" : ""}
{param.tsType && (
<>
Expand Down
2 changes: 1 addition & 1 deletion site/api/components/TypeAlias.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function TypeAlias(
return (
<>
<H1>{typeAlias.name}</H1>
<P doc>{typeAlias.jsDoc?.doc}</P>
<P doc getLink={getLink}>{typeAlias.jsDoc?.doc}</P>
<Loc>{typeAlias}</Loc>
<Sector title="Type Parameters" show={!!typeParams.length}>
<TypeParams getLink={getLink}>{typeParams}</TypeParams>
Expand Down
2 changes: 1 addition & 1 deletion site/api/components/Variable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function Variable(
return (
<>
<H1>{varr.name}</H1>
<P doc>{varr.jsDoc?.doc}</P>
<P doc getLink={getLink}>{varr.jsDoc?.doc}</P>
<Loc>{varr}</Loc>
<Sector title="Type" show={!!varr.variableDef.tsType}>
<CodeBlock>
Expand Down
83 changes: 83 additions & 0 deletions site/api/components/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TsTypeParamDef } from "deno_doc/types.d.ts";
import { LinkGetter } from "./types.ts";

export function newGetLink(
oldGetLink: (r: string) => string | null,
Expand All @@ -14,3 +15,85 @@ export function newGetLink(
return l;
};
}

export function replaceModuleSymbolLinks(
text: string,
getLink: LinkGetter,
anchors: string[] | undefined,
) {
return replaceSymbolLinks(text, (match) => {
let [link, text = ""] = match.split("|");
text = text.trim();
const [symbol, anchor] = link.trim().split(".");
let href: string;
if (anchors?.includes(symbol)) {
href = `#${symbol}`;
} else {
href = getLink(symbol) ?? "";
if (anchor) {
href += `#${anchor}`;
}
}
href = href.toLowerCase();
return `[${text || match}](${href})`;
});
}
function replaceSymbolLinks(
text: string,
replacer: (string: string) => string,
) {
let newText = "";
let stackActive = false;
let stackExpects: "keyword" | "value" = "keyword";
let stack = new Array<string>();
let value = "";

const flushStack = () => {
stackExpects = "keyword";
stackActive = false;
value = "";
for (const item of stack) {
newText += item;
}
stack = [];
};

for (let i = 0; i < text.length; ++i) {
const char = text[i];
const prevChar = text[i - 1] || "";
if (char == "{" && prevChar != "\\") {
stackActive = true;
stack.push(char);
continue;
}
if (stackActive) {
stack.push(char);
} else {
newText += char;
}
if (stackActive && stackExpects == "keyword") {
if (/\s/.test(char)) {
continue;
}
if (text.slice(i, i + "@link ".length) != "@link ") {
flushStack();
} else {
stackExpects = "value";
i += "@link ".length - 1;
continue;
}
}
if (stackExpects == "value" && char == "}" && prevChar != "\\") {
value = value.trim();
newText += replacer(value);
stack = [];
flushStack();
continue;
}
if (stackExpects == "value") {
value += char;
}
}

return newText;
}
Loading
Loading