fix(docs-html): keycodes, taglinks, column_heading

Problem:
- Docs HTML: "foo ~" headings (column_heading) are not aligned with
  their table columns/contents because the leading whitespace is not
  emitted.
- taglinks starting with hyphen like |-x| were not recognized.
- keycodes like `<foo>` and `CTRL-x` were not recognized.
- ToC is not scrollable.

Solution:
- Add ws() to the column_heading case.
- Update help parser to latest version
  - supports `keycode`
  - fixes for taglink, argument
- Update .toc CSS. https://github.com/neovim/neovim.github.io/issues/297

fix https://github.com/neovim/neovim.github.io/issues/297
This commit is contained in:
Justin M. Keyes
2022-10-05 01:13:12 +02:00
parent 2c08ab5369
commit 6d74676848
16 changed files with 112 additions and 107 deletions

View File

@@ -201,8 +201,8 @@ set(TREESITTER_LUA_SHA256 564594fe0ffd2f2fb3578a15019b723e1bc94ac82cb6a0103a6b3b
set(TREESITTER_VIM_URL https://github.com/vigoux/tree-sitter-viml/archive/v0.2.0.tar.gz) set(TREESITTER_VIM_URL https://github.com/vigoux/tree-sitter-viml/archive/v0.2.0.tar.gz)
set(TREESITTER_VIM_SHA256 608dcc31a7948cb66ae7f45494620e2e9face1af75598205541f80d782ec4501) set(TREESITTER_VIM_SHA256 608dcc31a7948cb66ae7f45494620e2e9face1af75598205541f80d782ec4501)
set(TREESITTER_HELP_URL https://github.com/neovim/tree-sitter-vimdoc/archive/c27e3e21a54f6d90dfb791f37d90eab5b28de971.tar.gz) set(TREESITTER_HELP_URL https://github.com/neovim/tree-sitter-vimdoc/archive/d5950211e725fe7f5af50a5eea1b47adfc02ceb2.tar.gz)
set(TREESITTER_HELP_SHA256 54a6a5b52a395097775f06f96ac1e1c9efdab10243550a467e1198a286b8c59c) set(TREESITTER_HELP_SHA256 a5282abda813b976d445665865b9668fbb097f6ce1c554681d15dfd2b24f0692)
set(TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.20.7.tar.gz) set(TREESITTER_URL https://github.com/tree-sitter/tree-sitter/archive/v0.20.7.tar.gz)
set(TREESITTER_SHA256 b355e968ec2d0241bbd96748e00a9038f83968f85d822ecb9940cbe4c42e182e) set(TREESITTER_SHA256 b355e968ec2d0241bbd96748e00a9038f83968f85d822ecb9940cbe4c42e182e)

View File

@@ -590,6 +590,7 @@ FileChangedShell When Vim notices that the modification time of
- executing a shell command - executing a shell command
- |:checktime| - |:checktime|
- |FocusGained| - |FocusGained|
Not used when 'autoread' is set and the buffer Not used when 'autoread' is set and the buffer
was not changed. If a FileChangedShell was not changed. If a FileChangedShell
autocommand exists the warning message and autocommand exists the warning message and

View File

@@ -48,21 +48,22 @@ a job channel using RPC, bytes can still be read over its stderr. Similarly,
only bytes can be written to Nvim's own stderr. only bytes can be written to Nvim's own stderr.
*channel-callback* *channel-callback*
on_stdout({chan-id}, {data}, {name}) *on_stdout* - on_stdout({chan-id}, {data}, {name}) *on_stdout*
on_stderr({chan-id}, {data}, {name}) *on_stderr* - on_stderr({chan-id}, {data}, {name}) *on_stderr*
on_stdin({chan-id}, {data}, {name}) *on_stdin* - on_stdin({chan-id}, {data}, {name}) *on_stdin*
on_data({chan-id}, {data}, {name}) *on_data* - on_data({chan-id}, {data}, {name}) *on_data*
Scripts can react to channel activity (received data) via callback Scripts can react to channel activity (received data) via callback
functions assigned to the `on_stdout`, `on_stderr`, `on_stdin`, or functions assigned to the `on_stdout`, `on_stderr`, `on_stdin`, or
`on_data` option keys. Callbacks should be fast: avoid potentially `on_data` option keys. Callbacks should be fast: avoid potentially
slow/expensive work. slow/expensive work.
Parameters: ~ Parameters: ~
{chan-id} Channel handle. |channel-id| - {chan-id} Channel handle. |channel-id|
{data} Raw data (|readfile()|-style list of strings) read from - {data} Raw data (|readfile()|-style list of strings) read from
the channel. EOF is a single-item list: `['']`. First and the channel. EOF is a single-item list: `['']`. First and
last items may be partial lines! |channel-lines| last items may be partial lines! |channel-lines|
{name} Stream name (string) like "stdout", so the same function - {name} Stream name (string) like "stdout", so the same function
can handle multiple streams. Event names depend on how the can handle multiple streams. Event names depend on how the
channel was opened and in what mode/protocol. channel was opened and in what mode/protocol.
@@ -83,13 +84,14 @@ on_data({chan-id}, {data}, {name}) *on_data*
the final `['']` emitted at EOF): the final `['']` emitted at EOF):
- `foobar` may arrive as `['fo'], ['obar']` - `foobar` may arrive as `['fo'], ['obar']`
- `foo\nbar` may arrive as - `foo\nbar` may arrive as
`['foo','bar']` - `['foo','bar']`
or `['foo',''], ['bar']` - or `['foo',''], ['bar']`
or `['foo'], ['','bar']` - or `['foo'], ['','bar']`
or `['fo'], ['o','bar']` - or `['fo'], ['o','bar']`
There are two ways to deal with this: There are two ways to deal with this:
1. To wait for the entire output, use |channel-buffered| mode. - 1. To wait for the entire output, use |channel-buffered| mode.
2. To read line-by-line, use the following code: > - 2. To read line-by-line, use the following code: >
let s:lines = [''] let s:lines = ['']
func! s:on_event(job_id, data, event) dict func! s:on_event(job_id, data, event) dict
let eof = (a:data == ['']) let eof = (a:data == [''])

View File

@@ -51,7 +51,7 @@ for a complete list.
To enable them, assign a value to the option. For example, to turn one on: To enable them, assign a value to the option. For example, to turn one on:
> >
> let g:ada_standard_types = 1 > let g:ada_standard_types = 1
>
To disable them use ":unlet". Example: To disable them use ":unlet". Example:
> >
> unlet g:ada_standard_types > unlet g:ada_standard_types

View File

@@ -308,7 +308,7 @@ These names for keys are used in the documentation. They can also be used
with the ":map" command. with the ":map" command.
notation meaning equivalent decimal value(s) ~ notation meaning equivalent decimal value(s) ~
----------------------------------------------------------------------- ----------------------------------------------------------------------- ~
<Nul> zero CTRL-@ 0 (stored as 10) *<Nul>* <Nul> zero CTRL-@ 0 (stored as 10) *<Nul>*
<BS> backspace CTRL-H 8 *backspace* <BS> backspace CTRL-H 8 *backspace*
<Tab> tab CTRL-I 9 *tab* *Tab* <Tab> tab CTRL-I 9 *tab* *Tab*
@@ -530,12 +530,12 @@ Ex :vi -- -- -- -- --
-- not possible -- not possible
*1 Go from Normal mode to Insert mode by giving the command "i", "I", "a", * 1 Go from Normal mode to Insert mode by giving the command "i", "I", "a",
"A", "o", "O", "c", "C", "s" or S". "A", "o", "O", "c", "C", "s" or S".
*2 Go from Visual mode to Normal mode by giving a non-movement command, which * 2 Go from Visual mode to Normal mode by giving a non-movement command, which
causes the command to be executed, or by hitting <Esc> "v", "V" or "CTRL-V" causes the command to be executed, or by hitting <Esc> "v", "V" or "CTRL-V"
(see |v_v|), which just stops Visual mode without side effects. (see |v_v|), which just stops Visual mode without side effects.
*3 Go from Command-line mode to Normal mode by: * 3 Go from Command-line mode to Normal mode by:
- Hitting <CR> or <NL>, which causes the entered command to be executed. - Hitting <CR> or <NL>, which causes the entered command to be executed.
- Deleting the complete line (e.g., with CTRL-U) and giving a final <BS>. - Deleting the complete line (e.g., with CTRL-U) and giving a final <BS>.
- Hitting CTRL-C or <Esc>, which quits the command-line without executing - Hitting CTRL-C or <Esc>, which quits the command-line without executing
@@ -543,15 +543,15 @@ Ex :vi -- -- -- -- --
In the last case <Esc> may be the character defined with the 'wildchar' In the last case <Esc> may be the character defined with the 'wildchar'
option, in which case it will start command-line completion. You can option, in which case it will start command-line completion. You can
ignore that and type <Esc> again. ignore that and type <Esc> again.
*4 Go from Normal to Select mode by: * 4 Go from Normal to Select mode by:
- use the mouse to select text while 'selectmode' contains "mouse" - use the mouse to select text while 'selectmode' contains "mouse"
- use a non-printable command to move the cursor while keeping the Shift - use a non-printable command to move the cursor while keeping the Shift
key pressed, and the 'selectmode' option contains "key" key pressed, and the 'selectmode' option contains "key"
- use "v", "V" or "CTRL-V" while 'selectmode' contains "cmd" - use "v", "V" or "CTRL-V" while 'selectmode' contains "cmd"
- use "gh", "gH" or "g CTRL-H" |g_CTRL-H| - use "gh", "gH" or "g CTRL-H" |g_CTRL-H|
*5 Go from Select mode to Normal mode by using a non-printable command to move * 5 Go from Select mode to Normal mode by using a non-printable command to move
the cursor, without keeping the Shift key pressed. the cursor, without keeping the Shift key pressed.
*6 Go from Select mode to Insert mode by typing a printable character. The * 6 Go from Select mode to Insert mode by typing a printable character. The
selection is deleted and the character is inserted. selection is deleted and the character is inserted.
*CTRL-\_CTRL-N* *i_CTRL-\_CTRL-N* *c_CTRL-\_CTRL-N* *CTRL-\_CTRL-N* *i_CTRL-\_CTRL-N* *c_CTRL-\_CTRL-N*

View File

@@ -24,7 +24,6 @@ Type |gO| to see the table of contents.
============================================================================== ==============================================================================
1 INTRODUCTION *luaref-intro* 1 INTRODUCTION *luaref-intro*
==============================================================================
Lua is an extension programming language designed to support general Lua is an extension programming language designed to support general
procedural programming with data description facilities. It also offers good procedural programming with data description facilities. It also offers good
@@ -1504,7 +1503,6 @@ When you run it, it produces the following output:
============================================================================== ==============================================================================
3 THE APPLICATION PROGRAM INTERFACE *luaref-API* 3 THE APPLICATION PROGRAM INTERFACE *luaref-API*
==============================================================================
This section describes the C API for Lua, that is, the set of C functions This section describes the C API for Lua, that is, the set of C functions
available to the host program to communicate with Lua. All API functions and available to the host program to communicate with Lua. All API functions and
@@ -2979,7 +2977,6 @@ lua_setupvalue *lua_setupvalue()*
============================================================================== ==============================================================================
4 THE AUXILIARY LIBRARY *luaref-aux* 4 THE AUXILIARY LIBRARY *luaref-aux*
==============================================================================
The auxiliary library provides several convenient functions to interface C The auxiliary library provides several convenient functions to interface C
with Lua. While the basic API provides the primitive functions for all with Lua. While the basic API provides the primitive functions for all
@@ -3511,7 +3508,6 @@ luaL_where *luaL_where()*
============================================================================== ==============================================================================
5 STANDARD LIBRARIES *luaref-Lib* 5 STANDARD LIBRARIES *luaref-Lib*
==============================================================================
The standard libraries provide useful functions that are implemented directly The standard libraries provide useful functions that are implemented directly
through the C API. Some of these functions provide essential services to the through the C API. Some of these functions provide essential services to the
@@ -4064,7 +4060,7 @@ string.gmatch({s}, {pattern}) *string.gmatch()*
end end
< <
string.gsub({s}, {pattern}, {repl} [, {n}]) *string.gsu{b}()* string.gsub({s}, {pattern}, {repl} [, {n}]) *string.gsub()*
Returns a copy of {s} in which all occurrences of the {pattern} have Returns a copy of {s} in which all occurrences of the {pattern} have
been replaced by a replacement string specified by {repl}, which may been replaced by a replacement string specified by {repl}, which may
be a string, a table, or a function. `gsub` also returns, as its be a string, a table, or a function. `gsub` also returns, as its
@@ -4831,7 +4827,6 @@ debug.traceback([{thread},] [{message}] [,{level}]) *debug.traceback()*
============================================================================== ==============================================================================
A BIBLIOGRAPHY *luaref-bibliography* A BIBLIOGRAPHY *luaref-bibliography*
==============================================================================
This help file is a minor adaptation from this main reference: This help file is a minor adaptation from this main reference:
@@ -4858,7 +4853,6 @@ Lua is discussed in these references:
============================================================================== ==============================================================================
B COPYRIGHT & LICENSES *luaref-copyright* B COPYRIGHT & LICENSES *luaref-copyright*
==============================================================================
This help file has the same copyright and license as Lua 5.1 and the Lua 5.1 This help file has the same copyright and license as Lua 5.1 and the Lua 5.1
manual: manual:
@@ -4885,7 +4879,6 @@ SOFTWARE.
============================================================================== ==============================================================================
C LUAREF DOC *luarefvim* *luarefvimdoc* *luaref-help* *luaref-doc* C LUAREF DOC *luarefvim* *luarefvimdoc* *luaref-help* *luaref-doc*
==============================================================================
This is a Vim help file containing a reference for Lua 5.1, and it is -- with This is a Vim help file containing a reference for Lua 5.1, and it is -- with
a few exceptions and adaptations -- a copy of the Lua 5.1 Reference Manual a few exceptions and adaptations -- a copy of the Lua 5.1 Reference Manual

View File

@@ -334,8 +334,8 @@ Vim will automatically convert from one to another encoding in several places:
"utf-8" (requires a gettext version that supports this). "utf-8" (requires a gettext version that supports this).
- When reading a Vim script where |:scriptencoding| is different from - When reading a Vim script where |:scriptencoding| is different from
"utf-8". "utf-8".
Most of these require the |+iconv| feature. Conversion for reading and Most of these require iconv. Conversion for reading and writing files may
writing files may also be specified with the 'charconvert' option. also be specified with the 'charconvert' option.
Useful utilities for converting the charset: Useful utilities for converting the charset:
All: iconv All: iconv

View File

@@ -3920,9 +3920,9 @@ A jump table for the options with a short description can be found at |Q_op|.
`:lgrepadd`, `:cfile`, `:cgetfile`, `:caddfile`, `:lfile`, `:lgetfile`, `:lgrepadd`, `:cfile`, `:cgetfile`, `:caddfile`, `:lfile`, `:lgetfile`,
and `:laddfile`. and `:laddfile`.
This would be mostly useful when you use MS-Windows. If |+iconv| is This would be mostly useful when you use MS-Windows. If iconv is
enabled and GNU libiconv is used, setting 'makeencoding' to "char" has enabled, setting 'makeencoding' to "char" has the same effect as
the same effect as setting to the system locale encoding. Example: > setting to the system locale encoding. Example: >
:set makeencoding=char " system locale is used :set makeencoding=char " system locale is used
< <
*'makeprg'* *'mp'* *'makeprg'* *'mp'*

View File

@@ -63,16 +63,16 @@ msgpack#is_uint({msgpack-value}) *msgpack#is_uint()*
*msgpack#strftime* *msgpack#strftime*
msgpack#strftime({format}, {msgpack-integer}) *msgpack#strftime()* msgpack#strftime({format}, {msgpack-integer}) *msgpack#strftime()*
Same as |strftime()|, but second argument may be Same as |strftime()|, but second argument may be
|msgpack-special-dict|. Requires |+python| or |+python3| to really |msgpack-special-dict|. Requires |Python| to really work with
work with |msgpack-special-dict|s. |msgpack-special-dict|s.
*msgpack#strptime* *msgpack#strptime*
msgpack#strptime({format}, {time}) *msgpack#strptime()* msgpack#strptime({format}, {time}) *msgpack#strptime()*
Reverse of |msgpack#strftime()|: for any time and format Reverse of |msgpack#strftime()|: for any time and format
|msgpack#equal|( |msgpack#strptime|(format, |msgpack#strftime|(format, |msgpack#equal|( |msgpack#strptime|(format, |msgpack#strftime|(format,
time)), time) be true. Requires |+python| or |+python3|, without it time)), time) be true. Requires ||Python|, without it only supports
only supports non-|msgpack-special-dict| nonnegative times and format non-|msgpack-special-dict| nonnegative times and format equal to
equal to `%Y-%m-%dT%H:%M:%S`. `%Y-%m-%dT%H:%M:%S`.
msgpack#int_dict_to_str({msgpack-special-int}) *msgpack#int_dict_to_str()* msgpack#int_dict_to_str({msgpack-special-int}) *msgpack#int_dict_to_str()*
Function which converts |msgpack-special-dict| integer value to Function which converts |msgpack-special-dict| integer value to

View File

@@ -35,7 +35,7 @@ filename One or more file names. The first one will be the current
no other options or "+command" argument can follow. no other options or "+command" argument can follow.
*--* *--*
- Alias for stdin (standard input). `-` Alias for stdin (standard input).
Example: > Example: >
echo text | nvim - file echo text | nvim - file
< "text" is read into buffer 1, "file" is opened as buffer 2. < "text" is read into buffer 1, "file" is opened as buffer 2.
@@ -1182,7 +1182,7 @@ exactly four MessagePack objects:
encoding Binary, effective 'encoding' value. encoding Binary, effective 'encoding' value.
max_kbyte Integer, effective |shada-s| limit value. max_kbyte Integer, effective |shada-s| limit value.
pid Integer, instance process ID. pid Integer, instance process ID.
* It is allowed to have any number of `*` It is allowed to have any number of
additional keys with any data. additional keys with any data.
2 (SearchPattern) Map containing data describing last used search or 2 (SearchPattern) Map containing data describing last used search or
substitute pattern. Normally ShaDa file contains two substitute pattern. Normally ShaDa file contains two
@@ -1213,7 +1213,7 @@ exactly four MessagePack objects:
sp Binary N/A Actual pattern. Required. sp Binary N/A Actual pattern. Required.
sb Boolean false True if search direction is sb Boolean false True if search direction is
backward. backward.
* any none Other keys are allowed for `*` any none Other keys are allowed for
compatibility reasons, see compatibility reasons, see
|shada-compatibility|. |shada-compatibility|.
3 (SubString) Array containing last |:substitute| replacement string. 3 (SubString) Array containing last |:substitute| replacement string.
@@ -1284,7 +1284,7 @@ exactly four MessagePack objects:
GlobalMark and LocalMark GlobalMark and LocalMark
entries. entries.
f Binary N/A File name. Required. f Binary N/A File name. Required.
* any none Other keys are allowed for `*` any none Other keys are allowed for
compatibility reasons, see compatibility reasons, see
|shada-compatibility|. |shada-compatibility|.
9 (BufferList) Array containing maps. Each map in the array 9 (BufferList) Array containing maps. Each map in the array
@@ -1294,10 +1294,10 @@ exactly four MessagePack objects:
greater then zero. greater then zero.
c UInteger 0 Position column number. c UInteger 0 Position column number.
f Binary N/A File name. Required. f Binary N/A File name. Required.
* any none Other keys are allowed for `*` any none Other keys are allowed for
compatibility reasons, see compatibility reasons, see
|shada-compatibility|. |shada-compatibility|.
* (Unknown) Any other entry type is allowed for compatibility `*` (Unknown) Any other entry type is allowed for compatibility
reasons, see |shada-compatibility|. reasons, see |shada-compatibility|.
*E575* *E576* *E575* *E576*

View File

@@ -134,7 +134,7 @@ assert_match({pattern}, {actual} [, {msg}])
When {pattern} does not match {actual} an error message is When {pattern} does not match {actual} an error message is
added to |v:errors|. Also see |assert-return|. added to |v:errors|. Also see |assert-return|.
{pattern} is used as with |=~|: The matching is always done {pattern} is used as with |expr-=~|: The matching is always done
like 'magic' was set and 'cpoptions' is empty, no matter what like 'magic' was set and 'cpoptions' is empty, no matter what
the actual value of 'magic' or 'cpoptions' is. the actual value of 'magic' or 'cpoptions' is.

View File

@@ -1074,8 +1074,8 @@ Various: *various-functions*
wordcount() get byte/word/char count of buffer wordcount() get byte/word/char count of buffer
luaeval() evaluate |Lua| expression luaeval() evaluate |Lua| expression
py3eval() evaluate Python expression (|+python3|) py3eval() evaluate |Python| expression
pyeval() evaluate Python expression (|+python|) pyeval() evaluate |Python| expression
pyxeval() evaluate |python_x| expression pyxeval() evaluate |python_x| expression
rubyeval() evaluate |Ruby| expression rubyeval() evaluate |Ruby| expression

View File

@@ -5,7 +5,7 @@
Table Of Contents *user-manual* Table Of Contents *user-manual*
============================================================================== ==============================================================================
Overview ~ Overview
Getting Started Getting Started
|usr_01.txt| About the manuals |usr_01.txt| About the manuals
@@ -52,7 +52,7 @@ The user manual is online:
https://neovim.io/doc/user https://neovim.io/doc/user
============================================================================== ==============================================================================
Getting Started ~ Getting Started
Read this from start to end to learn the essential commands. Read this from start to end to learn the essential commands.
@@ -167,7 +167,7 @@ Read this from start to end to learn the essential commands.
|12.8| Find where a word is used |12.8| Find where a word is used
============================================================================== ==============================================================================
Editing Effectively ~ Editing Effectively
Subjects that can be read independently. Subjects that can be read independently.
@@ -275,7 +275,7 @@ Subjects that can be read independently.
|32.4| Time travelling |32.4| Time travelling
============================================================================== ==============================================================================
Tuning Vim ~ Tuning Vim
Make Vim work as you like it. Make Vim work as you like it.

View File

@@ -82,27 +82,24 @@ centralized reference of the differences.
Default Mouse ~ Default Mouse ~
*default-mouse* *disable-mouse* *default-mouse* *disable-mouse*
By default the mouse is enabled. The right button click opens |popup-menu| By default the mouse is enabled, and <RightMouse> opens a |popup-menu| with
with standard actions, such as "Cut", "Copy" and "Paste". standard actions ("Cut", "Copy", "Paste", …). Mouse is NOT enabled in
|command-mode| or the |more-prompt|, so you can temporarily disable it just by
typing ":".
If you don't like this you can add to your |config| any of the following: If you don't like this you can disable the mouse in your |config| using any of
the following:
- ignore mouse completely > - Disable mouse completely by unsetting the 'mouse' option: >
set mouse= set mouse=
< - Pressing <RightMouse> extends selection instead of showing popup-menu: >
- no |popup-menu| but the right button extends selection >
set mousemodel=extend set mousemodel=extend
> - Pressing <A-LeftMouse> releases mouse until the cursor moves: >
- pressing ALT+LeftMouse releases mouse until main cursor moves > nnoremap <A-LeftMouse> <Cmd>
nnoremap <M-LeftMouse> <Cmd>
\ set mouse=<Bar> \ set mouse=<Bar>
\ echo 'mouse OFF until next cursor-move'<Bar> \ echo 'mouse OFF until next cursor-move'<Bar>
\ autocmd CursorMoved * ++once set mouse&<Bar> \ autocmd CursorMoved * ++once set mouse&<Bar>
\ echo 'mouse ON'<CR> \ echo 'mouse ON'<CR>
< <
Also, mouse is not in use in |command-mode| or at |more-prompt|. So if you
need to copy/paste with your terminal then just pressing ':' makes Nvim to
release the mouse cursor temporarily.
Default Mappings ~ Default Mappings ~
*default-mappings* *default-mappings*

View File

@@ -208,7 +208,7 @@ local function get_helppage(f)
return 'index.html' return 'index.html'
end end
return f:gsub('%.txt$', '.html') return (f:gsub('%.txt$', '.html'))
end end
-- Counts leading spaces (tab=8) to decide the indent size of multiline text. -- Counts leading spaces (tab=8) to decide the indent size of multiline text.
@@ -255,9 +255,13 @@ end
-- Returns true if the given invalid tagname is a false positive. -- Returns true if the given invalid tagname is a false positive.
local function ignore_invalid(s) local function ignore_invalid(s)
return not not (
exclude_invalid[s]
-- Strings like |~/====| appear in various places and the parser thinks they are links, but they -- Strings like |~/====| appear in various places and the parser thinks they are links, but they
-- are just table borders. -- are just table borders.
return not not (s:find('===') or exclude_invalid[s]) or s:find('===')
or s:find('---')
)
end end
local function ignore_parse_error(s) local function ignore_parse_error(s)
@@ -281,10 +285,14 @@ end
local function validate_link(node, bufnr, fname) local function validate_link(node, bufnr, fname)
local helppage, tagname = get_tagname(node:child(1), bufnr) local helppage, tagname = get_tagname(node:child(1), bufnr)
if not has_ancestor(node, 'column_heading') and not node:has_error() and not tagmap[tagname] and not ignore_invalid(tagname) then local ignored = false
if not tagmap[tagname] then
ignored = has_ancestor(node, 'column_heading') or node:has_error() or ignore_invalid(tagname)
if not ignored then
invalid_links[tagname] = vim.fs.basename(fname) invalid_links[tagname] = vim.fs.basename(fname)
end end
return helppage, tagname end
return helppage, tagname, ignored
end end
-- Traverses the tree at `root` and checks that |tag| links point to valid helptags. -- Traverses the tree at `root` and checks that |tag| links point to valid helptags.
@@ -325,7 +333,7 @@ local function visit_validate(root, level, lang_tree, opt, stats)
invalid_urls[text] = vim.fs.basename(opt.fname) invalid_urls[text] = vim.fs.basename(opt.fname)
end end
elseif node_name == 'taglink' or node_name == 'optionlink' then elseif node_name == 'taglink' or node_name == 'optionlink' then
local _, _ = validate_link(root, opt.buf, opt.fname) local _, _, _ = validate_link(root, opt.buf, opt.fname)
end end
end end
@@ -341,7 +349,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
-- Parent kind (string). -- Parent kind (string).
local parent = root:parent() and root:parent():type() or nil local parent = root:parent() and root:parent():type() or nil
local text = '' local text = ''
local toplevel = level < 1 local trimmed
local function node_text(node) local function node_text(node)
return vim.treesitter.get_node_text(node or root, opt.buf) return vim.treesitter.get_node_text(node or root, opt.buf)
end end
@@ -352,6 +360,8 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
if root:named_child_count() == 0 or node_name == 'ERROR' then if root:named_child_count() == 0 or node_name == 'ERROR' then
text = node_text() text = node_text()
trimmed = html_esc(trim(text))
text = html_esc(text)
else else
-- Process children and join them with whitespace. -- Process children and join them with whitespace.
for node, _ in root:iter_children() do for node, _ in root:iter_children() do
@@ -360,8 +370,8 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
text = string.format('%s%s', text, r) text = string.format('%s%s', text, r)
end end
end end
trimmed = trim(text)
end end
local trimmed = trim(text)
if node_name == 'help_file' then -- root node if node_name == 'help_file' then -- root node
return text return text
@@ -369,7 +379,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
local fixed_url, removed_chars = fix_url(trimmed) local fixed_url, removed_chars = fix_url(trimmed)
return ('%s<a href="%s">%s</a>%s'):format(ws(), fixed_url, fixed_url, removed_chars) return ('%s<a href="%s">%s</a>%s'):format(ws(), fixed_url, fixed_url, removed_chars)
elseif node_name == 'word' or node_name == 'uppercase_name' then elseif node_name == 'word' or node_name == 'uppercase_name' then
return html_esc(text) return text
elseif node_name == 'h1' or node_name == 'h2' or node_name == 'h3' then elseif node_name == 'h1' or node_name == 'h2' or node_name == 'h3' then
if is_noise(text, stats.noise_lines) then if is_noise(text, stats.noise_lines) then
return '' -- Discard common "noise" lines. return '' -- Discard common "noise" lines.
@@ -387,7 +397,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
if root:has_error() then if root:has_error() then
return text return text
end end
return ('<div class="help-column_heading">%s</div>'):format(trimmed) return ('<div class="help-column_heading">%s%s</div>'):format(ws(), trimmed)
elseif node_name == 'block' then elseif node_name == 'block' then
if is_blank(text) then if is_blank(text) then
return '' return ''
@@ -425,28 +435,28 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
return string.format('<div class="help-li" style="%s">%s</div>', margin, text) return string.format('<div class="help-li" style="%s">%s</div>', margin, text)
elseif node_name == 'taglink' or node_name == 'optionlink' then elseif node_name == 'taglink' or node_name == 'optionlink' then
if root:has_error() then local helppage, tagname, ignored = validate_link(root, opt.buf, opt.fname)
if ignored then
return text return text
end end
local helppage, tagname = validate_link(root, opt.buf, opt.fname)
return ('%s<a href="%s#%s">%s</a>'):format(ws(), helppage, url_encode(tagname), html_esc(tagname)) return ('%s<a href="%s#%s">%s</a>'):format(ws(), helppage, url_encode(tagname), html_esc(tagname))
elseif node_name == 'codespan' then elseif vim.tbl_contains({'codespan', 'keycode'}, node_name) then
if root:has_error() then if root:has_error() then
return text return text
end end
return ('%s<code>%s</code>'):format(ws(), text) return ('%s<code>%s</code>'):format(ws(), trimmed)
elseif node_name == 'argument' then elseif node_name == 'argument' then
return ('%s<code>{%s}</code>'):format(ws(), text) return ('%s<code>{%s}</code>'):format(ws(), text)
elseif node_name == 'codeblock' then elseif node_name == 'codeblock' then
if is_blank(text) then if is_blank(text) then
return '' return ''
end end
return ('<pre>%s</pre>'):format(html_esc(trim(trim_indent(text), 2))) return ('<pre>%s</pre>'):format(trim(trim_indent(text), 2))
elseif node_name == 'tag' then -- anchor elseif node_name == 'tag' then -- anchor
if root:has_error() then if root:has_error() then
return text return text
end end
local in_heading = (parent == 'h1' or parent == 'h2') local in_heading = vim.tbl_count({'h1', 'h2', 'h3'}, parent)
local cssclass = (not in_heading and get_indent(node_text()) > 8) and 'help-tag-right' or 'help-tag' local cssclass = (not in_heading and get_indent(node_text()) > 8) and 'help-tag-right' or 'help-tag'
local tagname = node_text(root:child(1)) local tagname = node_text(root:child(1))
if vim.tbl_count(stats.first_tags) < 2 then if vim.tbl_count(stats.first_tags) < 2 then
@@ -471,12 +481,12 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
end end
-- Store the raw text to give context to the bug report. -- Store the raw text to give context to the bug report.
local sample_text = not toplevel and getbuflinestr(root, opt.buf, 3) or '[top level!]' local sample_text = level > 0 and getbuflinestr(root, opt.buf, 3) or '[top level!]'
table.insert(stats.parse_errors, sample_text) table.insert(stats.parse_errors, sample_text)
return ('<a class="parse-error" target="_blank" title="Report bug... (parse error)" href="%s">%s</a>'):format( return ('<a class="parse-error" target="_blank" title="Report bug... (parse error)" href="%s">%s</a>'):format(
get_bug_url_vimdoc(opt.fname, opt.to_fname, sample_text), trimmed) get_bug_url_vimdoc(opt.fname, opt.to_fname, sample_text), trimmed)
else -- Unknown token. else -- Unknown token.
local sample_text = not toplevel and getbuflinestr(root, opt.buf, 3) or '[top level!]' local sample_text = level > 0 and getbuflinestr(root, opt.buf, 3) or '[top level!]'
return ('<a class="unknown-token" target="_blank" title="Report bug... (unhandled token "%s")" href="%s">%s</a>'):format( return ('<a class="unknown-token" target="_blank" title="Report bug... (unhandled token "%s")" href="%s">%s</a>'):format(
node_name, get_bug_url_nvim(opt.fname, opt.to_fname, sample_text, node_name), trimmed), ('unknown-token:"%s"'):format(node_name) node_name, get_bug_url_nvim(opt.fname, opt.to_fname, sample_text, node_name), trimmed), ('unknown-token:"%s"'):format(node_name)
end end
@@ -751,6 +761,8 @@ local function gen_css(fname)
} }
.toc { .toc {
/* max-width: 12rem; */ /* max-width: 12rem; */
height: 95%; /* Scroll if there are too many items. https://github.com/neovim/neovim.github.io/issues/297 */
overflow: auto; /* Scroll if there are too many items. https://github.com/neovim/neovim.github.io/issues/297 */
} }
.toc > div { .toc > div {
text-overflow: ellipsis; text-overflow: ellipsis;
@@ -809,7 +821,7 @@ local function gen_css(fname)
.help-tag-right { .help-tag-right {
color: var(--tag-color); color: var(--tag-color);
} }
h1 .help-tag, h2 .help-tag { h1 .help-tag, h2 .help-tag, h3 .help-tag {
font-size: smaller; font-size: smaller;
} }
.help-heading { .help-heading {

View File

@@ -21,7 +21,7 @@ describe(':help docs', function()
ok(rv.helpfiles > 100, '>100 :help files', rv.helpfiles) ok(rv.helpfiles > 100, '>100 :help files', rv.helpfiles)
-- Check that parse errors did not increase wildly. -- Check that parse errors did not increase wildly.
-- TODO: Fix all parse errors in :help files. -- TODO: Fix all parse errors in :help files.
ok(rv.err_count < 280, '<280 parse errors', rv.err_count) ok(rv.err_count < 150, '<150 parse errors', rv.err_count)
eq({}, rv.invalid_links, exec_lua([[return 'found invalid :help tag links:\n'..vim.inspect(...)]], rv.invalid_links)) eq({}, rv.invalid_links, exec_lua([[return 'found invalid :help tag links:\n'..vim.inspect(...)]], rv.invalid_links))
end) end)
@@ -43,7 +43,7 @@ describe(':help docs', function()
tmpdir tmpdir
) )
eq(4, #rv.helpfiles) eq(4, #rv.helpfiles)
ok(rv.err_count <= 6, '<=6 parse errors', rv.err_count) ok(rv.err_count <= 1, '<=1 parse errors', rv.err_count)
eq({}, rv.invalid_links, exec_lua([[return 'found invalid :help tag links:\n'..vim.inspect(...)]], rv.invalid_links)) eq({}, rv.invalid_links, exec_lua([[return 'found invalid :help tag links:\n'..vim.inspect(...)]], rv.invalid_links))
end) end)
end) end)