Skip to content

Commit eed068a

Browse files
committed
More doc string# Please enter the commit message for your changes. Lines starting
1 parent 81cf47b commit eed068a

File tree

1 file changed

+37
-19
lines changed

1 file changed

+37
-19
lines changed

packages/cursorless-engine/src/DefaultSpokenFormMap.ts

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ type DefaultSpokenFormMapDefinition = {
1818
* become the sole source of truth for our default spoken forms, including the
1919
* Talon side. Today it is only used on the extension side for testing, and as a
2020
* fallback when we can't get the custom spoken forms from Talon.
21+
*
22+
* In this map, for regular entities, ie ones that are speakable by default, not
23+
* secret, and have only one spoken form, we allow a shorthand of just providing
24+
* the spoken form as a string. For more complex cases, we can use the
25+
* {@link secret} or {@link disabledByDefault} helper functions to construct
26+
* {@link DefaultSpokenFormMapEntry} objects, or just construct them manually.
2127
*/
2228
const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = {
2329
pairedDelimiter: {
@@ -195,8 +201,12 @@ export type DefaultSpokenFormMap = {
195201
: Record<SpokenFormMapKeyTypes[K], DefaultSpokenFormMapEntry>;
196202
};
197203

198-
// FIXME: Don't cast here; need to make our own mapValues with stronger typing
199-
// using tricks from our object.d.ts
204+
/**
205+
* This map contains information about the default spoken forms for all our
206+
* speakable entities, including scope types, paired delimiters, etc. Note that
207+
* this map can't be used as a spoken form map. If you want something that can
208+
* be used as a spoken form map, see {@link defaultSpokenFormMap}.
209+
*/
200210
export const defaultSpokenFormInfo = mapValues(
201211
defaultSpokenFormMapCore,
202212
(entry) =>
@@ -209,23 +219,31 @@ export const defaultSpokenFormInfo = mapValues(
209219
}
210220
: subEntry,
211221
),
222+
// FIXME: Don't cast here; need to make our own mapValues with stronger typing
223+
// using tricks from our object.d.ts
212224
) as DefaultSpokenFormMap;
213225

214-
// FIXME: Don't cast here; need to make our own mapValues with stronger typing
215-
// using tricks from our object.d.ts
216-
export const defaultSpokenFormMap = mapValues(defaultSpokenFormInfo, (entry) =>
217-
mapValues(
218-
entry,
219-
({
220-
defaultSpokenForms,
221-
isDisabledByDefault,
222-
isSecret,
223-
}): SpokenFormMapEntry => ({
224-
spokenForms: isDisabledByDefault ? [] : defaultSpokenForms,
225-
isCustom: false,
226-
defaultSpokenForms,
227-
requiresTalonUpdate: false,
228-
isSecret,
229-
}),
230-
),
226+
/**
227+
* A spoken form map constructed from the default spoken forms. It is designed to
228+
* be used as a fallback when the Talon spoken form map is not available.
229+
*/
230+
export const defaultSpokenFormMap = mapValues(
231+
defaultSpokenFormInfo,
232+
(entry) =>
233+
mapValues(
234+
entry,
235+
({
236+
defaultSpokenForms,
237+
isDisabledByDefault,
238+
isSecret,
239+
}): SpokenFormMapEntry => ({
240+
spokenForms: isDisabledByDefault ? [] : defaultSpokenForms,
241+
isCustom: false,
242+
defaultSpokenForms,
243+
requiresTalonUpdate: false,
244+
isSecret,
245+
}),
246+
),
247+
// FIXME: Don't cast here; need to make our own mapValues with stronger typing
248+
// using tricks from our object.d.ts
231249
) as SpokenFormMap;

0 commit comments

Comments
 (0)