Skip to content

Commit 3e47b32

Browse files
authored
Merge pull request #208 from vim-denops/variable-docs
📝 Add JSDoc to variable
2 parents bd02d51 + b44e871 commit 3e47b32

File tree

5 files changed

+44
-9
lines changed

5 files changed

+44
-9
lines changed

denops_std/variable/environment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ export const environment: Getter & Setter & Remover = {
6363
await denops.cmd(`unlet ${name}`);
6464
},
6565
};
66+
/** Shorthand for {@linkcode environment} */
6667
export const e = environment;

denops_std/variable/option.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const options: Getter & Setter & Remover = {
8787
return removeOption(denops, "", prop);
8888
},
8989
};
90+
/** Shorthand for {@linkcode options} */
9091
export const o = options;
9192

9293
/**
@@ -140,6 +141,7 @@ export const localOptions: Getter & Setter & Remover = {
140141
return removeOption(denops, "l", prop);
141142
},
142143
};
144+
/** Shorthand for {@linkcode localOptions} */
143145
export const lo = localOptions;
144146

145147
/**
@@ -193,4 +195,5 @@ export const globalOptions: Getter & Setter & Remover = {
193195
return removeOption(denops, "g", prop);
194196
},
195197
};
198+
/** Shorthand for {@linkcode globalOptions} */
196199
export const go = globalOptions;

denops_std/variable/register.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ export const register: Getter & Setter = {
5858
});
5959
},
6060
};
61+
/** Shorthand for {@linkcode register} */
6162
export const r = register;

denops_std/variable/types.ts

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
import type { Denops } from "https://deno.land/x/denops_core@v4.0.0/mod.ts";
22

3+
/**
4+
* Represents a getter method for retrieving property value.
5+
*/
36
export type Getter = {
4-
get<T = unknown>(
5-
denops: Denops,
6-
prop: string,
7-
defaultValue: T,
8-
): Promise<T>;
9-
get<T = unknown>(
10-
denops: Denops,
11-
prop: string,
12-
): Promise<T | null>;
7+
/**
8+
* Gets the value of the specified property, or default value if it doesn't exist.
9+
* @param prop - The name of the property.
10+
* @param defaultValue - The default value to be returned if the property doesn't exist.
11+
* @returns A promise that resolves to the value of the property.
12+
*/
13+
get<T = unknown>(denops: Denops, prop: string, defaultValue?: T): Promise<T>;
14+
15+
/**
16+
* Gets the value of the specified property, or null if it doesn't exist.
17+
* @param prop - The name of the property.
18+
* @returns A promise that resolves to the value of the property.
19+
*/
20+
get<T = unknown>(denops: Denops, prop: string): Promise<T | null>;
1321
};
1422

23+
/**
24+
* Represents a setter method for setting property value.
25+
*/
1526
export type Setter = {
27+
/**
28+
* Sets the value of the specified property.
29+
* @param prop - The name of the property.
30+
* @param value - The value to be set.
31+
* @returns A promise that resolves when the value has been set.
32+
*/
1633
set<T = unknown>(denops: Denops, prop: string, value: T): Promise<void>;
1734
};
1835

36+
/**
37+
* Represents a remover method for removing property value.
38+
*/
1939
export type Remover = {
40+
/**
41+
* Removes the value of the specified property or resets to its default value.
42+
* @param prop - The name of the property.
43+
* @returns A promise that resolves when the value has been removed or reset.
44+
*/
2045
remove(denops: Denops, prop: string): Promise<void>;
2146
};

denops_std/variable/variable.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const globals: Getter & Setter & Remover = {
8484
return removeVar(denops, "g", prop);
8585
},
8686
};
87+
/** Shorthand for {@linkcode globals} */
8788
export const g = globals;
8889

8990
/**
@@ -131,6 +132,7 @@ export const buffers: Getter & Setter & Remover = {
131132
return removeVar(denops, "b", prop);
132133
},
133134
};
135+
/** Shorthand for {@linkcode buffers} */
134136
export const b = buffers;
135137

136138
/**
@@ -178,6 +180,7 @@ export const windows: Getter & Setter & Remover = {
178180
return removeVar(denops, "w", prop);
179181
},
180182
};
183+
/** Shorthand for {@linkcode windows} */
181184
export const w = windows;
182185

183186
/**
@@ -225,6 +228,7 @@ export const tabpages: Getter & Setter & Remover = {
225228
return removeVar(denops, "t", prop);
226229
},
227230
};
231+
/** Shorthand for {@linkcode tabpages} */
228232
export const t = tabpages;
229233

230234
/**
@@ -262,4 +266,5 @@ export const vim: Getter & Setter = {
262266
return setVar(denops, "v", prop, value);
263267
},
264268
};
269+
/** Shorthand for {@linkcode vim} */
265270
export const v = vim;

0 commit comments

Comments
 (0)