Skip to content

Commit d0207c8

Browse files
Generate markdown with scope infos
1 parent c54b645 commit d0207c8

8 files changed

Lines changed: 486 additions & 38 deletions

File tree

data/scopeSupportFacetInfos.md

Lines changed: 408 additions & 0 deletions
Large diffs are not rendered by default.

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export * from "./util/range";
109109
export * from "./util/regex";
110110
export * from "./util/selectionsEqual";
111111
export * from "./util/serializedMarksToTokenHats";
112+
export * from "./util/serializeScopeType";
112113
export * from "./util/splitKey";
113114
export * from "./util/toPlainObject";
114115
export * from "./util/type";

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const scopeSupportFacetInfos: Record<
187187
},
188188
"argument.actual.multiLine": {
189189
description:
190-
"A multiline argument in a function call. Insertion delimiter should include `\n`.",
190+
"A multiline argument in a function call. Insertion delimiter should include new line.",
191191
scopeType: "argumentOrParameter",
192192
},
193193
"argument.actual.iteration": iteration(
@@ -201,7 +201,7 @@ export const scopeSupportFacetInfos: Record<
201201
},
202202
"argument.actual.method.multiLine": {
203203
description:
204-
"A multi line argument in a method call. Insertion delimiter should include `\n`.",
204+
"A multi line argument in a method call. Insertion delimiter should include new line.",
205205
scopeType: "argumentOrParameter",
206206
},
207207
"argument.actual.method.iteration": iteration(
@@ -215,7 +215,7 @@ export const scopeSupportFacetInfos: Record<
215215
},
216216
"argument.actual.constructor.multiLine": {
217217
description:
218-
"A multi line argument in a constructor call. Insertion delimiter should include `\n`.",
218+
"A multi line argument in a constructor call. Insertion delimiter should include new line.",
219219
scopeType: "argumentOrParameter",
220220
},
221221
"argument.actual.constructor.iteration": iteration(
@@ -230,7 +230,7 @@ export const scopeSupportFacetInfos: Record<
230230
},
231231
"argument.formal.multiLine": {
232232
description:
233-
"A multi line parameter in a function declaration. Insertion delimiter should include `\n`.",
233+
"A multi line parameter in a function declaration. Insertion delimiter should include new line.",
234234
scopeType: "argumentOrParameter",
235235
},
236236
"argument.formal.iteration": iteration(
@@ -244,7 +244,7 @@ export const scopeSupportFacetInfos: Record<
244244
},
245245
"argument.formal.method.multiLine": {
246246
description:
247-
"A multi line parameter in a class method declaration. Insertion delimiter should include `\n`.",
247+
"A multi line parameter in a class method declaration. Insertion delimiter should include new line.",
248248
scopeType: "argumentOrParameter",
249249
},
250250
"argument.formal.method.iteration": iteration(
@@ -259,7 +259,7 @@ export const scopeSupportFacetInfos: Record<
259259
},
260260
"argument.formal.constructor.multiLine": {
261261
description:
262-
"A multi line parameter in a constructor declaration. Insertion delimiter should include `\n`.",
262+
"A multi line parameter in a constructor declaration. Insertion delimiter should include new line.",
263263
scopeType: "argumentOrParameter",
264264
},
265265
"argument.formal.constructor.iteration": iteration(
@@ -273,7 +273,7 @@ export const scopeSupportFacetInfos: Record<
273273
},
274274
"argument.formal.lambda.multiLine": {
275275
description:
276-
"A multi line parameter in a lambda declaration. Insertion delimiter should include `\n`.",
276+
"A multi line parameter in a lambda declaration. Insertion delimiter should include new line.",
277277
scopeType: "argumentOrParameter",
278278
},
279279
"argument.formal.lambda.iteration": iteration(
@@ -297,7 +297,7 @@ export const scopeSupportFacetInfos: Record<
297297
},
298298
"argumentList.actual.multiLine": {
299299
description:
300-
"A multi line list of arguments in a function call. Insertion delimiter should include `\n`.",
300+
"A multi line list of arguments in a function call. Insertion delimiter should include new line.",
301301
scopeType: "argumentList",
302302
},
303303
"argumentList.actual.method.empty": {
@@ -311,7 +311,7 @@ export const scopeSupportFacetInfos: Record<
311311
},
312312
"argumentList.actual.method.multiLine": {
313313
description:
314-
"A multi line list of arguments in a method call. Insertion delimiter should include `\n`.",
314+
"A multi line list of arguments in a method call. Insertion delimiter should include new line.",
315315
scopeType: "argumentList",
316316
},
317317
"argumentList.actual.constructor.empty": {
@@ -325,7 +325,7 @@ export const scopeSupportFacetInfos: Record<
325325
},
326326
"argumentList.actual.constructor.multiLine": {
327327
description:
328-
"A multi line list of arguments in a constructor call. Insertion delimiter should include `\n`.",
328+
"A multi line list of arguments in a constructor call. Insertion delimiter should include new line.",
329329
scopeType: "argumentList",
330330
},
331331

@@ -340,7 +340,7 @@ export const scopeSupportFacetInfos: Record<
340340
},
341341
"argumentList.formal.multiLine": {
342342
description:
343-
"A multi line list of parameters in a function declaration. Insertion delimiter should include `\n`.",
343+
"A multi line list of parameters in a function declaration. Insertion delimiter should include new line.",
344344
scopeType: "argumentList",
345345
},
346346
"argumentList.formal.lambda.empty": {
@@ -354,7 +354,7 @@ export const scopeSupportFacetInfos: Record<
354354
},
355355
"argumentList.formal.lambda.multiLine": {
356356
description:
357-
"A multi line list of parameters in a lambda declaration. Insertion delimiter should include `\n`.",
357+
"A multi line list of parameters in a lambda declaration. Insertion delimiter should include new line.",
358358
scopeType: "argumentList",
359359
},
360360
"argumentList.formal.method.empty": {
@@ -369,7 +369,7 @@ export const scopeSupportFacetInfos: Record<
369369
},
370370
"argumentList.formal.method.multiLine": {
371371
description:
372-
"A multi line list of parameters in a class method declaration. Insertion delimiter should include `\n`.",
372+
"A multi line list of parameters in a class method declaration. Insertion delimiter should include new line.",
373373
scopeType: "argumentList",
374374
},
375375
"argumentList.formal.constructor.empty": {
@@ -384,7 +384,7 @@ export const scopeSupportFacetInfos: Record<
384384
},
385385
"argumentList.formal.constructor.multiLine": {
386386
description:
387-
"A multi line list of parameters in a constructor declaration. Insertion delimiter should include `\n`.",
387+
"A multi line list of parameters in a constructor declaration. Insertion delimiter should include new line.",
388388
scopeType: "argumentList",
389389
},
390390

@@ -1003,7 +1003,7 @@ function iteration(
10031003
const description =
10041004
desc != null
10051005
? `Iteration scope for ${label}: ${desc}.`
1006-
: `Iteration scope for ${label}.`;
1006+
: `Iteration scope for ${label}`;
10071007
return {
10081008
description,
10091009
scopeType,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type {
2+
ScopeType,
3+
SimpleScopeTypeType,
4+
} from "../types/command/PartialTargetDescriptor.types";
5+
6+
export function serializeScopeType(
7+
scopeType: SimpleScopeTypeType | ScopeType,
8+
): string {
9+
if (typeof scopeType === "string") {
10+
return scopeType;
11+
}
12+
return scopeType.type;
13+
}

packages/cursorless-org-docs/src/docs/contributing/MissingLanguageScopes.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import {
33
scopeSupportFacetInfos,
44
ScopeSupportFacetLevel,
55
scopeSupportFacets,
6+
serializeScopeType,
67
type ScopeSupportFacet,
7-
type ScopeType,
8-
type SimpleScopeTypeType,
98
} from "@cursorless/common";
109
import React, { useState } from "react";
1110

@@ -122,12 +121,3 @@ function facetsToScopes(facets: ScopeSupportFacet[], showPrivate: boolean) {
122121
.filter((scope) => showPrivate || !scope.startsWith("private."))
123122
.sort();
124123
}
125-
126-
function serializeScopeType(
127-
scopeType: SimpleScopeTypeType | ScopeType,
128-
): string {
129-
if (typeof scopeType === "string") {
130-
return scopeType;
131-
}
132-
return scopeType.type;
133-
}

packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import {
22
camelCaseToAllDown,
33
capitalize,
44
groupBy,
5+
scopeSupportFacetInfos,
6+
serializeScopeType,
57
type ScopeSupportFacet,
68
type ScopeSupportFacetInfo,
7-
scopeSupportFacetInfos,
8-
type ScopeType,
9-
type SimpleScopeTypeType,
109
} from "@cursorless/common";
1110
import React, { useState, type JSX } from "react";
1211

@@ -114,12 +113,3 @@ function prettifyFacet(facet: ScopeSupportFacet): string {
114113
const name = capitalize(parts.slice(1).join(" "));
115114
return isIteration ? `${name} (iteration)` : name;
116115
}
117-
118-
function serializeScopeType(
119-
scopeType: SimpleScopeTypeType | ScopeType,
120-
): string {
121-
if (typeof scopeType === "string") {
122-
return scopeType;
123-
}
124-
return scopeType.type;
125-
}

packages/meta-updater/src/metaUpdater.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { textFormat } from "./textFormat";
1010
import { updateLanguageMdxConfig } from "./updateLanguageScopeSupportConfig";
1111
import { updatePackageJson } from "./updatePackageJson";
1212
import { updateTSConfig } from "./updateTSConfig";
13+
import { updatesScopeSupportFacetInfos } from "./updatesScopeSupportFacetInfos";
1314

1415
export const updater = async (workspaceDir: string) => {
1516
const pnpmLockfile = await readWantedLockfile(workspaceDir, {
@@ -29,6 +30,7 @@ export const updater = async (workspaceDir: string) => {
2930
files: {
3031
["package.json"]: updatePackageJson.bind(null, context),
3132
["tsconfig.json"]: updateTSConfig.bind(null, context),
33+
["data/scopeSupportFacetInfos.md"]: updatesScopeSupportFacetInfos,
3234
...Object.fromEntries(
3335
Object.keys(languageScopeSupport).map((languageId) => {
3436
return [
@@ -39,6 +41,7 @@ export const updater = async (workspaceDir: string) => {
3941
),
4042
},
4143
formats: {
44+
md: textFormat,
4245
mdx: textFormat,
4346
},
4447
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import {
2+
scopeSupportFacetInfos,
3+
serializeScopeType,
4+
textualScopeSupportFacetInfos,
5+
type ScopeSupportFacet,
6+
type TextualScopeSupportFacet,
7+
} from "@cursorless/common";
8+
import type { FormatPluginFnOptions } from "@pnpm/meta-updater";
9+
10+
export function updatesScopeSupportFacetInfos(
11+
actual: string | null,
12+
options: FormatPluginFnOptions,
13+
): string | null {
14+
if (actual == null) {
15+
return null;
16+
}
17+
18+
const facetsInfos = {
19+
...scopeSupportFacetInfos,
20+
...textualScopeSupportFacetInfos,
21+
};
22+
23+
const facets = Object.keys(facetsInfos).sort();
24+
const rows: string[] = [];
25+
let currentScopeType: string | null = null;
26+
27+
for (const facet of facets) {
28+
const facetInfo =
29+
facetsInfos[facet as ScopeSupportFacet | TextualScopeSupportFacet];
30+
const scopeType = serializeScopeType(facetInfo.scopeType);
31+
if (scopeType !== currentScopeType) {
32+
if (currentScopeType !== null) {
33+
rows.push("");
34+
}
35+
currentScopeType = scopeType;
36+
rows.push(`### ${currentScopeType}`);
37+
rows.push("");
38+
}
39+
rows.push(`- \`${facet}\` ${facetInfo.description}`);
40+
}
41+
42+
return rows.join("\n");
43+
}

0 commit comments

Comments
 (0)