Skip to content

Commit c36205d

Browse files
Added community alphabet and symbols to docs (#3332)
Fixes #936
1 parent 77c2d18 commit c36205d

4 files changed

Lines changed: 175 additions & 0 deletions

File tree

‎packages/app-web-docs/sidebarItemsGenerator.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const items: (Group | string)[] = [
2323
"Targets",
2424
"Destinations",
2525
"Paired delimiters",
26+
"Alphabet and symbols",
2627
],
2728
},
2829
"Supported languages",
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Alphabet and symbols
2+
3+
Cursorless uses the [Talon Community](https://github.com/talonhub/community) alphabet, digits, and symbol spoken forms via the [`user.any_alphanumeric_key`](https://github.com/talonhub/community/blob/607c3415f5f29a5f75db6fe5648e37f514f62ac5/core/keys/keys.py#L71-L74) capture.
4+
5+
## Alphabet
6+
7+
| Character | Default spoken form |
8+
| --------- | ------------------- |
9+
| `a` | `air` |
10+
| `b` | `bat` |
11+
| `c` | `cap` |
12+
| `d` | `drum` |
13+
| `e` | `each` |
14+
| `f` | `fine` |
15+
| `g` | `gust` |
16+
| `h` | `harp` |
17+
| `i` | `sit` |
18+
| `j` | `jury` |
19+
| `k` | `crunch` |
20+
| `l` | `look` |
21+
| `m` | `made` |
22+
| `n` | `near` |
23+
| `o` | `odd` |
24+
| `p` | `pit` |
25+
| `q` | `quench` |
26+
| `r` | `red` |
27+
| `s` | `sun` |
28+
| `t` | `trap` |
29+
| `u` | `urge` |
30+
| `v` | `vest` |
31+
| `w` | `whale` |
32+
| `x` | `plex` |
33+
| `y` | `yank` |
34+
| `z` | `zip` |
35+
36+
## Symbols
37+
38+
| Character | Default spoken form |
39+
| --------- | ------------------- |
40+
| `.` | `dot` |
41+
| `,` | `comma` |
42+
| `;` | `semicolon` |
43+
| `:` | `colon` |
44+
| `!` | `bang` |
45+
| `*` | `asterisk` |
46+
| `@` | `at sign` |
47+
| `&` | `ampersand` |
48+
| `?` | `question` |
49+
| `/` | `slash` |
50+
| `\` | `backslash` |
51+
| `-` | `dash` |
52+
| `=` | `equals` |
53+
| `+` | `plus` |
54+
| `~` | `tilde` |
55+
| `_` | `underscore` |
56+
| `#` | `hash` |
57+
| `%` | `percent` |
58+
| `^` | `caret` |
59+
| `\|` | `pipe` |
60+
| `$` | `dollar` |
61+
| `£` | `pound` |
62+
| `'` | `quote` |
63+
| `"` | `double quote` |
64+
| `` ` `` | `back tick` |
65+
| `(` | `paren` |
66+
| `)` | `right paren` |
67+
| `{` | `brace` |
68+
| `}` | `right brace` |
69+
| `[` | `square` |
70+
| `]` | `right square` |
71+
| `<` | `angle` |
72+
| `>` | `right angle` |
73+
74+
## Digits
75+
76+
| Character | Default spoken form |
77+
| --------- | ------------------- |
78+
| `0` | `zero` |
79+
| `1` | `one` |
80+
| `2` | `two` |
81+
| `3` | `three` |
82+
| `4` | `four` |
83+
| `5` | `five` |
84+
| `6` | `six` |
85+
| `7` | `seven` |
86+
| `8` | `eight` |
87+
| `9` | `nine` |

‎packages/tool-meta-updater/src/metaUpdater.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { ScopeTypeType } from "@cursorless/lib-common";
99
import {
1010
actionReferenceGroups,
1111
actionReferences,
12+
graphemeDefaultSpokenForms,
1213
languageReferences,
1314
modifierReferenceGroups,
1415
modifierReferences,
@@ -22,6 +23,7 @@ import type { RecordedTestPath } from "@cursorless/lib-node-common";
2223
import type { Context } from "./Context";
2324
import { createScopeFixtureGroups } from "./scopeFixtureGroups";
2425
import { textFormat } from "./textFormat";
26+
import { updateGraphemeDefaultSpokenFormsMd } from "./updateGraphemeDefaultSpokenFormsMd";
2527
import { updateLanguageMdx } from "./updateLanguageMdx";
2628
import { updatePackageJson } from "./updatePackageJson";
2729
import { updatePairedDelimitersMd } from "./updatePairedDelimitersMd";
@@ -78,6 +80,11 @@ export const updater = async (workspaceDir: string) => {
7880
null,
7981
pairedDelimiterReferences,
8082
),
83+
[`${userDir}/alphabet-and-symbols.md`]:
84+
updateGraphemeDefaultSpokenFormsMd.bind(
85+
null,
86+
graphemeDefaultSpokenForms,
87+
),
8188
[`${userDir}/actions/README.md`]: updateReferenceReadmeMd.bind(
8289
null,
8390
"Actions",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import type { FormatPluginFnOptions } from "@pnpm/meta-updater";
2+
3+
const HEADERS = ["Character", "Default spoken form"] as const;
4+
5+
export function updateGraphemeDefaultSpokenFormsMd(
6+
entries: Readonly<Record<string, string>>,
7+
actual: string | null,
8+
options: FormatPluginFnOptions,
9+
): string | null {
10+
if (options.manifest.name !== "@cursorless/app-web-docs") {
11+
return null;
12+
}
13+
14+
const alphabet: string[][] = [];
15+
const digits: string[][] = [];
16+
const symbols: string[][] = [];
17+
18+
for (const [character, spokenForm] of Object.entries(entries)) {
19+
const row = [code(character), code(spokenForm)];
20+
21+
if (/^[a-z]$/u.test(character)) {
22+
alphabet.push(row);
23+
} else if (/^[0-9]$/u.test(character)) {
24+
digits.push(row);
25+
} else {
26+
symbols.push(row);
27+
}
28+
}
29+
30+
return [
31+
"# Alphabet and symbols",
32+
"",
33+
"Cursorless uses the [Talon Community](https://github.com/talonhub/community) alphabet, digits, and symbol spoken forms via the [`user.any_alphanumeric_key`](https://github.com/talonhub/community/blob/607c3415f5f29a5f75db6fe5648e37f514f62ac5/core/keys/keys.py#L71-L74) capture.",
34+
"",
35+
"## Alphabet",
36+
"",
37+
...formatTable(HEADERS, alphabet),
38+
"",
39+
"## Symbols",
40+
"",
41+
...formatTable(HEADERS, symbols),
42+
"",
43+
"## Digits",
44+
"",
45+
...formatTable(HEADERS, digits),
46+
"",
47+
].join("\n");
48+
}
49+
50+
function code(value: string): string {
51+
const escaped = value.replaceAll("|", String.raw`\|`);
52+
53+
if (escaped.includes("`")) {
54+
return `\`\` ${escaped} \`\``;
55+
}
56+
57+
return `\`${escaped}\``;
58+
}
59+
60+
function formatTable(
61+
headers: readonly string[],
62+
rows: readonly string[][],
63+
): string[] {
64+
const columnWidths = headers.map((header, index) =>
65+
Math.max(header.length, ...rows.map((row) => row[index].length)),
66+
);
67+
const formatRow = (row: readonly string[]) =>
68+
`| ${row
69+
.map(
70+
(cell, index) =>
71+
`${cell}${" ".repeat(columnWidths[index] - cell.length)}`,
72+
)
73+
.join(" | ")} |`;
74+
75+
return [
76+
formatRow(headers),
77+
formatRow(columnWidths.map((width) => "-".repeat(width))),
78+
...rows.map(formatRow),
79+
];
80+
}

0 commit comments

Comments
 (0)