Skip to content

Commit bdf9ca6

Browse files
authored
chore: tweak emmylua docs (#162)
1 parent cc87c89 commit bdf9ca6

File tree

9 files changed

+337
-318
lines changed

9 files changed

+337
-318
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ Following are the **default** config for the [`setup()`](#setup). If you want to
127127
},
128128

129129
---Pre-hook, called before commenting the line
130-
---@type fun(ctx: Ctx):string
130+
---@type fun(ctx: CommentCtx):string
131131
pre_hook = nil,
132132

133133
---Post-hook, called after commenting is done
134-
---@type fun(ctx: Ctx)
134+
---@type fun(ctx: CommentCtx)
135135
post_hook = nil,
136136
}
137137
```
@@ -255,7 +255,7 @@ There are two hook methods i.e `pre_hook` and `post_hook` which are called befor
255255
```lua
256256
-- NOTE: The example below is a proper integration and it is RECOMMENDED.
257257
{
258-
---@param ctx Ctx
258+
---@param ctx CommentCtx
259259
pre_hook = function(ctx)
260260
-- Only calculate commentstring for tsx filetypes
261261
if vim.bo.filetype == 'typescriptreact' then
@@ -287,7 +287,7 @@ There are two hook methods i.e `pre_hook` and `post_hook` which are called befor
287287

288288
```lua
289289
{
290-
---@param ctx Ctx
290+
---@param ctx CommentCtx
291291
post_hook = function(ctx)
292292
if ctx.range.srow == ctx.range.erow then
293293
-- do something with the current line
@@ -411,21 +411,21 @@ The following object is provided as an argument to `pre_hook` and `post_hook` fu
411411
412412
```lua
413413
---Comment context
414-
---@class Ctx
415-
---@field ctype CType
416-
---@field cmode CMode
417-
---@field cmotion CMotion
418-
---@field range CRange
414+
---@class CommentCtx
415+
---@field ctype CommentType
416+
---@field cmode CommentMode
417+
---@field cmotion CommentMotion
418+
---@field range CommentRange
419419

420420
---Range of the selection that needs to be commented
421-
---@class CRange
421+
---@class CommentRange
422422
---@field srow number Starting row
423423
---@field scol number Starting column
424424
---@field erow number Ending row
425425
---@field ecol number Ending column
426426
```
427427

428-
`CType` (Comment type), `CMode` (Comment mode) and `CMotion` (Comment motion) all of them are exported from the plugin's utils for reuse
428+
`CommentType`, `CommentMode` and `CommentMotion` all of them are exported from the plugin's utils for reuse
429429

430430
```lua
431431
require('Comment.utils').ctype.{line,block}

doc/API.md

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ⚙️ API
22

3-
Following are list of APIs that are exported from the plugin. These can be used to setup [custom keybinding](#usage) or to make your own custom comment function. All API functions can take `vmode` (defined below) and a optional [`cfg`](../README.md#config) argument which can be used to override the [default configuration](../README.md#config)
3+
Following are list of APIs that are exported from the plugin. These can be used to setup [custom keybinding](#usage) or to make your own custom comment function. All API functions can take `opmode` (defined below) and a optional [`cfg`](../README.md#config) argument which can be used to override the [default configuration](../README.md#config)
44

55
```lua
6-
---@alias VMode '"line"'|'"char"'|'"v"'|'"V"' Vim Mode. Read `:h map-operator`
6+
---@alias OpMode 'line'|'char'|'v'|'V' Vim operator-mode motions. Read `:h map-operator`
77
```
88

99
### Core
@@ -14,41 +14,41 @@ These APIs powers the [basic-mappings](../README.md#basic-mappings).
1414
--######### LINEWISE #########--
1515

1616
---Toggle linewise-comment on the current line
17-
---@param cfg? Config
17+
---@param cfg? CommentConfig
1818
require('Comment.api').toggle_current_linewise(cfg)
1919

2020
---(Operator-Pending) Toggle linewise-comment on the current line
21-
---@param vmode VMode
22-
---@param cfg? Config
23-
require('Comment.api').toggle_current_linewise_op(vmode, cfg)
21+
---@param opmode OpMode
22+
---@param cfg? CommentConfig
23+
require('Comment.api').toggle_current_linewise_op(opmode, cfg)
2424

2525
---(Operator-Pending) Toggle linewise-comment over multiple lines
26-
---@param vmode VMode
27-
---@param cfg? Config
28-
require('Comment.api').toggle_linewise_op(vmode, cfg)
26+
---@param opmode OpMode
27+
---@param cfg? CommentConfig
28+
require('Comment.api').toggle_linewise_op(opmode, cfg)
2929

3030
---Toggle linewise-comment over multiple lines using `vim.v.count`
31-
---@param cfg? Config
31+
---@param cfg? CommentConfig
3232
require('Comment.api').toggle_linewise_count(cfg)
3333

3434
--######### BLOCKWISE #########--
3535

3636
---Toggle blockwise comment on the current line
37-
---@param cfg? Config
37+
---@param cfg? CommentConfig
3838
require('Comment.api').toggle_current_blockwise(cfg)
3939

4040
---(Operator-Pending) Toggle blockwise comment on the current line
41-
---@param vmode VMode
42-
---@param cfg? Config
43-
require('Comment.api').toggle_current_blockwise_op(vmode, cfg)
41+
---@param opmode OpMode
42+
---@param cfg? CommentConfig
43+
require('Comment.api').toggle_current_blockwise_op(opmode, cfg)
4444

4545
---(Operator-Pending) Toggle blockwise-comment over multiple lines
46-
---@param vmode VMode
47-
---@param cfg? Config
48-
require('Comment.api').toggle_blockwise_op(vmode, cfg)
46+
---@param opmode OpMode
47+
---@param cfg? CommentConfig
48+
require('Comment.api').toggle_blockwise_op(opmode, cfg)
4949

5050
---Toggle blockwise-comment over multiple lines using `vim.v.count`
51-
---@param cfg? Config
51+
---@param cfg? CommentConfig
5252
require('Comment.api').toggle_blockwise_count(cfg)
5353
```
5454

@@ -60,29 +60,29 @@ These APIs powers the [extra-mappings](../README.md#extra-mappings) and also pro
6060
--######### LINEWISE #########--
6161

6262
---Insert a linewise-comment below
63-
---@param cfg? Config
63+
---@param cfg? CommentConfig
6464
require('Comment.api').insert_linewise_below(cfg)
6565

6666
---Insert a linewise-comment above
67-
---@param cfg? Config
67+
---@param cfg? CommentConfig
6868
require('Comment.api').insert_linewise_above(cfg)
6969

7070
---Insert a linewise-comment at the end-of-line
71-
---@param cfg? Config
71+
---@param cfg? CommentConfig
7272
require('Comment.api').insert_linewise_eol(cfg)
7373

7474
--######### BLOCKWISE #########--
7575

7676
---Insert a blockwise-comment below
77-
---@param cfg? Config
77+
---@param cfg? CommentConfig
7878
require('Comment.api').insert_blockwise_below(cfg)
7979

8080
---Insert a blockwise-comment above
81-
---@param cfg? Config
81+
---@param cfg? CommentConfig
8282
require('Comment.api').insert_blockwise_above(cfg)
8383

8484
---Insert a blockwise-comment at the end-of-line
85-
---@param cfg? Config
85+
---@param cfg? CommentConfig
8686
require('Comment.api').insert_blockwise_eol(cfg)
8787
```
8888

@@ -94,52 +94,52 @@ These APIs powers the [extended-mappings](../README.md#extended-mappings).
9494
--######### LINEWISE #########--
9595

9696
---Comment current line using linewise-comment
97-
---@param cfg? Config
97+
---@param cfg? CommentConfig
9898
require('Comment.api').comment_current_linewise(cfg)
9999

100100
---(Operator-Pending) Comment current line using linewise-comment
101-
---@param vmode VMode
102-
---@param cfg? Config
103-
require('Comment.api').comment_current_linewise_op(vmode, cfg)
101+
---@param opmode OpMode
102+
---@param cfg? CommentConfig
103+
require('Comment.api').comment_current_linewise_op(opmode, cfg)
104104

105105
---(Operator-Pending) Comment multiple line using linewise-comment
106-
---@param vmode VMode
107-
---@param cfg? Config
108-
require('Comment.api').comment_linewise_op(vmode, cfg)
106+
---@param opmode OpMode
107+
---@param cfg? CommentConfig
108+
require('Comment.api').comment_linewise_op(opmode, cfg)
109109

110110
---Uncomment current line using linewise-comment
111-
---@param cfg? Config
111+
---@param cfg? CommentConfig
112112
require('Comment.api').uncomment_current_linewise(cfg)
113113

114114
---(Operator-Pending) Uncomment current line using linewise-comment
115-
---@param vmode VMode
116-
---@param cfg? Config
117-
require('Comment.api').uncomment_current_linewise_op(vmode, cfg)
115+
---@param opmode OpMode
116+
---@param cfg? CommentConfig
117+
require('Comment.api').uncomment_current_linewise_op(opmode, cfg)
118118

119119
---(Operator-Pending) Uncomment multiple line using linewise-comment
120-
---@param vmode VMode
121-
---@param cfg? Config
122-
require('Comment.api').uncomment_linewise_op(vmode, cfg)
120+
---@param opmode OpMode
121+
---@param cfg? CommentConfig
122+
require('Comment.api').uncomment_linewise_op(opmode, cfg)
123123

124124
--######### BLOCKWISE #########--
125125

126126
---Comment current line using linewise-comment
127-
---@param cfg? Config
127+
---@param cfg? CommentConfig
128128
require('Comment.api').comment_current_blockwise(cfg)
129129

130130
---(Operator-Pending) Comment current line using blockwise-comment
131-
---@param vmode VMode
132-
---@param cfg? Config
133-
require('Comment.api').comment_current_blockwise_op(vmode, cfg)
131+
---@param opmode OpMode
132+
---@param cfg? CommentConfig
133+
require('Comment.api').comment_current_blockwise_op(opmode, cfg)
134134

135135
---Uncomment current line using blockwise-comment
136-
---@param cfg? Config
136+
---@param cfg? CommentConfig
137137
require('Comment.api').uncomment_current_blockwise(cfg)
138138

139139
---(Operator-Pending) Uncomment current line using blockwise-comment
140-
---@param vmode VMode
141-
---@param cfg? Config
142-
require('Comment.api').uncomment_current_blockwise_op(vmode, cfg)
140+
---@param opmode OpMode
141+
---@param cfg? CommentConfig
142+
require('Comment.api').uncomment_current_blockwise_op(opmode, cfg)
143143
```
144144

145145
### Additional

0 commit comments

Comments
 (0)