Skip to content

Commit b091e8e

Browse files
committed
docs: Improve documentation comments
1 parent 9de0150 commit b091e8e

File tree

13 files changed

+221
-100
lines changed

13 files changed

+221
-100
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# 🍂 fall-core
22

3+
[![JSR](https://jsr.io/badges/@vim-fall/core)](https://jsr.io/@vim-fall/core)
34
[![Test](https://github.com/vim-fall/fall-core/actions/workflows/test.yml/badge.svg)](https://github.com/vim-fall/fall-core/actions/workflows/test.yml)
45
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
56

6-
Core types for [Fall](https://github.com/vim-fall/fall), a Vim/Neovim Fuzzy
7-
Finder plugin powered by [Denops](https://github.com/vim-denops/denops.vim).
7+
Core types for [Fall](https://github.com/vim-fall/fall), a Vim/Neovim fuzzy
8+
finder plugin powered by [Denops](https://github.com/vim-denops/denops.vim).
89

910
> [!WARNING]
1011
>
11-
> This module is for internal use only. It is not intended to be used by others.
12+
> This module is intended for internal use only and is not meant for external
13+
> use.
1214
1315
## License
1416

15-
The code in this repository follows the MIT license, as detailed in
16-
[LICENSE](./LICENSE). Contributors must agree that any modifications submitted
17-
to this repository also adhere to the license.
17+
This repository is licensed under the MIT License, as detailed in the
18+
[LICENSE](./LICENSE) file. By contributing, you agree that any modifications you
19+
submit will also be licensed under the MIT License.

_typeutil.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
/**
2+
* Promish<T> represents a value that can be either of type T or a Promise of type T.
3+
*/
14
export type Promish<T> = T | Promise<T>;

action.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,39 @@ import type { Denops } from "@denops/std";
33
import type { Promish } from "./_typeutil.ts";
44
import type { IdItem } from "./item.ts";
55

6+
/**
7+
* Parameters for invoking an action.
8+
*/
69
export type InvokeParams<T> = {
710
/**
8-
* The item under the cursor.
11+
* The item currently under the cursor.
12+
*
13+
* If `filteredItems` is empty, this will be `undefined`.
914
*/
1015
readonly item?: IdItem<T> | undefined;
1116
/**
12-
* The selected items.
17+
* The items selected by the user.
18+
*
19+
* If no items were selected, this will be `undefined`.
1320
*/
1421
readonly selectedItems?: readonly IdItem<T>[] | undefined;
1522
/**
16-
* The filtered items.
23+
* The items after filtering.
1724
*/
1825
readonly filteredItems: readonly IdItem<T>[];
1926
};
2027

28+
/**
29+
* An action that can be invoked from the picker.
30+
*/
2131
export type Action<T> = {
2232
/**
2333
* Invoke the action.
2434
*
25-
* @param denops The Denops instance.
26-
* @param params The parameters for invoking the action.
27-
* @param options The options.
28-
* @returns If the picker should not be closed, return `true`.
35+
* @param denops - The Denops instance.
36+
* @param params - Parameters for the action invocation.
37+
* @param options - Additional options.
38+
* @returns If the picker should remain open, return `true`.
2939
*/
3040
invoke(
3141
denops: Denops,

coordinator.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,74 @@
11
import type { Border, Theme } from "./theme.ts";
22

3+
/**
4+
* Represents the width and height dimensions.
5+
*/
36
export type Size = {
47
width: number;
58
height: number;
69
};
710

11+
/**
12+
* Dimension: size with position (col, row).
13+
*/
814
export type Dimension = Size & {
915
col: number;
1016
row: number;
1117
};
1218

19+
/**
20+
* Styles for the picker components.
21+
*/
1322
export type Style = {
23+
/**
24+
* The border style for the input component.
25+
*/
1426
input: Border;
27+
/**
28+
* The border style for the list component.
29+
*/
1530
list: Border;
31+
/**
32+
* The border style for the preview component, if applicable.
33+
*/
1634
preview?: Border;
1735
};
1836

37+
/**
38+
* Layout for the picker components.
39+
*/
1940
export type Layout = {
41+
/**
42+
* Dimensions of the input component.
43+
*/
2044
input: Dimension;
45+
/**
46+
* Dimensions of the list component.
47+
*/
2148
list: Dimension;
49+
/**
50+
* Dimensions of the preview component, if applicable.
51+
*/
2252
preview?: Dimension;
2353
};
2454

55+
/**
56+
* Coordinator for managing the layout and style of picker components.
57+
*/
2558
export type Coordinator = {
2659
/**
27-
* Style of the picker components.
60+
* Retrieves the style for the picker components.
61+
*
62+
* @param theme - The theme used to style the components.
63+
* @returns The style configuration for the picker components.
2864
*/
2965
style(theme: Theme): Style;
3066

3167
/**
32-
* Layout of the picker components.
68+
* Determines the layout for the picker components based on screen size.
69+
*
70+
* @param screen - The size of the screen.
71+
* @returns The layout configuration for the picker components.
3372
*/
3473
layout(screen: Size): Layout;
3574
};

curator.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@ import type { Denops } from "@denops/std";
22

33
import type { IdItem } from "./item.ts";
44

5+
/**
6+
* Parameters for curating items.
7+
*/
58
export type CurateParams = {
69
/**
7-
* The arguments passed to the picker.
10+
* Arguments passed to the picker.
811
*/
912
readonly args: readonly string[];
1013
/**
11-
* User input query.
14+
* User input query for filtering items.
1215
*/
1316
readonly query: string;
1417
};
1518

19+
/**
20+
* Curator that collects and filters items based on user input.
21+
*
22+
* Acts as an interactive `Source`.
23+
*/
1624
export type Curator<T> = {
1725
/**
18-
* Curate items.
26+
* Curates items based on the provided parameters.
1927
*
20-
* @param denops The Denops instance.
21-
* @param params The parameters to curate items.
22-
* @param options The options.
23-
* @param options.signal The signal to cancel the operation.
28+
* @param denops - The Denops instance.
29+
* @param params - Parameters for curating items.
30+
* @param options - Optional settings, including an abort signal.
31+
* @returns An async iterator over curated `IdItem` elements.
2432
*/
2533
curate(
2634
denops: Denops,

item.ts

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,106 @@
1+
/**
2+
* An item processed by the picker.
3+
*/
14
export type IdItem<T> = {
25
/**
3-
* The unique identifier of the item.
6+
* Unique identifier for the item.
47
*/
5-
readonly id: number;
8+
readonly id: unknown;
69

710
/**
8-
* The value of the item.
11+
* Item's primary value.
912
*/
1013
readonly value: string;
1114

1215
/**
13-
* The detailed information of the item.
16+
* Detailed information about the item.
1417
*
15-
* This information is used in further processing.
16-
* Developers should verify if the `detail` has the expected structure before using it
17-
* and ignore the item if it does not.
18+
* Used for further processing.
1819
*/
1920
readonly detail: T;
2021

2122
/**
22-
* The display label of the item.
23+
* Display label for the item in the picker.
2324
*
24-
* This label is used to display the item in the picker.
25-
* If not specified, `value` is used.
25+
* If not specified, `value` is used as the label.
2626
*/
2727
label?: string;
2828

2929
/**
30-
* Decorations to be applied to the line of the item in the picker.
30+
* Decorations applied to the item's line in the picker.
3131
*
32-
* These decorations highlight the matched part of the item, or are used for better visualization.
33-
* Developers should respect existing `decorations` and extend them.
32+
* These decorations highlight matched parts or improve visualization.
33+
* Developers should respect and extend existing `decorations`.
3434
*
35-
* Note: If `highlight` is not specified, the picker will use the default highlight group
36-
* for highlighting the matched part.
35+
* Note: If `highlight` is unspecified, the picker uses a default highlight
36+
* group to emphasize matched parts.
3737
*/
3838
decorations?: readonly ItemDecoration[];
3939
};
4040

41+
/**
42+
* An item displayed in the picker.
43+
*/
4144
export type DisplayItem<T> = IdItem<T> & {
4245
/**
43-
* The display label of the item.
46+
* Display label for the item in the picker.
4447
*
45-
* This label is used to display the item in the picker.
46-
* If not specified, `value` is used.
48+
* If unspecified, `value` is used as the label.
4749
*/
4850
label: string;
4951

5052
/**
51-
* Decorations to be applied to the line of the item in the picker.
53+
* Decorations applied to the item's line in the picker.
5254
*
53-
* These decorations highlight the matched part of the item, or are used for better visualization.
54-
* Developers should respect existing `decorations` and extend them.
55+
* These decorations highlight matched parts or improve visualization.
56+
* Developers should respect and extend existing `decorations`.
5557
*
56-
* Note: If `highlight` is not specified, the picker will use the default highlight group
57-
* for highlighting the matched part.
58+
* Note: If `highlight` is unspecified, the picker uses a default highlight
59+
* group to emphasize matched parts.
5860
*/
5961
decorations: readonly ItemDecoration[];
6062
};
6163

64+
/**
65+
* An item used for previewing content in the picker.
66+
*/
6267
export type PreviewItem = {
6368
/**
64-
* The content to preview.
69+
* Content to preview.
6570
*/
6671
readonly content: string[];
6772
/**
68-
* The line number to jump to.
73+
* Line number to jump to.
6974
*/
7075
readonly line?: number;
7176
/**
72-
* The column number to jump to.
77+
* Column number to jump to.
7378
*/
7479
readonly column?: number;
7580
/**
76-
* The filetype used for highlighting.
81+
* Filetype for syntax highlighting.
7782
*/
7883
readonly filetype?: string;
7984
/**
80-
* The filename used in the buffer name.
85+
* Filename displayed in the buffer name.
8186
*/
8287
readonly filename?: string;
8388
};
8489

90+
/**
91+
* Decoration applied to an item's line in the picker.
92+
*/
8593
export type ItemDecoration = {
8694
/**
87-
* Column number (bytes)
95+
* Column number (in bytes).
8896
*/
8997
readonly column: number;
9098
/**
91-
* Length (bytes)
99+
* Length of the decoration (in bytes).
92100
*/
93101
readonly length: number;
94102
/**
95-
* Highlight name
103+
* Name of the highlight group.
96104
*/
97105
readonly highlight?: string;
98106
};

matcher.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
import type { Denops } from "@denops/std";
2-
32
import type { IdItem } from "./item.ts";
43

4+
/**
5+
* Parameters for matching items.
6+
*/
57
export type MatchParams<T> = {
68
/**
7-
* User input query.
9+
* User input query for filtering.
810
*/
911
readonly query: string;
1012
/**
11-
* Items to match.
13+
* Array of items to match against the query.
1214
*/
1315
readonly items: readonly IdItem<T>[];
1416
};
1517

18+
/**
19+
* Matcher that filters items based on user input.
20+
*/
1621
export type Matcher<T> = {
1722
/**
18-
* Match items.
23+
* Matches items against the provided query.
1924
*
20-
* @param denops Denops instance.
21-
* @param params Parameters to match items.
22-
* @param options Options.
25+
* @param denops - The Denops instance.
26+
* @param params - Parameters for matching items.
27+
* @param options - Additional options, including an abort signal.
28+
* @returns An async iterator over matched `IdItem` elements.
2329
*/
2430
match(
2531
denops: Denops,

0 commit comments

Comments
 (0)