Skip to content

Commit 968257e

Browse files
committed
☕ Generate docs of manual functions
1 parent 6db918c commit 968257e

File tree

7 files changed

+627
-518
lines changed

7 files changed

+627
-518
lines changed

denops_std/function/buffer.ts

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

33
/**
4-
* Add a buffer to the buffer list with name {name} (must be a
4+
* Add a buffer to the buffer list with name **{name}** (must be a
55
* String).
6-
* If a buffer for file {name} already exists, return that buffer
6+
* If a buffer for file **{name}** already exists, return that buffer
77
* number. Otherwise return the buffer number of the newly
8-
* created buffer. When {name} is an empty string then a new
8+
* created buffer. When **{name}** is an empty string then a new
99
* buffer is always created.
1010
* The buffer will not have 'buflisted' set and not be loaded
1111
* yet. To add some text to the buffer use this:
12-
* let bufnr = bufadd('someName')
13-
* call bufload(bufnr)
14-
* call setbufline(bufnr, 1, ['some', 'text'])
12+
*
13+
* let bufnr = bufadd('someName')
14+
* call bufload(bufnr)
15+
* call setbufline(bufnr, 1, ['some', 'text'])
16+
*
1517
* Returns 0 on error.
16-
* Can also be used as a |method|:
17-
* let bufnr = 'somename'->bufadd()
18+
* Can also be used as a `method`:
19+
*
20+
* let bufnr = 'somename'->bufadd()
1821
*/
1922
export async function bufadd(
2023
denops: Denops,
@@ -25,29 +28,30 @@ export async function bufadd(
2528
}
2629

2730
/**
28-
* The result is a Number, which is |TRUE| if a buffer called
29-
* {buf} exists.
30-
* If the {buf} argument is a number, buffer numbers are used.
31-
*
31+
* The result is a Number, which is `TRUE` if a buffer called
32+
* **{buf}** exists.
33+
* If the **{buf}** argument is a number, buffer numbers are used.
3234
* Number zero is the alternate buffer for the current window.
33-
* If the {buf} argument is a string it must match a buffer name
35+
*
36+
* If the **{buf}** argument is a string it must match a buffer name
3437
* exactly. The name can be:
3538
* - Relative to the current directory.
3639
* - A full path.
3740
* - The name of a buffer with 'buftype' set to "nofile".
3841
* - A URL name.
3942
* Unlisted buffers will be found.
4043
* Note that help files are listed by their short name in the
41-
* output of |:buffers|, but bufexists() requires using their
44+
* output of `:buffers`, but bufexists() requires using their
4245
* long name to be able to find them.
4346
* bufexists() may report a buffer exists, but to use the name
44-
* with a |:buffer| command you may need to use |expand()|. Esp
45-
* for MS-Windows 8.3 names in the form "c:\DOCUME~1"
47+
* with a `:buffer` command you may need to use `expand()`. Esp
48+
* for MS-Windows 8.3 names in the form `"c:\DOCUME~1"`
4649
* Use "bufexists(0)" to test for the existence of an alternate
4750
* file name.
4851
*
49-
* Can also be used as a |method|:
50-
* let exists = 'somename'->bufexists()
52+
* Can also be used as a `method`:
53+
*
54+
* let exists = 'somename'->bufexists()
5155
*
5256
* Obsolete name: buffer_exists().
5357
*/
@@ -60,12 +64,13 @@ export async function bufexists(
6064
}
6165

6266
/**
63-
* The result is a Number, which is |TRUE| if a buffer called
64-
* {buf} exists and is listed (has the 'buflisted' option set).
65-
* The {buf} argument is used like with |bufexists()|.
67+
* The result is a Number, which is `TRUE` if a buffer called
68+
* **{buf}** exists and is listed (has the 'buflisted' option set).
69+
* The **{buf}** argument is used like with `bufexists()`.
70+
*
71+
* Can also be used as a `method`:
6672
*
67-
* Can also be used as a |method|:
68-
* let listed = 'somename'->buflisted()
73+
* let listed = 'somename'->buflisted()
6974
*/
7075
export async function buflisted(
7176
denops: Denops,
@@ -76,17 +81,18 @@ export async function buflisted(
7681
}
7782

7883
/**
79-
* Ensure the buffer {buf} is loaded. When the buffer name
84+
* Ensure the buffer **{buf}** is loaded. When the buffer name
8085
* refers to an existing file then the file is read. Otherwise
8186
* the buffer will be empty. If the buffer was already loaded
8287
* then there is no change. If the buffer is not related to a
8388
* file the no file is read (e.g., when 'buftype' is "nofile").
8489
* If there is an existing swap file for the file of the buffer,
8590
* there will be no dialog, the buffer will be loaded anyway.
86-
* The {buf} argument is used like with |bufexists()|.
91+
* The **{buf}** argument is used like with `bufexists()`.
8792
*
88-
* Can also be used as a |method|:
89-
* eval 'somename'->bufload()
93+
* Can also be used as a `method`:
94+
*
95+
* eval 'somename'->bufload()
9096
*/
9197
export async function bufload(
9298
denops: Denops,
@@ -96,12 +102,13 @@ export async function bufload(
96102
}
97103

98104
/**
99-
* The result is a Number, which is |TRUE| if a buffer called
100-
* {buf} exists and is loaded (shown in a window or hidden).
101-
* The {buf} argument is used like with |bufexists()|.
105+
* The result is a Number, which is `TRUE` if a buffer called
106+
* **{buf}** exists and is loaded (shown in a window or hidden).
107+
* The **{buf}** argument is used like with `bufexists()`.
108+
*
109+
* Can also be used as a `method`:
102110
*
103-
* Can also be used as a |method|:
104-
* let loaded = 'somename'->bufloaded()
111+
* let loaded = 'somename'->bufloaded()
105112
*/
106113
export async function bufloaded(
107114
denops: Denops,
@@ -115,10 +122,10 @@ export async function bufloaded(
115122
* The result is the name of a buffer. Mostly as it is displayed
116123
* by the `:ls` command, but not using special names such as
117124
* "[No Name]".
118-
* If {buf} is omitted the current buffer is used.
119-
* If {buf} is a Number, that buffer number's name is given.
125+
* If **{buf}** is omitted the current buffer is used.
126+
* If **{buf}** is a Number, that buffer number's name is given.
120127
* Number zero is the alternate buffer for the current window.
121-
* If {buf} is a String, it is used as a |file-pattern| to match
128+
* If **{buf}** is a String, it is used as a `file-pattern` to match
122129
* with the buffer names. This is always done like 'magic' is
123130
* set and 'cpoptions' is empty. When there is more than one
124131
* match an empty string is returned.
@@ -131,18 +138,22 @@ export async function bufloaded(
131138
* Listed buffers are found first. If there is a single match
132139
* with a listed buffer, that one is returned. Next unlisted
133140
* buffers are searched for.
134-
* If the {buf} is a String, but you want to use it as a buffer
141+
* If the **{buf}** is a String, but you want to use it as a buffer
135142
* number, force it to be a Number by adding zero to it:
136-
* :echo bufname("3" + 0)
137-
* Can also be used as a |method|:
138-
* echo bufnr->bufname()
143+
*
144+
* :echo bufname("3" + 0)
145+
*
146+
* Can also be used as a `method`:
147+
*
148+
* echo bufnr->bufname()
139149
*
140150
* If the buffer doesn't exist, or doesn't have a name, an empty
141151
* string is returned.
142-
* bufname("#") alternate buffer name
143-
* bufname(3) name of buffer 3
144-
* bufname("%") name of current buffer
145-
* bufname("file2") name of buffer where "file2" matches.
152+
*
153+
* bufname("#") alternate buffer name
154+
* bufname(3) name of buffer 3
155+
* bufname("%") name of current buffer
156+
* bufname("file2") name of buffer where "file2" matches.
146157
*
147158
* Obsolete name: buffer_name().
148159
*/
@@ -155,25 +166,33 @@ export async function bufname(
155166

156167
/**
157168
* The result is the number of a buffer, as it is displayed by
158-
* the `:ls` command. For the use of {buf}, see |bufname()|
169+
* the `:ls` command. For the use of **{buf}**, see `bufname()`
159170
* above.
171+
*
160172
* If the buffer doesn't exist, -1 is returned. Or, if the
161-
* {create} argument is present and TRUE, a new, unlisted,
173+
* **{create}** argument is present and TRUE, a new, unlisted,
162174
* buffer is created and its number is returned. Example:
163-
* let newbuf = bufnr('Scratch001', 1)
175+
*
176+
* let newbuf = bufnr('Scratch001', 1)
177+
*
164178
* Using an empty name uses the current buffer. To create a new
165-
* buffer with an empty name use |bufadd()|.
179+
* buffer with an empty name use `bufadd()`.
180+
*
166181
* bufnr("$") is the last buffer:
167-
* :let last_buffer = bufnr("$")
182+
*
183+
* :let last_buffer = bufnr("$")
184+
*
168185
* The result is a Number, which is the highest buffer number
169186
* of existing buffers. Note that not all buffers with a smaller
170187
* number necessarily exist, because ":bwipeout" may have removed
171188
* them. Use bufexists() to test for the existence of a buffer.
172189
*
173-
* Can also be used as a |method|:
174-
* echo bufref->bufnr()
190+
* Can also be used as a `method`:
191+
*
192+
* echo bufref->bufnr()
175193
*
176194
* Obsolete name: buffer_number().
195+
*
177196
* Obsolete name for bufnr("$"): last_buffer_nr().
178197
*/
179198
export async function bufnr(
@@ -185,17 +204,18 @@ export async function bufnr(
185204
}
186205

187206
/**
188-
* The result is a Number, which is the |window-ID| of the first
189-
* window associated with buffer {buf}. For the use of {buf},
190-
* see |bufname()| above. If buffer {buf} doesn't exist or
207+
* The result is a Number, which is the `window-ID` of the first
208+
* window associated with buffer **{buf}**. For the use of **{buf}**,
209+
* see `bufname()` above. If buffer **{buf}** doesn't exist or
191210
* there is no such window, -1 is returned. Example:
192211
*
193-
* echo "A window containing buffer 1 is " .. (bufwinid(1))
212+
* echo "A window containing buffer 1 is " .. (bufwinid(1))
194213
*
195214
* Only deals with the current tab page.
196215
*
197-
* Can also be used as a |method|:
198-
* FindBuffer()->bufwinid()
216+
* Can also be used as a `method`:
217+
*
218+
* FindBuffer()->bufwinid()
199219
*/
200220
export async function bufwinid(
201221
denops: Denops,
@@ -205,18 +225,19 @@ export async function bufwinid(
205225
}
206226

207227
/**
208-
* Like |bufwinid()| but return the window number instead of the
209-
* |window-ID|.
210-
* If buffer {buf} doesn't exist or there is no such window, -1
228+
* Like `bufwinid()` but return the window number instead of the
229+
* `window-ID`.
230+
* If buffer **{buf}** doesn't exist or there is no such window, -1
211231
* is returned. Example:
212232
*
213-
* echo "A window containing buffer 1 is " .. (bufwinnr(1))
233+
* echo "A window containing buffer 1 is " .. (bufwinnr(1))
234+
*
235+
* The number can be used with `CTRL-W_w` and ":wincmd w"
236+
* `:wincmd`.
214237
*
215-
* The number can be used with |CTRL-W_w| and ":wincmd w"
216-
* |:wincmd|.
238+
* Can also be used as a `method`:
217239
*
218-
* Can also be used as a |method|:
219-
* FindBuffer()->bufwinnr()
240+
* FindBuffer()->bufwinnr()
220241
*/
221242
export async function bufwinnr(
222243
denops: Denops,
@@ -226,31 +247,33 @@ export async function bufwinnr(
226247
}
227248

228249
/**
229-
* Return a |List| with the lines starting from {lnum} to {end}
230-
* (inclusive) in the buffer {buf}. If {end} is omitted, a
231-
* |List| with only the line {lnum} is returned.
250+
* Return a `List` with the lines starting from **{lnum}** to **{end}**
251+
* (inclusive) in the buffer **{buf}**. If **{end}** is omitted, a
252+
* `List` with only the line **{lnum}** is returned.
232253
*
233-
* For the use of {buf}, see |bufname()| above.
254+
* For the use of **{buf}**, see `bufname()` above.
234255
*
235-
* For {lnum} and {end} "$" can be used for the last line of the
256+
* For **{lnum}** and **{end}** "$" can be used for the last line of the
236257
* buffer. Otherwise a number must be used.
237258
*
238-
* When {lnum} is smaller than 1 or bigger than the number of
239-
* lines in the buffer, an empty |List| is returned.
259+
* When **{lnum}** is smaller than 1 or bigger than the number of
260+
* lines in the buffer, an empty `List` is returned.
240261
*
241-
* When {end} is greater than the number of lines in the buffer,
242-
* it is treated as {end} is set to the number of lines in the
243-
* buffer. When {end} is before {lnum} an empty |List| is
262+
* When **{end}** is greater than the number of lines in the buffer,
263+
* it is treated as **{end}** is set to the number of lines in the
264+
* buffer. When **{end}** is before **{lnum}** an empty `List` is
244265
* returned.
245266
*
246267
* This function works only for loaded buffers. For unloaded and
247-
* non-existing buffers, an empty |List| is returned.
268+
* non-existing buffers, an empty `List` is returned.
248269
*
249270
* Example:
250-
* :let lines = getbufline(bufnr("myfile"), 1, "$")
251271
*
252-
* Can also be used as a |method|:
253-
* GetBufnr()->getbufline(lnum)
272+
* :let lines = getbufline(bufnr("myfile"), 1, "$")
273+
*
274+
* Can also be used as a `method`:
275+
*
276+
* GetBufnr()->getbufline(lnum)
254277
*/
255278
export async function getbufline(
256279
denops: Denops,
@@ -262,33 +285,35 @@ export async function getbufline(
262285
}
263286

264287
/**
265-
* Set line {lnum} to {text} in buffer {buf}. This works like
266-
* |setline()| for the specified buffer.
288+
* Set line **{lnum}** to **{text}** in buffer **{buf}**. This works like
289+
* `setline()` for the specified buffer.
267290
*
268291
* This function works only for loaded buffers. First call
269-
* |bufload()| if needed.
292+
* `bufload()` if needed.
293+
*
294+
* To insert lines use `appendbufline()`.
295+
* Any text properties in **{lnum}** are cleared.
270296
*
271-
* To insert lines use |appendbufline()|.
272-
* Any text properties in {lnum} are cleared.
273-
* {text} can be a string to set one line, or a list of strings
297+
* **{text}** can be a string to set one line, or a list of strings
274298
* to set multiple lines. If the list extends below the last
275299
* line then those lines are added.
276300
*
277-
* For the use of {buf}, see |bufname()| above.
301+
* For the use of **{buf}**, see `bufname()` above.
278302
*
279-
* {lnum} is used like with |setline()|.
280-
* Use "$" to refer to the last line in buffer {buf}.
281-
* When {lnum} is just below the last line the {text} will be
303+
* **{lnum}** is used like with `setline()`.
304+
* Use "$" to refer to the last line in buffer **{buf}**.
305+
* When **{lnum}** is just below the last line the **{text}** will be
282306
* added below the last line.
283307
*
284-
* When {buf} is not a valid buffer, the buffer is not loaded or
285-
* {lnum} is not valid then 1 is returned. In |Vim9| script an
308+
* When **{buf}** is not a valid buffer, the buffer is not loaded or
309+
* **{lnum}** is not valid then 1 is returned. In `Vim9` script an
286310
* error is given.
287311
* On success 0 is returned.
288312
*
289-
* Can also be used as a |method|, the base is passed as the
313+
* Can also be used as a `method`, the base is passed as the
290314
* third argument:
291-
* GetText()->setbufline(buf, lnum)
315+
*
316+
* GetText()->setbufline(buf, lnum)
292317
*/
293318
export async function setbufline(
294319
denops: Denops,

0 commit comments

Comments
 (0)