Skip to content

Commit 291f177

Browse files
lambdalisueclaude
andcommitted
docs: add comprehensive JSDoc to main entry points
- Document main.ts with module overview and entry point details - Add extensive documentation to picker.ts including: - Pipeline architecture explanation - Type documentation for all exported interfaces - Class and method documentation with examples - Document custom.ts configuration system with: - Module-level documentation - Function documentation for all exported APIs - Internal helper documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 0b51971 commit 291f177

File tree

3 files changed

+412
-7
lines changed

3 files changed

+412
-7
lines changed

denops/fall/custom.ts

Lines changed: 153 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/**
2+
* @module custom
3+
*
4+
* Custom configuration management for vim-fall.
5+
*
6+
* This module handles loading, managing, and reloading user customizations
7+
* for vim-fall. It provides APIs for:
8+
*
9+
* - Loading user custom configuration files
10+
* - Managing global settings (theme, coordinator)
11+
* - Registering custom pickers
12+
* - Configuring action pickers
13+
* - Editing and reloading configurations
14+
*
15+
* The custom system allows users to define their own pickers, customize
16+
* existing ones, and configure the overall appearance and behavior of
17+
* vim-fall through a TypeScript configuration file.
18+
*/
19+
120
import type { Denops } from "jsr:@denops/std@^7.3.2";
221
import * as buffer from "jsr:@denops/std@^7.3.2/buffer";
322
import * as vars from "jsr:@denops/std@^7.3.2/variable";
@@ -53,7 +72,22 @@ let actionPickerParams = { ...defaultActionPickerParams };
5372
const pickerParamsMap = new Map<string, PickerParams>();
5473

5574
/**
56-
* Edit user custom
75+
* Opens the user custom configuration file for editing.
76+
*
77+
* This function:
78+
* - Creates the custom file from a template if it doesn't exist
79+
* - Opens the file in a new buffer
80+
* - Sets up auto-reload on save
81+
*
82+
* @param denops - The Denops instance
83+
* @param options - Buffer open options (split, vsplit, etc.)
84+
* @returns A promise that resolves when the file is opened
85+
*
86+
* @example
87+
* ```typescript
88+
* // Open custom file in a vertical split
89+
* await editUserCustom(denops, { mods: "vertical" });
90+
* ```
5791
*/
5892
export async function editUserCustom(
5993
denops: Denops,
@@ -86,7 +120,28 @@ export async function editUserCustom(
86120
}
87121

88122
/**
89-
* Load user custom from the g:fall_config_path.
123+
* Loads the user custom configuration from the path specified in g:fall_custom_path.
124+
*
125+
* This function:
126+
* - Loads the custom TypeScript module
127+
* - Executes its main function with the configuration context
128+
* - Falls back to default configuration on error
129+
* - Emits User:FallCustomLoaded autocmd on success
130+
*
131+
* @param denops - The Denops instance
132+
* @param options - Loading options
133+
* @param options.reload - Force reload even if already loaded
134+
* @param options.verbose - Show loading messages
135+
* @returns A promise that resolves when loading is complete
136+
*
137+
* @example
138+
* ```typescript
139+
* // Initial load
140+
* await loadUserCustom(denops);
141+
*
142+
* // Force reload with verbose output
143+
* await loadUserCustom(denops, { reload: true, verbose: true });
144+
* ```
90145
*/
91146
export function loadUserCustom(
92147
denops: Denops,
@@ -144,7 +199,26 @@ export function loadUserCustom(
144199
}
145200

146201
/**
147-
* Recache user custom by running `deno cache --reload` command.
202+
* Recaches the user custom file and its dependencies.
203+
*
204+
* This function runs `deno cache --reload` on the custom file to:
205+
* - Download and update all dependencies
206+
* - Recompile TypeScript code
207+
* - Clear the module cache
208+
*
209+
* After recaching, Vim must be restarted for changes to take effect.
210+
*
211+
* @param denops - The Denops instance
212+
* @param options - Recache options
213+
* @param options.verbose - Show cache progress
214+
* @param options.signal - AbortSignal to cancel the operation
215+
* @returns A promise that resolves when recaching is complete
216+
*
217+
* @example
218+
* ```typescript
219+
* // Recache with progress output
220+
* await recacheUserCustom(denops, { verbose: true });
221+
* ```
148222
*/
149223
export async function recacheUserCustom(
150224
denops: Denops,
@@ -199,14 +273,32 @@ export async function recacheUserCustom(
199273
}
200274

201275
/**
202-
* Get global custom.
276+
* Gets the current global settings.
277+
*
278+
* @returns The current setting configuration including theme and coordinator
279+
*
280+
* @example
281+
* ```typescript
282+
* const settings = getSetting();
283+
* console.log("Current theme:", settings.theme);
284+
* ```
203285
*/
204286
export function getSetting(): Readonly<Setting> {
205287
return setting;
206288
}
207289

208290
/**
209-
* Get action picker params.
291+
* Gets the current action picker parameters.
292+
*
293+
* Action pickers are used for selecting actions to perform on items.
294+
*
295+
* @returns The current action picker configuration
296+
*
297+
* @example
298+
* ```typescript
299+
* const params = getActionPickerParams();
300+
* console.log("Action picker matchers:", params.matchers);
301+
* ```
210302
*/
211303
export function getActionPickerParams(): Readonly<
212304
ActionPickerParams
@@ -215,7 +307,18 @@ export function getActionPickerParams(): Readonly<
215307
}
216308

217309
/**
218-
* Get item picker params.
310+
* Gets the parameters for a specific picker by name.
311+
*
312+
* @param name - The name of the picker
313+
* @returns The picker parameters if found, undefined otherwise
314+
*
315+
* @example
316+
* ```typescript
317+
* const filePickerParams = getPickerParams("file");
318+
* if (filePickerParams) {
319+
* console.log("File picker source:", filePickerParams.source);
320+
* }
321+
* ```
219322
*/
220323
export function getPickerParams(
221324
name: string,
@@ -228,18 +331,42 @@ export function getPickerParams(
228331
}
229332

230333
/**
231-
* List item picker names.
334+
* Lists all registered picker names.
335+
*
336+
* @returns An array of all registered picker names
337+
*
338+
* @example
339+
* ```typescript
340+
* const pickers = listPickerNames();
341+
* console.log("Available pickers:", pickers);
342+
* // Output: ["file", "grep", "buffer", ...]
343+
* ```
232344
*/
233345
export function listPickerNames(): readonly string[] {
234346
return Array.from(pickerParamsMap.keys());
235347
}
236348

349+
/**
350+
* Resets all custom configurations to their defaults.
351+
* This is called before loading/reloading custom configurations.
352+
*/
237353
function reset(): void {
238354
setting = { ...defaultSetting };
239355
actionPickerParams = { ...defaultActionPickerParams };
240356
pickerParamsMap.clear();
241357
}
242358

359+
/**
360+
* Builds the context object passed to custom configuration files.
361+
*
362+
* This context provides APIs for:
363+
* - Refining global settings
364+
* - Configuring action pickers
365+
* - Defining new pickers from sources or curators
366+
*
367+
* @param denops - The Denops instance
368+
* @returns The configuration context object
369+
*/
243370
function buildContext(denops: Denops): {
244371
denops: Denops;
245372
refineSetting: ReturnType<typeof buildRefineSetting>;
@@ -266,6 +393,13 @@ function buildContext(denops: Denops): {
266393
};
267394
}
268395

396+
/**
397+
* Gets the URL of the user custom file from g:fall_custom_path.
398+
*
399+
* @param denops - The Denops instance
400+
* @returns The file URL of the custom configuration
401+
* @throws Error if g:fall_custom_path is not set or invalid
402+
*/
269403
async function getUserCustomUrl(denops: Denops): Promise<URL> {
270404
try {
271405
const path = await vars.g.get(denops, "fall_custom_path") as string;
@@ -277,6 +411,12 @@ async function getUserCustomUrl(denops: Denops): Promise<URL> {
277411
}
278412
}
279413

414+
/**
415+
* Validates a picker name to ensure it's valid and not already used.
416+
*
417+
* @param name - The picker name to validate
418+
* @throws ExpectedError if the name is invalid or already exists
419+
*/
280420
function validatePickerName(name: string): void {
281421
if (pickerParamsMap.has(name)) {
282422
throw new ExpectedError(`Picker '${name}' is already defined.`);
@@ -286,6 +426,12 @@ function validatePickerName(name: string): void {
286426
}
287427
}
288428

429+
/**
430+
* Validates action names to ensure they don't use reserved prefixes.
431+
*
432+
* @param actions - The actions object to validate
433+
* @throws ExpectedError if any action name starts with '@'
434+
*/
289435
function validateActions(actions: Record<PropertyKey, unknown>): void {
290436
Object.keys(actions).forEach((name) => {
291437
if (name.startsWith("@")) {

denops/fall/main.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/**
2+
* @module main
3+
*
4+
* Main entry point for the vim-fall Denops plugin.
5+
*
6+
* This module serves as the primary initialization point for vim-fall, a fuzzy finder
7+
* framework for Vim/Neovim built with Denops. It coordinates the initialization of
8+
* all major subsystems including custom configurations, event handling, picker
9+
* functionality, and submatch features.
10+
*
11+
* The module imports and executes initialization functions for each subsystem in a
12+
* specific order to ensure proper setup of the plugin's functionality.
13+
*/
14+
115
import "./lib/polyfill.ts";
216

317
import type { Entrypoint } from "jsr:@denops/std@^7.3.2";
@@ -7,6 +21,26 @@ import { main as mainEvent } from "./main/event.ts";
721
import { main as mainPicker } from "./main/picker.ts";
822
import { main as mainSubmatch } from "./main/submatch.ts";
923

24+
/**
25+
* Main entry point function for the vim-fall plugin.
26+
*
27+
* This function is called by Denops when the plugin is loaded. It initializes
28+
* all the plugin's subsystems in the following order:
29+
*
30+
* 1. Custom configurations - Loads user-defined settings and customizations
31+
* 2. Event system - Sets up the internal event handling mechanism
32+
* 3. Picker system - Initializes the core picker functionality
33+
* 4. Submatch system - Sets up submatch highlighting capabilities
34+
*
35+
* @param denops - The Denops instance provided by the Denops plugin system
36+
* @returns A promise that resolves when all subsystems are initialized
37+
*
38+
* @example
39+
* ```typescript
40+
* // This function is automatically called by Denops
41+
* // No manual invocation is required
42+
* ```
43+
*/
1044
export const main: Entrypoint = async (denops) => {
1145
await mainCustom(denops);
1246
await mainEvent(denops);

0 commit comments

Comments
 (0)