Skip to content

Commit 516f8ce

Browse files
committed
feat(gen_help_html.lua): adapt to new parser
neovim/tree-sitter-vimdoc#16
1 parent 79a9014 commit 516f8ce

File tree

11 files changed

+553
-382
lines changed

11 files changed

+553
-382
lines changed

runtime/doc/api.txt

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ and |rpcnotify()|:
8383
let nvim = jobstart(['nvim', '--embed'], {'rpc': v:true})
8484
echo rpcrequest(nvim, 'nvim_eval', '"Hello " . "world!"')
8585
call jobstop(nvim)
86+
<
8687

8788
==============================================================================
8889
API Definitions *api-definitions*
@@ -92,7 +93,7 @@ The Nvim C API defines custom types for all function parameters. Some are just
9293
typedefs around C99 standard types, others are Nvim-defined data structures.
9394

9495
Basic types ~
95-
96+
>
9697
API Type C type
9798
------------------------------------------------------------------------
9899
Nil
@@ -103,7 +104,7 @@ Basic types ~
103104
Array
104105
Dictionary (msgpack: map)
105106
Object
106-
107+
<
107108
Note: empty Array is accepted as a valid argument for Dictionary parameter.
108109

109110
Special types (msgpack EXT) ~
@@ -115,13 +116,13 @@ Special types (msgpack EXT) ~
115116
The EXT object data is the (integer) object handle. The EXT type codes given
116117
in the |api-metadata| `types` key are stable: they will not change and are
117118
thus forward-compatible.
118-
119+
>
119120
EXT Type C type Data
120121
------------------------------------------------------------------------
121122
Buffer enum value kObjectTypeBuffer |bufnr()|
122123
Window enum value kObjectTypeWindow |window-ID|
123124
Tabpage enum value kObjectTypeTabpage internal handle
124-
125+
<
125126

126127
*api-indexing*
127128
Most of the API uses 0-based indices, and ranges are end-exclusive. For the
@@ -130,19 +131,19 @@ end of a range, -1 denotes the last line/column.
130131
Exception: the following API functions use "mark-like" indexing (1-based
131132
lines, 0-based columns):
132133

133-
|nvim_get_mark()|
134-
|nvim_buf_get_mark()|
135-
|nvim_buf_set_mark()|
136-
|nvim_win_get_cursor()|
137-
|nvim_win_set_cursor()|
134+
- |nvim_get_mark()|
135+
- |nvim_buf_get_mark()|
136+
- |nvim_buf_set_mark()|
137+
- |nvim_win_get_cursor()|
138+
- |nvim_win_set_cursor()|
138139

139140
Exception: the following API functions use |extmarks| indexing (0-based
140141
indices, end-inclusive):
141142

142-
|nvim_buf_del_extmark()|
143-
|nvim_buf_get_extmark_by_id()|
144-
|nvim_buf_get_extmarks()|
145-
|nvim_buf_set_extmark()|
143+
- |nvim_buf_del_extmark()|
144+
- |nvim_buf_get_extmark_by_id()|
145+
- |nvim_buf_get_extmarks()|
146+
- |nvim_buf_set_extmark()|
146147

147148
*api-fast*
148149
Most API functions are "deferred": they are queued on the main loop and
@@ -162,19 +163,19 @@ and return values.
162163

163164
Nvim exposes its API metadata as a Dictionary with these items:
164165

165-
version Nvim version, API level/compatibility
166-
version.api_level API version integer *api-level*
167-
version.api_compatible API is backwards-compatible with this level
168-
version.api_prerelease Declares the API as unstable/unreleased >
169-
(version.api_prerelease && fn.since == version.api_level)
170-
functions API function signatures, containing |api-types| info
171-
describing the return value and parameters.
172-
ui_events |UI| event signatures
173-
ui_options Supported |ui-option|s
174-
{fn}.since API level where function {fn} was introduced
175-
{fn}.deprecated_since API level where function {fn} was deprecated
176-
types Custom handle types defined by Nvim
177-
error_types Possible error types returned by API functions
166+
- version Nvim version, API level/compatibility
167+
- version.api_level API version integer *api-level*
168+
- version.api_compatible API is backwards-compatible with this level
169+
- version.api_prerelease Declares the API as unstable/unreleased
170+
`(version.api_prerelease && fn.since == version.api_level)`
171+
- functions API function signatures, containing |api-types| info
172+
describing the return value and parameters.
173+
- ui_events |UI| event signatures
174+
- ui_options Supported |ui-option|s
175+
- {fn}.since API level where function {fn} was introduced
176+
- {fn}.deprecated_since API level where function {fn} was deprecated
177+
- types Custom handle types defined by Nvim
178+
- error_types Possible error types returned by API functions
178179

179180
About the `functions` map:
180181

runtime/doc/develop.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,23 @@ DOCUMENTATION *dev-doc*
151151
/// @param dirname The path fragment before `pend`
152152
<
153153

154+
Documentation format ~
155+
156+
For Nvim-owned docs, use the following strict subset of "vimdoc" to ensure
157+
the help doc renders nicely in other formats (such as HTML:
158+
https://neovim.io/doc/user ).
159+
160+
Strict "vimdoc" subset:
161+
162+
- Use lists (like this!) prefixed with "-", "*", or "•", for adjacent lines
163+
that you don't want auto-wrapped. Lists are always rendered with "flow"
164+
(soft-wrapped) layout instead of preformatted (hard-wrapped) layout common
165+
in legacy :help docs.
166+
- Separate blocks (paragraphs) of content by a blank line(s).
167+
- Do not use indentation in random places—that prevents the page from using
168+
"flow" layout. If you need a preformatted section, put it in
169+
a |help-codeblock| starting with ">".
170+
154171
C docstrings ~
155172

156173
Nvim API documentation lives in the source code, as docstrings (Doxygen

runtime/doc/eval.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4119,7 +4119,7 @@ This example sorts lines with a specific compare function. >
41194119
41204120
As a one-liner: >
41214121
:call setline(1, sort(getline(1, '$'), function("Strcmp")))
4122-
4122+
<
41234123

41244124
scanf() replacement ~
41254125
*sscanf*

runtime/doc/filetype.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ If a file type that you want to use is not detected yet, there are a few ways
178178
to add it. In any way, it's better not to modify the $VIMRUNTIME/filetype.lua
179179
or $VIMRUNTIME/filetype.vim files. They will be overwritten when installing a
180180
new version of Nvim. The following explains the legacy Vim mechanism (enabled
181-
if |do_legacy_filetype| is set). For Nvim's default mechanism, see
181+
if |g:do_legacy_filetype| is set). For Nvim's default mechanism, see
182182
|vim.filetype.add()|.
183183

184184
A. If you want to overrule all default file type checks.

runtime/doc/helphelp.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,6 @@ This is done when viewing the file in Vim, the file itself is not changed. It
212212
is done by going through all help files and obtaining the first line of each
213213
file. The files in $VIMRUNTIME/doc are skipped.
214214

215-
*help-xterm-window*
216-
If you want to have the help in another xterm window, you could use this
217-
command: >
218-
:!xterm -e vim +help &
219-
<
220-
221215
*:helpt* *:helptags*
222216
*E150* *E151* *E152* *E153* *E154* *E670* *E856*
223217
:helpt[ags] [++t] {dir}
@@ -372,6 +366,7 @@ To separate sections in a help file, place a series of '=' characters in a
372366
line starting from the first column. The section separator line is highlighted
373367
differently.
374368

369+
*help-codeblock*
375370
To quote a block of ex-commands verbatim, place a greater than (>) character
376371
at the end of the line before the block and a less than (<) character as the
377372
first non-blank on a line following the block. Any line starting in column 1

runtime/doc/luaref.txt

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ Lua means "moon" in Portuguese and is pronounced LOO-ah.
5555

5656
==============================================================================
5757
2 THE LANGUAGE *luaref-language*
58-
==============================================================================
5958

6059
This section describes the lexis, the syntax, and the semantics of Lua. In
6160
other words, this section describes which tokens are valid, how they can be
@@ -450,21 +449,22 @@ through an arithmetic progression. It has the following syntax:
450449
<
451450
The `block` is repeated for `name` starting at the value of the first `exp`, until
452451
it passes the second `exp` by steps of the third `exp`. More precisely,
453-
a `for` statement like
452+
a `for` statement like >
454453
455-
`for var =` `e1, e2, e3` `do` `block` `end`
454+
for var = e1, e2, e3 do block end
456455
457-
is equivalent to the code:
456+
< is equivalent to the code: >
458457
459-
`do`
460-
`local` `var, limit, step` `= tonumber(e1), tonumber(e2), tonumber(e3)`
461-
`if not (` `var` `and` `limit` `and` `step` `) then error() end`
462-
`while (` `step` `>0 and` `var` `<=` `limit` `)`
463-
`or (` `step` `<=0 and` `var` `>=` `limit` `) do`
464-
`block`
465-
`var` `=` `var` `+` `step`
466-
`end`
467-
`end`
458+
do
459+
local var, limit, step = tonumber(e1), tonumber(e2), tonumber(e3)
460+
if not ( var and limit and step ) then error() end
461+
while ( step >0 and var <= limit )
462+
or ( step <=0 and var >= limit ) do
463+
block
464+
var = var + step
465+
end
466+
end
467+
<
468468

469469
Note the following:
470470

@@ -490,18 +490,18 @@ A `for` statement like
490490

491491
`for` `var1, ..., varn` `in` `explist` `do` `block` `end`
492492

493-
is equivalent to the code:
494-
495-
`do`
496-
`local` `f, s, var` `=` `explist`
497-
`while true do`
498-
`local` `var1, ..., varn` `=` `f(s, var)`
499-
`var` `=` `var1`
500-
`if` `var` `== nil then break end`
501-
`block`
502-
`end`
503-
`end`
493+
is equivalent to the code: >
504494
495+
do
496+
local f, s, var = explist
497+
while true do
498+
local var1, ..., varn = f(s, var)
499+
var = var1
500+
if var == nil then break end
501+
block
502+
end
503+
end
504+
<
505505
Note the following:
506506

507507
- `explist` is evaluated only once. Its results are an iterator function,
@@ -1871,25 +1871,25 @@ lua_gc *lua_gc()*
18711871
This function performs several tasks, according to the value of the
18721872
parameter `what`:
18731873

1874-
`LUA_GCSTOP` stops the garbage collector.
1875-
`LUA_GCRESTART` restarts the garbage collector.
1876-
`LUA_GCCOLLECT` performs a full garbage-collection cycle.
1877-
`LUA_GCCOUNT` returns the current amount of memory (in Kbytes) in
1874+
- `LUA_GCSTOP` stops the garbage collector.
1875+
- `LUA_GCRESTART` restarts the garbage collector.
1876+
- `LUA_GCCOLLECT` performs a full garbage-collection cycle.
1877+
- `LUA_GCCOUNT` returns the current amount of memory (in Kbytes) in
18781878
use by Lua.
1879-
`LUA_GCCOUNTB` returns the remainder of dividing the current
1879+
- `LUA_GCCOUNTB` returns the remainder of dividing the current
18801880
amount of bytes of memory in use by Lua by 1024.
1881-
`LUA_GCSTEP` performs an incremental step of garbage collection.
1881+
- `LUA_GCSTEP` performs an incremental step of garbage collection.
18821882
The step "size" is controlled by `data` (larger
18831883
values mean more steps) in a non-specified way. If
18841884
you want to control the step size you must
18851885
experimentally tune the value of `data`. The
18861886
function returns 1 if the step finished a
18871887
garbage-collection cycle.
1888-
`LUA_GCSETPAUSE` sets `data` /100 as the new value for the
1888+
- `LUA_GCSETPAUSE` sets `data` /100 as the new value for the
18891889
`pause` of the collector (see |luaref-langGC|).
18901890
The function returns the previous value of the
18911891
pause.
1892-
`LUA_GCSETSTEPMUL` sets `data` /100 as the new value for the
1892+
- `LUA_GCSETSTEPMUL`sets `data` /100 as the new value for the
18931893
`step` `multiplier` of the collector (see
18941894
|luaref-langGC|). The function returns the
18951895
previous value of the step multiplier.
@@ -2717,20 +2717,22 @@ need "inside information" from the interpreter.
27172717

27182718
lua_Debug *lua_Debug()*
27192719

2720-
`typedef struct lua_Debug {`
2721-
`int event;`
2722-
`const char *name; /* (n) */`
2723-
`const char *namewhat; /* (n) */`
2724-
`const char *what; /* (S) */`
2725-
`const char *source; /* (S) */`
2726-
`int currentline; /* (l) */`
2727-
`int nups; /* (u) number of upvalues */`
2728-
`int linedefined; /* (S) */`
2729-
`int lastlinedefined; /* (S) */`
2730-
`char short_src[LUA_IDSIZE]; /* (S) */`
2731-
`/* private part */`
2732-
`other fields`
2733-
`} lua_Debug;`
2720+
>
2721+
typedef struct lua_Debug {
2722+
int event;
2723+
const char *name; /* (n) */
2724+
const char *namewhat; /* (n) */
2725+
const char *what; /* (S) */
2726+
const char *source; /* (S) */
2727+
int currentline; /* (l) */
2728+
int nups; /* (u) number of upvalues */
2729+
int linedefined; /* (S) */
2730+
int lastlinedefined; /* (S) */
2731+
char short_src[LUA_IDSIZE]; /* (S) */
2732+
/* private part */
2733+
other fields
2734+
} lua_Debug;
2735+
<
27342736

27352737
A structure used to carry different pieces of information about an active
27362738
function. `lua_getstack` (see |lua_getstack()|) fills only the private part
@@ -2739,28 +2741,28 @@ useful information, call `lua_getinfo` (see |lua_getinfo()|).
27392741

27402742
The fields of `lua_Debug` have the following meaning:
27412743

2742-
`source` If the function was defined in a string, then `source` is
2744+
- `source` If the function was defined in a string, then `source` is
27432745
that string. If the function was defined in a file, then
27442746
`source` starts with a `@` followed by the file name.
2745-
`short_src` a "printable" version of `source`, to be used in error messages.
2746-
`linedefined` the line number where the definition of the function starts.
2747-
`lastlinedefined` the line number where the definition of the function ends.
2748-
`what` the string `"Lua"` if the function is a Lua function,
2747+
- `short_src` a "printable" version of `source`, to be used in error messages.
2748+
- `linedefined` the line number where the definition of the function starts.
2749+
- `lastlinedefined` the line number where the definition of the function ends.
2750+
- `what` the string `"Lua"` if the function is a Lua function,
27492751
`"C"` if it is a C function, `"main"` if it is the main
27502752
part of a chunk, and `"tail"` if it was a function that
27512753
did a tail call. In the latter case, Lua has no other
27522754
information about the function.
2753-
`currentline` the current line where the given function is executing.
2755+
- `currentline` the current line where the given function is executing.
27542756
When no line information is available, `currentline` is
27552757
set to -1.
2756-
`name` a reasonable name for the given function. Because
2758+
- `name` a reasonable name for the given function. Because
27572759
functions in Lua are first-class values, they do not have
27582760
a fixed name: some functions may be the value of multiple
27592761
global variables, while others may be stored only in a
27602762
table field. The `lua_getinfo` function checks how the
27612763
function was called to find a suitable name. If it cannot
27622764
find a name, then `name` is set to `NULL`.
2763-
`namewhat` explains the `name` field. The value of `namewhat` can be
2765+
- `namewhat` explains the `name` field. The value of `namewhat` can be
27642766
`"global"`, `"local"`, `"method"`, `"field"`,
27652767
`"upvalue"`, or `""` (the empty string), according to how
27662768
the function was called. (Lua uses the empty string when

0 commit comments

Comments
 (0)