aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gen_vimdoc.py73
-rw-r--r--scripts/genvimvim.lua9
-rw-r--r--scripts/lintcommit.lua18
-rw-r--r--scripts/lua2dox.lua23
-rwxr-xr-xscripts/update_terminfo.sh6
-rwxr-xr-xscripts/vim-patch.sh4
6 files changed, 80 insertions, 53 deletions
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py
index 57b46a381e..755749cef6 100755
--- a/scripts/gen_vimdoc.py
+++ b/scripts/gen_vimdoc.py
@@ -79,13 +79,11 @@ LOG_LEVELS = {
]
}
-fmt_vimhelp = False # HACK
text_width = 78
script_path = os.path.abspath(__file__)
base_dir = os.path.dirname(os.path.dirname(script_path))
out_dir = os.path.join(base_dir, 'tmp-{target}-doc')
filter_cmd = '%s %s' % (sys.executable, script_path)
-seen_funcs = set()
msgs = [] # Messages to show on exit.
lua2dox_filter = os.path.join(base_dir, 'scripts', 'lua2dox_filter')
@@ -287,11 +285,6 @@ annotation_map = {
}
-# Tracks `xrefsect` titles. As of this writing, used only for separating
-# deprecated functions.
-xrefs = set()
-
-
# Raises an error with details about `o`, if `cond` is in object `o`,
# or if `cond()` is callable and returns True.
def debug_this(o, cond=True):
@@ -485,10 +478,8 @@ def update_params_map(parent, ret_map, width=62):
return ret_map
-def render_node(n, text, prefix='', indent='', width=62):
+def render_node(n, text, prefix='', indent='', width=62, fmt_vimhelp=False):
"""Renders a node as Vim help text, recursively traversing all descendants."""
- global fmt_vimhelp
- global has_seen_preformatted
def ind(s):
return s if fmt_vimhelp else ''
@@ -566,7 +557,7 @@ def render_node(n, text, prefix='', indent='', width=62):
return text
-def para_as_map(parent, indent='', width=62):
+def para_as_map(parent, indent='', width=62, fmt_vimhelp=False):
"""Extracts a Doxygen XML <para> node to a map.
Keys:
@@ -599,7 +590,8 @@ def para_as_map(parent, indent='', width=62):
last = ''
if is_inline(parent):
# Flatten inline text from a tree of non-block nodes.
- text = doc_wrap(render_node(parent, ""), indent=indent, width=width)
+ text = doc_wrap(render_node(parent, "", fmt_vimhelp=fmt_vimhelp),
+ indent=indent, width=width)
else:
prev = None # Previous node
for child in parent.childNodes:
@@ -615,7 +607,8 @@ def para_as_map(parent, indent='', width=62):
elif kind == 'see':
groups['seealso'].append(child)
elif kind in ('note', 'warning'):
- text += render_node(child, text, indent=indent, width=width)
+ text += render_node(child, text, indent=indent,
+ width=width, fmt_vimhelp=fmt_vimhelp)
else:
raise RuntimeError('unhandled simplesect: {}\n{}'.format(
child.nodeName, child.toprettyxml(indent=' ', newl='\n')))
@@ -628,7 +621,8 @@ def para_as_map(parent, indent='', width=62):
and ' ' != text[-1]):
text += ' '
- text += render_node(child, text, indent=indent, width=width)
+ text += render_node(child, text, indent=indent, width=width,
+ fmt_vimhelp=fmt_vimhelp)
prev = child
chunks['text'] += text
@@ -639,10 +633,12 @@ def para_as_map(parent, indent='', width=62):
update_params_map(child, ret_map=chunks['params'], width=width)
for child in groups['return']:
chunks['return'].append(render_node(
- child, '', indent=indent, width=width))
+ child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp))
for child in groups['seealso']:
chunks['seealso'].append(render_node(
- child, '', indent=indent, width=width))
+ child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp))
+
+ xrefs = set()
for child in groups['xrefs']:
# XXX: Add a space (or any char) to `title` here, otherwise xrefs
# ("Deprecated" section) acts very weird...
@@ -652,10 +648,10 @@ def para_as_map(parent, indent='', width=62):
chunks['xrefs'].append(doc_wrap(xrefdesc, prefix='{}: '.format(title),
width=width) + '\n')
- return chunks
+ return chunks, xrefs
-def fmt_node_as_vimhelp(parent, width=62, indent=''):
+def fmt_node_as_vimhelp(parent, width=62, indent='', fmt_vimhelp=False):
"""Renders (nested) Doxygen <para> nodes as Vim :help text.
NB: Blank lines in a docstring manifest as <para> tags.
@@ -678,7 +674,7 @@ def fmt_node_as_vimhelp(parent, width=62, indent=''):
return True
for child in parent.childNodes:
- para = para_as_map(child, indent, width)
+ para, _ = para_as_map(child, indent, width, fmt_vimhelp)
# Generate text from the gathered items.
chunks = [para['text']]
@@ -702,19 +698,16 @@ def fmt_node_as_vimhelp(parent, width=62, indent=''):
return clean_lines('\n'.join(rendered_blocks).strip())
-def extract_from_xml(filename, target, width):
+def extract_from_xml(filename, target, width, fmt_vimhelp):
"""Extracts Doxygen info as maps without formatting the text.
Returns two maps:
1. Functions
2. Deprecated functions
- The `fmt_vimhelp` global controls some special cases for use by
+ The `fmt_vimhelp` variable controls some special cases for use by
fmt_doxygen_xml_as_vimhelp(). (TODO: ugly :)
"""
- global xrefs
- global fmt_vimhelp
- xrefs.clear()
fns = {} # Map of func_name:docstring.
deprecated_fns = {} # Map of func_name:docstring.
@@ -821,16 +814,22 @@ def extract_from_xml(filename, target, width):
signature = prefix + suffix
signature += vimtag.rjust(width - len(signature))
+ # Tracks `xrefsect` titles. As of this writing, used only for separating
+ # deprecated functions.
+ xrefs_all = set()
paras = []
brief_desc = find_first(member, 'briefdescription')
if brief_desc:
for child in brief_desc.childNodes:
- paras.append(para_as_map(child))
+ para, xrefs = para_as_map(child)
+ xrefs_all.update(xrefs)
desc = find_first(member, 'detaileddescription')
if desc:
for child in desc.childNodes:
- paras.append(para_as_map(child))
+ para, xrefs = para_as_map(child)
+ paras.append(para)
+ xrefs_all.update(xrefs)
log.debug(
textwrap.indent(
re.sub(r'\n\s*\n+', '\n',
@@ -846,7 +845,6 @@ def extract_from_xml(filename, target, width):
'seealso': [],
}
if fmt_vimhelp:
- # HACK :(
fn['desc_node'] = desc
fn['brief_desc_node'] = brief_desc
@@ -865,18 +863,16 @@ def extract_from_xml(filename, target, width):
if INCLUDE_C_DECL:
fn['c_decl'] = c_decl
- if 'Deprecated' in str(xrefs):
+ if 'Deprecated' in str(xrefs_all):
deprecated_fns[name] = fn
elif name.startswith(CONFIG[target]['fn_name_prefix']):
fns[name] = fn
- xrefs.clear()
-
fns = collections.OrderedDict(sorted(
fns.items(),
key=lambda key_item_tuple: key_item_tuple[0].lower()))
deprecated_fns = collections.OrderedDict(sorted(deprecated_fns.items()))
- return (fns, deprecated_fns)
+ return fns, deprecated_fns
def fmt_doxygen_xml_as_vimhelp(filename, target):
@@ -886,16 +882,14 @@ def fmt_doxygen_xml_as_vimhelp(filename, target):
1. Vim help text for functions found in `filename`.
2. Vim help text for deprecated functions.
"""
- global fmt_vimhelp
- fmt_vimhelp = True
fns_txt = {} # Map of func_name:vim-help-text.
deprecated_fns_txt = {} # Map of func_name:vim-help-text.
- fns, _ = extract_from_xml(filename, target, width=text_width)
+ fns, _ = extract_from_xml(filename, target, text_width, True)
for name, fn in fns.items():
# Generate Vim :help for parameters.
if fn['desc_node']:
- doc = fmt_node_as_vimhelp(fn['desc_node'])
+ doc = fmt_node_as_vimhelp(fn['desc_node'], fmt_vimhelp=True)
if not doc and fn['brief_desc_node']:
doc = fmt_node_as_vimhelp(fn['brief_desc_node'])
if not doc:
@@ -948,14 +942,9 @@ def fmt_doxygen_xml_as_vimhelp(filename, target):
func_doc = "\n".join(split_lines)
- if 'Deprecated' in xrefs:
- deprecated_fns_txt[name] = func_doc
- elif name.startswith(CONFIG[target]['fn_name_prefix']):
+ if name.startswith(CONFIG[target]['fn_name_prefix']):
fns_txt[name] = func_doc
- xrefs.clear()
-
- fmt_vimhelp = False
return ('\n\n'.join(list(fns_txt.values())),
'\n\n'.join(list(deprecated_fns_txt.values())))
@@ -1059,7 +1048,7 @@ def main(config, args):
xmlfile = os.path.join(base,
'{}.xml'.format(compound.getAttribute('refid')))
# Extract unformatted (*.mpack).
- fn_map, _ = extract_from_xml(xmlfile, target, width=9999)
+ fn_map, _ = extract_from_xml(xmlfile, target, 9999, False)
# Extract formatted (:help).
functions_text, deprecated_text = fmt_doxygen_xml_as_vimhelp(
os.path.join(base, '{}.xml'.format(
diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua
index ff60b6cce7..7e9d649cb4 100644
--- a/scripts/genvimvim.lua
+++ b/scripts/genvimvim.lua
@@ -44,12 +44,13 @@ local function cmd_kw(prev_cmd, cmd)
end
-- Exclude these from the vimCommand keyword list, they are handled specially
--- in syntax/vim.vim (vimAugroupKey, vimAutoCmd). #9327
-local function is_autocmd_cmd(cmd)
+-- in syntax/vim.vim (vimAugroupKey, vimAutoCmd, vimSubst). #9327
+local function is_special_cased_cmd(cmd)
return (cmd == 'augroup'
or cmd == 'autocmd'
or cmd == 'doautocmd'
- or cmd == 'doautoall')
+ or cmd == 'doautoall'
+ or cmd == 'substitute')
end
local vimcmd_start = 'syn keyword vimCommand contained '
@@ -60,7 +61,7 @@ for _, cmd_desc in ipairs(ex_cmds.cmds) do
w('\n' .. vimcmd_start)
end
local cmd = cmd_desc.command
- if cmd:match('%w') and cmd ~= 'z' and not is_autocmd_cmd(cmd) then
+ if cmd:match('%w') and cmd ~= 'z' and not is_special_cased_cmd(cmd) then
w(' ' .. cmd_kw(prev_cmd, cmd))
end
prev_cmd = cmd
diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua
index 6871858a0b..16326cfe66 100644
--- a/scripts/lintcommit.lua
+++ b/scripts/lintcommit.lua
@@ -45,8 +45,13 @@ end
-- Returns nil if the given commit message is valid, or returns a string
-- message explaining why it is invalid.
local function validate_commit(commit_message)
- local commit_split = vim.split(commit_message, ":")
+ -- Return nil if the commit message starts with "fixup" as it signifies it's
+ -- a work in progress and shouldn't be linted yet.
+ if vim.startswith(commit_message, "fixup") then
+ return nil
+ end
+ local commit_split = vim.split(commit_message, ":")
-- Return nil if the type is vim-patch since most of the normal rules don't
-- apply.
if commit_split[1] == "vim-patch" then
@@ -73,7 +78,7 @@ local function validate_commit(commit_message)
-- Check if type is correct
local type = vim.split(before_colon, "%(")[1]
- local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'chore', 'vim-patch'}
+ local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'dist', 'vim-patch'}
if not vim.tbl_contains(allowed_types, type) then
return string.format(
'Invalid commit type "%s". Allowed types are:\n %s',
@@ -176,13 +181,16 @@ function M._test()
['refactor: normal message'] = true,
['revert: normal message'] = true,
['test: normal message'] = true,
- ['chore: normal message'] = true,
+ ['dist: normal message'] = true,
['ci(window): message with scope'] = true,
['ci!: message with breaking change'] = true,
['ci(tui)!: message with scope and breaking change'] = true,
['vim-patch:8.2.3374: Pyret files are not recognized (#15642)'] = true,
['vim-patch:8.1.1195,8.2.{3417,3419}'] = true,
['revert: "ci: use continue-on-error instead of "|| true""'] = true,
+ ['fixup'] = true,
+ ['fixup: commit message'] = true,
+ ['fixup! commit message'] = true,
[':no type before colon 1'] = false,
[' :no type before colon 2'] = false,
[' :no type before colon 3'] = false,
@@ -197,10 +205,10 @@ function M._test()
['ci :extra space before colon'] = false,
['refactor(): empty scope'] = false,
['ci( ): whitespace as scope'] = false,
- ['chore: period at end of sentence.'] = false,
+ ['ci: period at end of sentence.'] = false,
['ci: Starting sentence capitalized'] = false,
['unknown: using unknown type'] = false,
- ['chore: you\'re saying this commit message just goes on and on and on and on and on and on for way too long?'] = false,
+ ['ci: you\'re saying this commit message just goes on and on and on and on and on and on for way too long?'] = false,
}
local failed = 0
diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua
index c32370517c..6a206066b8 100644
--- a/scripts/lua2dox.lua
+++ b/scripts/lua2dox.lua
@@ -403,6 +403,29 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename)
if string.sub(line, 3, 3) == '@' or string.sub(line, 1, 4) == '---@' then -- it's a magic comment
state = 'in_magic_comment'
local magic = string.sub(line, 4 + offset)
+
+ local magic_split = string_split(magic, ' ')
+
+ local type_index = 2
+ if magic_split[1] == 'param' then
+ type_index = type_index + 1
+ end
+
+ if magic_split[type_index] == 'number' or
+ magic_split[type_index] == 'number|nil' or
+ magic_split[type_index] == 'string' or
+ magic_split[type_index] == 'string|nil' or
+ magic_split[type_index] == 'table' or
+ magic_split[type_index] == 'table|nil' or
+ magic_split[type_index] == 'boolean' or
+ magic_split[type_index] == 'boolean|nil' or
+ magic_split[type_index] == 'function' or
+ magic_split[type_index] == 'function|nil'
+ then
+ magic_split[type_index] = '(' .. magic_split[type_index] .. ')'
+ end
+ magic = table.concat(magic_split, ' ')
+
outStream:writeln('/// @' .. magic)
fn_magic = checkComment4fn(fn_magic,magic)
elseif string.sub(line,3,3)=='-' then -- it's a nonmagic doc comment
diff --git a/scripts/update_terminfo.sh b/scripts/update_terminfo.sh
index 0cfc230ca6..8a0937cc8c 100755
--- a/scripts/update_terminfo.sh
+++ b/scripts/update_terminfo.sh
@@ -64,6 +64,8 @@ cat > "$target" <<EOF
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
+// uncrustify:off
+
//
// Generated by scripts/update_terminfo.sh and $(tic -V)
//
@@ -84,8 +86,8 @@ for term in $sorted_terms; do
infocmp -L -1 -A "$db" "$term" | sed -e '1d' -e 's#^#// #' | tr '\t' ' '
printf 'static const int8_t %s[] = {\n' "${entries[$term]}"
printf ' '
- od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ',' | tr -d '\n'
- printf ' // NOLINT\n};\n'
+ od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ','
+ printf '};\n'
done >> "$target"
cat >> "$target" <<EOF
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index 57f51d9d46..e7e8f0b274 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -239,6 +239,10 @@ preprocess_patch() {
LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/highlight\(\.[ch]\)/\1\/highlight_group\2/g' \
"$file" > "$file".tmp && mv "$file".tmp "$file"
+ # Rename keymap.h to keycodes.h
+ LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/keymap\.h/\1\/keycodes.h/g' \
+ "$file" > "$file".tmp && mv "$file".tmp "$file"
+
# Rename test_urls.vim to check_urls.vim
LC_ALL=C sed -e 's@\( [ab]\)/runtime/doc/test\(_urls\.vim\)@\1/scripts/check\2@g' \
"$file" > "$file".tmp && mv "$file".tmp "$file"