Skip to content

Commit 54f27fa

Browse files
committed
📝 Add documentation comments on variable
1 parent 17c3c2e commit 54f27fa

File tree

6 files changed

+177
-183
lines changed

6 files changed

+177
-183
lines changed

denops_std/variable/README.md

Lines changed: 0 additions & 173 deletions
This file was deleted.

denops_std/variable/environment.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,23 @@ import type { Denops } from "https://deno.land/x/denops_core@v3.4.1/mod.ts";
22
import { Getter, Remover, Setter } from "./types.ts";
33

44
/**
5-
* Environment variables
5+
* Environment variables (`environment` or `e`)
6+
*
7+
* ```typescript
8+
* import { Denops } from "../mod.ts";
9+
* import { environment } from "../variable/mod.ts";
10+
*
11+
* export async function main(denops: Denops): Promise<void> {
12+
* // Set environment variable
13+
* await environment.set(denops, "DENOPS_HELLO", "world");
14+
*
15+
* // Get environment variable
16+
* console.log(await environment.get(denops, "DENOPS_HELLO"));
17+
*
18+
* // Remove environment variable
19+
* await environment.remove(denops, "DENOPS_HELLO");
20+
* }
21+
* ```
622
*/
723
export const environment: Getter & Setter & Remover = {
824
/**

denops_std/variable/mod.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* A module to provide helper accessor functions to variables
3+
*
4+
* @module
5+
*/
16
export * from "./variable.ts";
27
export * from "./environment.ts";
38
export * from "./register.ts";

denops_std/variable/option.ts

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,25 @@ async function removeOption(
3737
}
3838

3939
/**
40-
* Options
40+
* Options (`options` or `o`)
41+
*
42+
* ```typescript
43+
* import { Denops } from "../mod.ts";
44+
* import { options } from "../variable/mod.ts";
45+
*
46+
* export async function main(denops: Denops): Promise<void> {
47+
* // Set option
48+
* await options.set(denops, "filetype", "world");
49+
*
50+
* // Get option
51+
* console.log(await options.get(denops, "filetype"));
52+
*
53+
* // Reset option
54+
* await options.remove(denops, "filetype");
55+
* }
56+
* ```
57+
*
58+
* Note that `options.get()` returns `defaultValue` when the option is falsy.
4159
*/
4260
export const options: Getter & Setter & Remover = {
4361
/**
@@ -72,7 +90,25 @@ export const options: Getter & Setter & Remover = {
7290
export const o = options;
7391

7492
/**
75-
* Local options
93+
* Local options (`localOptions` or `lo`)
94+
*
95+
* ```typescript
96+
* import { Denops } from "../mod.ts";
97+
* import { localOptions } from "../variable/mod.ts";
98+
*
99+
* export async function main(denops: Denops): Promise<void> {
100+
* // Set option
101+
* await localOptions.set(denops, "filetype", "world");
102+
*
103+
* // Get option
104+
* console.log(await localOptions.get(denops, "filetype"));
105+
*
106+
* // Reset option
107+
* await localOptions.remove(denops, "filetype");
108+
* }
109+
* ```
110+
*
111+
* Note that `localOptions.get()` returns `defaultValue` when the option is falsy.
76112
*/
77113
export const localOptions: Getter & Setter & Remover = {
78114
/**
@@ -107,7 +143,25 @@ export const localOptions: Getter & Setter & Remover = {
107143
export const lo = localOptions;
108144

109145
/**
110-
* Global options
146+
* Global options (`globalOptions` or `go`)
147+
*
148+
* ```typescript
149+
* import { Denops } from "../mod.ts";
150+
* import { globalOptions } from "../variable/mod.ts";
151+
*
152+
* export async function main(denops: Denops): Promise<void> {
153+
* // Set option
154+
* await globalOptions.set(denops, "filetype", "world");
155+
*
156+
* // Get option
157+
* console.log(await globalOptions.get(denops, "filetype"));
158+
*
159+
* // Reset option
160+
* await globalOptions.remove(denops, "filetype");
161+
* }
162+
* ```
163+
*
164+
* Note that `globalOption.get()` returns `defaultValue` when the option is falsy.
111165
*/
112166
export const globalOptions: Getter & Setter & Remover = {
113167
/**

denops_std/variable/register.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@ import type { Denops } from "https://deno.land/x/denops_core@v3.4.1/mod.ts";
22
import { Getter, Setter } from "./types.ts";
33

44
/**
5-
* Register
5+
* Register (`register` or `r`)
6+
*
7+
* ```typescript
8+
* import { Denops } from "../mod.ts";
9+
* import { register } from "../variable/mod.ts";
10+
*
11+
* export async function main(denops: Denops): Promise<void> {
12+
* // Set register
13+
* await register.set(denops, "a", "world");
14+
*
15+
* // Get register
16+
* console.log(await register.get(denops, "a"));
17+
* }
18+
* ```
19+
*
20+
* Note that `register.get()` returns `defaultValue` when the register is falsy.
621
*/
722
export const register: Getter & Setter = {
823
/**

0 commit comments

Comments
 (0)