Skip to content

Commit ee033e8

Browse files
committed
More doc string
1 parent 3193942 commit ee033e8

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+
* private, 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 isPrivate} or {@link isDisabledByDefault} helper functions to construct
26+
* {@link DefaultSpokenFormMapEntry} objects, or just construct them manually.
2127
*/
2228
const defaultSpokenFormMapCore: DefaultSpokenFormMapDefinition = {
2329
pairedDelimiter: {
@@ -196,8 +202,12 @@ export type DefaultSpokenFormMap = {
196202
: Record<SpokenFormMapKeyTypes[K], DefaultSpokenFormMapEntry>;
197203
};
198204

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

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

0 commit comments

Comments
 (0)