Skip to content

Commit d649fd6

Browse files
authored
Merge pull request #245 from vim-denops/use-entrypoint
📝 Use `Entrypoint` style on example codes.
2 parents 52b4d51 + db5fc10 commit d649fd6

File tree

32 files changed

+177
-176
lines changed

32 files changed

+177
-176
lines changed

argument/flags.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const shortPattern = /^-([a-zA-Z0-9])(.*)/;
99
* Parse string array to extract flags (-f/--flag).
1010
*
1111
* ```typescript
12-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
12+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
1313
* import { parseFlags } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
1414
*
15-
* export async function main(denops: Denops): Promise<void> {
15+
* export const main: Entrypoint = async (denops) => {
1616
* const args = [
1717
* "++enc=sjis",
1818
* "++ff=dos",
@@ -66,10 +66,10 @@ export function parseFlags(args: string[]): [Flags, string[]] {
6666
* Validate if `flags` has unknown attributes.
6767
*
6868
* ```typescript
69-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
69+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
7070
* import { parse, validateFlags } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
7171
*
72-
* export async function main(denops: Denops): Promise<void> {
72+
* export const main: Entrypoint = async (denops) => {
7373
* const args = [
7474
* "++enc=sjis",
7575
* "++ff=dos",
@@ -102,10 +102,10 @@ export function validateFlags(flags: Flags, knownAttributes: string[]): void {
102102
* Format `key` and `value` to construct string array.
103103
*
104104
* ```typescript
105-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
105+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
106106
* import { formatFlag } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
107107
*
108-
* export async function main(denops: Denops): Promise<void> {
108+
* export const main: Entrypoint = async (denops) => {
109109
* console.log(formatFlag("f", ""));
110110
* // "-f"
111111
*
@@ -133,10 +133,10 @@ export function formatFlag(
133133
* Format `flags` to construct string array.
134134
*
135135
* ```typescript
136-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
136+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
137137
* import { formatFlags, parse } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
138138
*
139-
* export async function main(denops: Denops): Promise<void> {
139+
* export const main: Entrypoint = async (denops) => {
140140
* const args = [
141141
* "++enc=sjis",
142142
* "++ff=dos",

argument/mod.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Then, developers can use this module to parse, validate, or format the arguments.
1818
*
1919
* ```typescript
20-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
20+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
2121
* import {
2222
* builtinOpts,
2323
* formatFlags,
@@ -27,7 +27,7 @@
2727
* validateOpts,
2828
* } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
2929
*
30-
* export async function main(denops: Denops): Promise<void> {
30+
* export const main: Entrypoint = async (denops) => {
3131
* denops.dispatcher = {
3232
* test(args: unknown) {
3333
* // Parse string array to extract `opts`, `flags`.
@@ -70,10 +70,10 @@ import { Flags, parseFlags } from "./flags.ts";
7070
* Parse string array to extract opts, flags.
7171
*
7272
* ```typescript
73-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
73+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
7474
* import { parse } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
7575
*
76-
* export async function main(denops: Denops): Promise<void> {
76+
* export const main: Entrypoint = async (denops) => {
7777
* const args = [
7878
* "++enc=sjis",
7979
* "++ff=dos",

argument/opts.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ const optPattern = /^\+\+([a-zA-Z0-9-]+)(?:=(.*))?/;
2424
* Parse string array to extract opts (++opt).
2525
*
2626
* ```typescript
27-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
27+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
2828
* import { parseOpts } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
2929
*
30-
* export async function main(denops: Denops): Promise<void> {
30+
* export const main: Entrypoint = async (denops) => {
3131
* const args = [
3232
* "++enc=sjis",
3333
* "++ff=dos",
@@ -77,10 +77,10 @@ export function parseOpts(args: string[]): [Opts, string[]] {
7777
* Validate if `opts` has unknown attributes.
7878
*
7979
* ```typescript
80-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
80+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
8181
* import { builtinOpts, parse, validateOpts } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
8282
*
83-
* export async function main(denops: Denops): Promise<void> {
83+
* export const main: Entrypoint = async (denops) => {
8484
* const args = [
8585
* "++enc=sjis",
8686
* "++ff=dos",
@@ -112,10 +112,10 @@ export function validateOpts(opts: Opts, knownAttributes: string[]): void {
112112
* Format `key` and `value` to construct string array.
113113
*
114114
* ```typescript
115-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
115+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
116116
* import { formatOpt } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
117117
*
118-
* export async function main(denops: Denops): Promise<void> {
118+
* export const main: Entrypoint = async (denops) => {
119119
* console.log(formatOpt("enc", "sjis"));
120120
* // "++enc=sjis"
121121
* }
@@ -132,10 +132,10 @@ export function formatOpt(key: string, value: string | undefined): string[] {
132132
* Format `opts` to construct string array.
133133
*
134134
* ```typescript
135-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
135+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
136136
* import { formatOpts, parse } from "https://deno.land/x/denops_std@$MODULE_VERSION/argument/mod.ts";
137137
*
138-
* export async function main(denops: Denops): Promise<void> {
138+
* export const main: Entrypoint = async (denops) => {
139139
* const args = [
140140
* "++enc=sjis",
141141
* "++ff=dos",

autocmd/common.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { buildDefineExpr, buildRemoveExpr } from "./_utils.ts";
1212
* Define an autocmd
1313
*
1414
* ```typescript
15-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
15+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
1616
* import * as autocmd from "https://deno.land/x/denops_std@$MODULE_VERSION/autocmd/mod.ts";
1717
*
18-
* export async function main(denops: Denops): Promise<void> {
18+
* export const main: Entrypoint = async (denops) => {
1919
* // Define new autocmd for BufEnter
2020
* await autocmd.define(denops, "BufEnter", "*", "echo 'BufEnter'");
2121
*
@@ -54,10 +54,10 @@ export async function define(
5454
* Remove an autocmd
5555
*
5656
* ```typescript
57-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
57+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
5858
* import * as autocmd from "https://deno.land/x/denops_std@$MODULE_VERSION/autocmd/mod.ts";
5959
*
60-
* export async function main(denops: Denops): Promise<void> {
60+
* export const main: Entrypoint = async (denops) => {
6161
* // Remove BufEnter autocmd
6262
* await autocmd.remove(denops, "BufEnter", "*");
6363
*
@@ -88,10 +88,10 @@ export async function remove(
8888
* List defined autocmds
8989
*
9090
* ```typescript
91-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
91+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
9292
* import * as autocmd from "https://deno.land/x/denops_std@$MODULE_VERSION/autocmd/mod.ts";
9393
*
94-
* export async function main(denops: Denops): Promise<void> {
94+
* export const main: Entrypoint = async (denops) => {
9595
* // List all autocmd
9696
* console.log(await autocmd.list(denops));
9797
*
@@ -138,10 +138,10 @@ export async function list(
138138
* Emit an autocmd in a buffer
139139
*
140140
* ```typescript
141-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
141+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
142142
* import * as autocmd from "https://deno.land/x/denops_std@$MODULE_VERSION/autocmd/mod.ts";
143143
*
144-
* export async function main(denops: Denops): Promise<void> {
144+
* export const main: Entrypoint = async (denops) => {
145145
* // Emit an autocmd in a current buffer
146146
* await autocmd.emit(denops, "BufEnter");
147147
*
@@ -182,10 +182,10 @@ export async function emit(
182182
* Emit an autocmd in all buffers
183183
*
184184
* ```typescript
185-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
185+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
186186
* import * as autocmd from "https://deno.land/x/denops_std@$MODULE_VERSION/autocmd/mod.ts";
187187
*
188-
* export async function main(denops: Denops): Promise<void> {
188+
* export const main: Entrypoint = async (denops) => {
189189
* // Emit an autocmd in all buffers
190190
* await autocmd.emitAll(denops, "BufEnter");
191191
*

autocmd/group.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ export type GroupRemoveOptions = Omit<RemoveOptions, "group">;
1010
* Create an autocmd group and define/remove autocmds in that group.
1111
*
1212
* ```typescript
13-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
13+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
1414
* import { group } from "https://deno.land/x/denops_std@$MODULE_VERSION/autocmd/mod.ts";
1515
*
16-
* export async function main(denops: Denops): Promise<void> {
16+
* export const main: Entrypoint = async (denops) => {
1717
* await group(denops, "my-autocmd", (helper) => {
1818
* // Define new autocmd for BufEnter
1919
* helper.define("BufEnter", "*", "echo 'BufEnter'");

batch/batch.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ class BatchHelper implements Denops {
9393
* Call multiple denops functions sequentially without RPC overhead
9494
*
9595
* ```typescript
96-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
96+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
9797
* import { batch } from "https://deno.land/x/denops_std@$MODULE_VERSION/batch/mod.ts";
9898
*
99-
* export async function main(denops: Denops): Promise<void> {
99+
* export const main: Entrypoint = async (denops) => {
100100
* await batch(denops, async (denops) => {
101101
* await denops.cmd("setlocal modifiable");
102102
* await denops.cmd("setlocal noswap");
@@ -109,7 +109,7 @@ class BatchHelper implements Denops {
109109
* `batch()` like:
110110
*
111111
* ```typescript
112-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
112+
* import type { Denops, Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
113113
* import { batch } from "https://deno.land/x/denops_std@$MODULE_VERSION/batch/mod.ts";
114114
*
115115
* async function replace(denops: Denops, content: string): Promise<void> {
@@ -122,7 +122,7 @@ class BatchHelper implements Denops {
122122
* });
123123
* }
124124
*
125-
* export async function main(denops: Denops): Promise<void> {
125+
* export const main: Entrypoint = async (denops) => {
126126
* await batch(denops, async (denops) => {
127127
* await denops.cmd("edit Hello");
128128
* await replace(denops, "Hello Darkness My Old Friend");
@@ -134,10 +134,10 @@ class BatchHelper implements Denops {
134134
* falsy value in `batch()`, indicating that you **cannot** write code like below:
135135
*
136136
* ```typescript
137-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
137+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
138138
* import { batch } from "https://deno.land/x/denops_std@$MODULE_VERSION/batch/mod.ts";
139139
*
140-
* export async function main(denops: Denops): Promise<void> {
140+
* export const main: Entrypoint = async (denops) => {
141141
* await batch(denops, async (denops) => {
142142
* // !!! DON'T DO THIS !!!
143143
* if (await denops.eval("&verbose")) {
@@ -153,11 +153,11 @@ class BatchHelper implements Denops {
153153
* like:
154154
*
155155
* ```typescript
156-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
156+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
157157
* import * as lambda from "https://deno.land/x/denops_std@$MODULE_VERSION/lambda/mod.ts";
158158
* import { batch } from "https://deno.land/x/denops_std@$MODULE_VERSION/batch/mod.ts";
159159
*
160-
* export async function main(denops: Denops): Promise<void> {
160+
* export const main: Entrypoint = async (denops) => {
161161
* await batch(denops, async (denops) => {
162162
* const id = lambda.register(denops, async () => {
163163
* // This code is called outside of 'batch' block

batch/collect.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ class CollectHelper implements Denops {
8686
* Call multiple denops functions sequentially without RPC overhead and return values
8787
*
8888
* ```typescript
89-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
89+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
9090
* import { collect } from "https://deno.land/x/denops_std@$MODULE_VERSION/batch/mod.ts";
9191
*
92-
* export async function main(denops: Denops): Promise<void> {
92+
* export const main: Entrypoint = async (denops) => {
9393
* const results = await collect(denops, (denops) => [
9494
* denops.eval("&modifiable"),
9595
* denops.eval("&modified"),
@@ -105,10 +105,10 @@ class CollectHelper implements Denops {
105105
* `collect()`, indicating that you **cannot** write code like below:
106106
*
107107
* ```typescript
108-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
108+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
109109
* import { collect } from "https://deno.land/x/denops_std@$MODULE_VERSION/batch/mod.ts";
110110
*
111-
* export async function main(denops: Denops): Promise<void> {
111+
* export const main: Entrypoint = async (denops) => {
112112
* const results = await collect(denops, (denops) => {
113113
* // !!! DON'T DO THIS !!!
114114
* (async () => {

batch/mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* A module to provide `denops.batch()` helper functions
33
*
44
* ```typescript
5-
* import type { Denops } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
5+
* import type { Entrypoint } from "https://deno.land/x/denops_std@$MODULE_VERSION/mod.ts";
66
* import { batch, collect } from "https://deno.land/x/denops_std@$MODULE_VERSION/batch/mod.ts";
77
*
8-
* export async function main(denops: Denops): Promise<void> {
8+
* export const main: Entrypoint = async (denops) => {
99
* // Call multiple denops functions sequentially in a signle RPC call
1010
* await batch(denops, async (denops) => {
1111
* await denops.cmd("setlocal modifiable");

0 commit comments

Comments
 (0)