mirror of
https://github.com/neovim/neovim.git
synced 2025-12-08 23:52:39 +00:00
[Backport release-0.8] feat(docs): update parser, HTML gen (#20737)
Note: although the tolerance in help_spec.lua increased, the actual
error count with the new parser decreased by about 20%. The difference
is that the old ignore_parse_error() ignored many more errors with the
old parser.
fix https://github.com/neovim/tree-sitter-vimdoc/issues/37
fix https://github.com/neovim/tree-sitter-vimdoc/issues/44
fix https://github.com/neovim/tree-sitter-vimdoc/issues/47
(cherry picked from commit 10ae8ccbf2)
This commit is contained in:
committed by
GitHub
parent
f76473898d
commit
f73bc880f4
@@ -73,6 +73,23 @@ local exclude_invalid = {
|
||||
["vim.treesitter.start()"] = "treesitter.txt",
|
||||
}
|
||||
|
||||
-- False-positive "invalid URLs".
|
||||
local exclude_invalid_urls = {
|
||||
["http://"] = "usr_23.txt",
|
||||
["http://."] = "usr_23.txt",
|
||||
["http://aspell.net/man-html/Affix-Compression.html"] = "spell.txt",
|
||||
["http://aspell.net/man-html/Phonetic-Code.html"] = "spell.txt",
|
||||
["http://canna.sourceforge.jp/"] = "mbyte.txt",
|
||||
["http://gnuada.sourceforge.net"] = "ft_ada.txt",
|
||||
["http://lua-users.org/wiki/StringLibraryTutorial"] = "lua.txt",
|
||||
["http://michael.toren.net/code/"] = "pi_tar.txt",
|
||||
["http://papp.plan9.de"] = "syntax.txt",
|
||||
["http://wiki.services.openoffice.org/wiki/Dictionaries"] = "spell.txt",
|
||||
["http://www.adapower.com"] = "ft_ada.txt",
|
||||
["http://www.ghostscript.com/"] = "print.txt",
|
||||
["http://www.jclark.com/"] = "quickfix.txt",
|
||||
}
|
||||
|
||||
local function tofile(fname, text)
|
||||
local f = io.open(fname, 'w')
|
||||
if not f then
|
||||
@@ -277,10 +294,13 @@ local function ignore_invalid(s)
|
||||
)
|
||||
end
|
||||
|
||||
local function ignore_parse_error(s)
|
||||
-- Ignore parse errors for unclosed codespan/optionlink/tag.
|
||||
-- This is common in vimdocs and is treated as plaintext by :help.
|
||||
return s:find("^[`'|*]")
|
||||
local function ignore_parse_error(s, fname)
|
||||
local helpfile = vim.fs.basename(fname)
|
||||
return (helpfile == 'pi_netrw.txt'
|
||||
-- Ignore parse errors for unclosed tag.
|
||||
-- This is common in vimdocs and is treated as plaintext by :help.
|
||||
or s:find("^[`'|*]")
|
||||
)
|
||||
end
|
||||
|
||||
local function has_ancestor(node, ancestor_name)
|
||||
@@ -322,7 +342,7 @@ local function validate_url(text, fname)
|
||||
local ignored = false
|
||||
if vim.fs.basename(fname) == 'pi_netrw.txt' then
|
||||
ignored = true
|
||||
elseif text:find('http%:') then
|
||||
elseif text:find('http%:') and not exclude_invalid_urls[text] then
|
||||
invalid_urls[text] = vim.fs.basename(fname)
|
||||
end
|
||||
return ignored
|
||||
@@ -347,7 +367,7 @@ local function visit_validate(root, level, lang_tree, opt, stats)
|
||||
end
|
||||
|
||||
if node_name == 'ERROR' then
|
||||
if ignore_parse_error(text) then
|
||||
if ignore_parse_error(text, opt.fname) then
|
||||
return
|
||||
end
|
||||
-- Store the raw text to give context to the error report.
|
||||
@@ -362,7 +382,8 @@ local function visit_validate(root, level, lang_tree, opt, stats)
|
||||
end
|
||||
end
|
||||
elseif node_name == 'url' then
|
||||
validate_url(text, opt.fname)
|
||||
local fixed_url, _ = fix_url(trim(text))
|
||||
validate_url(fixed_url, opt.fname)
|
||||
elseif node_name == 'taglink' or node_name == 'optionlink' then
|
||||
local _, _, _ = validate_link(root, opt.buf, opt.fname)
|
||||
end
|
||||
@@ -522,7 +543,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats)
|
||||
end
|
||||
return s
|
||||
elseif node_name == 'ERROR' then
|
||||
if ignore_parse_error(trimmed) then
|
||||
if ignore_parse_error(trimmed, opt.fname) then
|
||||
return text
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user