Skip to content

Commit 60d0b73

Browse files
coderabbitai[bot]snipsnipsnip
authored andcommitted
📝 Add docstrings to fix-typedoc
Docstrings generation was requested by @snipsnipsnip. * #32 (comment) The following files were modified: * `src/ghosttext-runner/ghost_text_runner.ts` * `src/root/background_helper.ts` * `src/root/util/wireless.ts`
1 parent b7b8567 commit 60d0b73

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

src/ghosttext-runner/ghost_text_runner.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ async function receiveChange(editor: IClientEditor, session: ISession): Promise<
9595
}
9696
}
9797

98+
/**
99+
* Await a single event from the editor or the session and produce the corresponding command result.
100+
*
101+
* @param editor - Client editor used to wait for an edit and to pop the last edit when one occurs
102+
* @param session - Session used to wait for a server change and to pop the server change when one occurs
103+
* @returns A `CommandResult` describing the event:
104+
* - `{ type: "clientEdited", edit }` when an editor edit was produced
105+
* - `{ type: "serverChanged", change }` when a server change was produced
106+
* - `{ type: "editorClosed" }` when the editor closed without an edit
107+
* - `{ type: "disconnected" }` when the session disconnected without a change
108+
* - `undefined` if an edit/change event was signaled but no payload was available to include.
109+
*/
98110
async function receiveChangeOnce(editor: IClientEditor, session: ISession): Promise<CommandResult | undefined> {
99111
let type = await Promise.race([
100112
editor.waitEdit().then(
@@ -117,6 +129,10 @@ async function receiveChangeOnce(editor: IClientEditor, session: ISession): Prom
117129
return { type }
118130
}
119131
}
132+
133+
/**
134+
* Map a connection status to a user-visible ClientStatus.
135+
*/
120136
function translateStatus(s: SessionStatus): ClientStatus {
121137
switch (s) {
122138
case "error":

src/root/background_helper.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ let routerCache: BackgroundEventRouter | undefined
1010
let routerPromise: Promise<BackgroundEventRouter> | undefined
1111

1212
/**
13-
* Executes a handler function with the background event router.
13+
* Ensure a BackgroundEventRouter is available and invoke the given handler with it.
1414
*
15-
* @param handler The function to execute with the router
16-
* @returns A promise that resolves when the handler completes, or undefined if an error occurs
15+
* @param handler - Function invoked with the prepared BackgroundEventRouter
16+
* @returns a promise when the handler is running async or the BackgroundEventRouter has been initialized, or `undefined` if finished synchronously
1717
*/
1818
export function withRouter(handler: RouterHandler): Promise<void> | undefined {
1919
if (routerCache) {
@@ -31,11 +31,11 @@ export function withRouter(handler: RouterHandler): Promise<void> | undefined {
3131
}
3232

3333
/**
34-
* Executes a handler function synchronously with the provided router.
34+
* Invokes the provided handler with the given BackgroundEventRouter and returns the handler's result.
3535
*
36-
* @param handler The function to execute with the router
37-
* @param router The background event router to use
38-
* @returns A promise that resolves when the handler completes, or undefined if an error occurs
36+
* @param handler - The function to execute with the router
37+
* @param router - The background event router to pass to `handler`
38+
* @returns A promise or an undefined returned by `handler`
3939
*/
4040
function runHandler(handler: RouterHandler, router: BackgroundEventRouter): Promise<void> | undefined {
4141
try {

src/root/util/wireless.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export type WirelessInjector<TCatalog> = <TCtor>(
3636
) => Resolved<TCatalog, TCtor>
3737

3838
/**
39-
* Collects available classes from given module objects to make a factory.
39+
* Creates a convention-based injector by scanning modules for startup classes and wiring constructors with resolved dependencies.
40+
*
41+
* @param modules - Iterable of module objects to scan for startup classes and their metadata
42+
* @param registry - Registry used to resolve dependencies and that will receive the created injector under the key `"$injector"`
43+
* @returns A `WirelessInjector` function that, given a constructor and optional dependency keys, returns a resolved instance for the catalog
4044
*/
4145
export function wireless<TCatalog>(
4246
modules: Iterable<Record<string, unknown>>,

0 commit comments

Comments
 (0)