mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
35ec60f73a
@ -516,6 +516,7 @@ if(NOT BUSTED_OUTPUT_TYPE)
|
||||
endif()
|
||||
|
||||
find_program(LUACHECK_PRG luacheck)
|
||||
find_program(FLAKE8_PRG flake8)
|
||||
find_program(GPERF_PRG gperf)
|
||||
|
||||
include(InstallHelpers)
|
||||
@ -667,6 +668,15 @@ else()
|
||||
COMMENT "lualint: LUACHECK_PRG not defined")
|
||||
endif()
|
||||
|
||||
if(FLAKE8_PRG)
|
||||
add_custom_target(pylint
|
||||
COMMAND ${FLAKE8_PRG} contrib/ scripts/ src/ test/
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
else()
|
||||
add_custom_target(pylint false
|
||||
COMMENT "flake8: FLAKE8_PRG not defined")
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_NAME "Neovim")
|
||||
set(CPACK_PACKAGE_VENDOR "neovim.io")
|
||||
set(CPACK_PACKAGE_VERSION ${NVIM_VERSION_MEDIUM})
|
||||
|
7
Makefile
7
Makefile
@ -138,6 +138,9 @@ functionaltest-lua: | nvim
|
||||
lualint: | build/.ran-cmake deps
|
||||
$(BUILD_CMD) -C build lualint
|
||||
|
||||
pylint: | build/.ran-cmake deps
|
||||
$(BUILD_CMD) -C build pylint
|
||||
|
||||
unittest: | nvim
|
||||
+$(BUILD_CMD) -C build unittest
|
||||
|
||||
@ -179,6 +182,6 @@ appimage:
|
||||
appimage-%:
|
||||
bash scripts/genappimage.sh $*
|
||||
|
||||
lint: check-single-includes clint lualint
|
||||
lint: check-single-includes clint lualint pylint
|
||||
|
||||
.PHONY: test lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix
|
||||
.PHONY: test lualint pylint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage checkprefix
|
||||
|
@ -4,6 +4,7 @@ set -e
|
||||
set -o pipefail
|
||||
|
||||
if [[ "${CI_TARGET}" == lint ]]; then
|
||||
python -m pip -q install --user --upgrade flake8
|
||||
exit
|
||||
fi
|
||||
|
||||
|
@ -9,26 +9,24 @@ source "${CI_DIR}/common/build.sh"
|
||||
source "${CI_DIR}/common/suite.sh"
|
||||
|
||||
enter_suite 'clint'
|
||||
|
||||
run_test 'make clint-full' clint
|
||||
|
||||
exit_suite --continue
|
||||
|
||||
enter_suite 'lualint'
|
||||
|
||||
run_test 'make lualint' lualint
|
||||
exit_suite --continue
|
||||
|
||||
enter_suite 'pylint'
|
||||
run_test 'make pylint' pylint
|
||||
exit_suite --continue
|
||||
|
||||
enter_suite single-includes
|
||||
|
||||
CLICOLOR_FORCE=1 run_test_wd \
|
||||
--allow-hang \
|
||||
10s \
|
||||
'make check-single-includes' \
|
||||
'csi_clean' \
|
||||
single-includes
|
||||
|
||||
exit_suite --continue
|
||||
|
||||
end_tests
|
||||
|
@ -22,8 +22,6 @@ def main(argv):
|
||||
args = argparser.parse_args(argv)
|
||||
|
||||
with args.file:
|
||||
include_dirs = []
|
||||
|
||||
iwyu = Popen(['include-what-you-use', '-xc'] + args.iwyu_args + ['/dev/stdin'],
|
||||
stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||
|
||||
|
@ -81,12 +81,12 @@ SITENAVI_PLAIN = '<p>' + SITENAVI_LINKS_PLAIN + '</p>'
|
||||
SITENAVI_WEB = '<p>' + SITENAVI_LINKS_WEB + '</p>'
|
||||
|
||||
SITENAVI_SEARCH = '<table width="100%"><tbody><tr><td>' + SITENAVI_LINKS_WEB + \
|
||||
'</td><td style="text-align: right; max-width: 25vw"><div class="gcse-searchbox">' \
|
||||
'</div></td></tr></tbody></table><div class="gcse-searchresults"></div>'
|
||||
'</td><td style="text-align: right; max-width: 25vw"><div class="gcse-searchbox">' \
|
||||
'</div></td></tr></tbody></table><div class="gcse-searchresults"></div>'
|
||||
|
||||
TEXTSTART = """
|
||||
<div id="d1">
|
||||
<pre id="sp"> </pre>
|
||||
<pre id="sp">""" + (" " * 80) + """</pre>
|
||||
<div id="d2">
|
||||
<pre>
|
||||
"""
|
||||
@ -152,6 +152,7 @@ RE_SECTION = re.compile(r'[-A-Z .][-A-Z0-9 .()]*(?=\s+\*)')
|
||||
RE_STARTAG = re.compile(r'\s\*([^ \t|]+)\*(?:\s|$)')
|
||||
RE_LOCAL_ADD = re.compile(r'LOCAL ADDITIONS:\s+\*local-additions\*$')
|
||||
|
||||
|
||||
class Link(object):
|
||||
__slots__ = 'link_plain_same', 'link_pipe_same', \
|
||||
'link_plain_foreign', 'link_pipe_foreign', \
|
||||
@ -165,9 +166,10 @@ class Link(object):
|
||||
self.link_pipe_foreign = link_pipe_foreign
|
||||
self.filename = filename
|
||||
|
||||
|
||||
class VimH2H(object):
|
||||
def __init__(self, tags, version=None, is_web_version=True):
|
||||
self._urls = { }
|
||||
self._urls = {}
|
||||
self._version = version
|
||||
self._is_web_version = is_web_version
|
||||
for line in RE_NEWLINE.split(tags):
|
||||
@ -183,6 +185,7 @@ class VimH2H(object):
|
||||
|
||||
def do_add_tag(self, filename, tag):
|
||||
tag_quoted = urllib.parse.quote_plus(tag)
|
||||
|
||||
def mkpart1(doc):
|
||||
return '<a href="' + doc + '#' + tag_quoted + '" class="'
|
||||
part1_same = mkpart1('')
|
||||
@ -192,6 +195,7 @@ class VimH2H(object):
|
||||
doc = filename + '.html'
|
||||
part1_foreign = mkpart1(doc)
|
||||
part2 = '">' + html_escape[tag] + '</a>'
|
||||
|
||||
def mklinks(cssclass):
|
||||
return (part1_same + cssclass + part2,
|
||||
part1_foreign + cssclass + part2)
|
||||
@ -199,9 +203,12 @@ class VimH2H(object):
|
||||
m = RE_LINKWORD.match(tag)
|
||||
if m:
|
||||
opt, ctrl, special = m.groups()
|
||||
if opt is not None: cssclass_plain = 'o'
|
||||
elif ctrl is not None: cssclass_plain = 'k'
|
||||
elif special is not None: cssclass_plain = 's'
|
||||
if opt is not None:
|
||||
cssclass_plain = 'o'
|
||||
elif ctrl is not None:
|
||||
cssclass_plain = 'k'
|
||||
elif special is not None:
|
||||
cssclass_plain = 's'
|
||||
links_plain = mklinks(cssclass_plain)
|
||||
links_pipe = mklinks('l')
|
||||
self._urls[tag] = Link(
|
||||
@ -213,18 +220,23 @@ class VimH2H(object):
|
||||
links = self._urls.get(tag)
|
||||
if links is not None:
|
||||
if links.filename == curr_filename:
|
||||
if css_class == 'l': return links.link_pipe_same
|
||||
else: return links.link_plain_same
|
||||
if css_class == 'l':
|
||||
return links.link_pipe_same
|
||||
else:
|
||||
if css_class == 'l': return links.link_pipe_foreign
|
||||
else: return links.link_plain_foreign
|
||||
return links.link_plain_same
|
||||
else:
|
||||
if css_class == 'l':
|
||||
return links.link_pipe_foreign
|
||||
else:
|
||||
return links.link_plain_foreign
|
||||
elif css_class is not None:
|
||||
return '<span class="' + css_class + '">' + html_escape[tag] + \
|
||||
'</span>'
|
||||
else: return html_escape[tag]
|
||||
else:
|
||||
return html_escape[tag]
|
||||
|
||||
def to_html(self, filename, contents, encoding):
|
||||
out = [ ]
|
||||
out = []
|
||||
|
||||
inexample = 0
|
||||
filename = str(filename)
|
||||
@ -247,7 +259,8 @@ class VimH2H(object):
|
||||
if inexample == 2:
|
||||
if RE_EG_END.match(line):
|
||||
inexample = 0
|
||||
if line[0] == '<': line = line[1:]
|
||||
if line[0] == '<':
|
||||
line = line[1:]
|
||||
else:
|
||||
out.extend(('<span class="e">', html_escape[line],
|
||||
'</span>\n'))
|
||||
@ -300,7 +313,8 @@ class VimH2H(object):
|
||||
if lastpos < len(line):
|
||||
out.append(html_escape[line[lastpos:]])
|
||||
out.append('\n')
|
||||
if inexample == 1: inexample = 2
|
||||
if inexample == 1:
|
||||
inexample = 2
|
||||
|
||||
header = []
|
||||
header.append(HEAD.format(encoding=encoding, filename=filename))
|
||||
@ -318,6 +332,7 @@ class VimH2H(object):
|
||||
header.append(TEXTSTART)
|
||||
return ''.join(chain(header, out, (FOOTER, sitenavi_footer, FOOTER2)))
|
||||
|
||||
|
||||
class HtmlEscCache(dict):
|
||||
def __missing__(self, key):
|
||||
r = key.replace('&', '&') \
|
||||
@ -326,11 +341,10 @@ class HtmlEscCache(dict):
|
||||
self[key] = r
|
||||
return r
|
||||
|
||||
|
||||
html_escape = HtmlEscCache()
|
||||
|
||||
|
||||
|
||||
|
||||
def slurp(filename):
|
||||
try:
|
||||
with open(filename, encoding='UTF-8') as f:
|
||||
@ -340,17 +354,20 @@ def slurp(filename):
|
||||
with open(filename, encoding='latin-1') as f:
|
||||
return f.read(), 'latin-1'
|
||||
|
||||
|
||||
def usage():
|
||||
return "usage: " + sys.argv[0] + " IN_DIR OUT_DIR [BASENAMES...]"
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 3: sys.exit(usage())
|
||||
if len(sys.argv) < 3:
|
||||
sys.exit(usage())
|
||||
|
||||
in_dir = sys.argv[1]
|
||||
out_dir = sys.argv[2]
|
||||
basenames = sys.argv[3:]
|
||||
|
||||
print( "Processing tags...")
|
||||
print("Processing tags...")
|
||||
h2h = VimH2H(slurp(os.path.join(in_dir, 'tags'))[0], is_web_version=False)
|
||||
|
||||
if len(basenames) == 0:
|
||||
@ -358,9 +375,9 @@ def main():
|
||||
|
||||
for basename in basenames:
|
||||
if os.path.splitext(basename)[1] != '.txt' and basename != 'tags':
|
||||
print( "Ignoring " + basename)
|
||||
print("Ignoring " + basename)
|
||||
continue
|
||||
print( "Processing " + basename + "...")
|
||||
print("Processing " + basename + "...")
|
||||
path = os.path.join(in_dir, basename)
|
||||
text, encoding = slurp(path)
|
||||
outpath = os.path.join(out_dir, basename + '.html')
|
||||
@ -368,4 +385,5 @@ def main():
|
||||
of.write(h2h.to_html(basename, text, encoding))
|
||||
of.close()
|
||||
|
||||
|
||||
main()
|
||||
|
@ -36,7 +36,6 @@ import shutil
|
||||
import textwrap
|
||||
import subprocess
|
||||
import collections
|
||||
import pprint
|
||||
|
||||
from xml.dom import minidom
|
||||
|
||||
@ -62,7 +61,7 @@ CONFIG = {
|
||||
# String used to find the start of the generated part of the doc.
|
||||
'section_start_token': '*api-global*',
|
||||
# Section ordering.
|
||||
'section_order' : [
|
||||
'section_order': [
|
||||
'vim.c',
|
||||
'buffer.c',
|
||||
'window.c',
|
||||
@ -82,12 +81,12 @@ CONFIG = {
|
||||
# Module name overrides (for Lua).
|
||||
'module_override': {},
|
||||
# Append the docs for these modules, do not start a new section.
|
||||
'append_only' : [],
|
||||
'append_only': [],
|
||||
},
|
||||
'lua': {
|
||||
'filename': 'if_lua.txt',
|
||||
'section_start_token': '*lua-vim*',
|
||||
'section_order' : [
|
||||
'section_order': [
|
||||
'vim.lua',
|
||||
'shared.lua',
|
||||
],
|
||||
@ -99,9 +98,10 @@ CONFIG = {
|
||||
'func_name_prefix': '',
|
||||
'section_name': {},
|
||||
'module_override': {
|
||||
'shared': 'vim', # `shared` functions are exposed on the `vim` module.
|
||||
# `shared` functions are exposed on the `vim` module.
|
||||
'shared': 'vim',
|
||||
},
|
||||
'append_only' : [
|
||||
'append_only': [
|
||||
'shared.lua',
|
||||
],
|
||||
},
|
||||
@ -121,6 +121,7 @@ annotation_map = {
|
||||
# deprecated functions.
|
||||
xrefs = set()
|
||||
|
||||
|
||||
def debug_this(s, n):
|
||||
o = n if isinstance(n, str) else n.toprettyxml(indent=' ', newl='\n')
|
||||
name = '' if isinstance(n, str) else n.nodeName
|
||||
@ -191,7 +192,7 @@ def len_lastline(text):
|
||||
if -1 == lastnl:
|
||||
return len(text)
|
||||
if '\n' == text[-1]:
|
||||
return lastnl - (1+ text.rfind('\n', 0, lastnl))
|
||||
return lastnl - (1 + text.rfind('\n', 0, lastnl))
|
||||
return len(text) - (1 + lastnl)
|
||||
|
||||
|
||||
@ -209,6 +210,7 @@ def is_inline(n):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def doc_wrap(text, prefix='', width=70, func=False, indent=None):
|
||||
"""Wraps text to `width`.
|
||||
|
||||
@ -237,8 +239,8 @@ def doc_wrap(text, prefix='', width=70, func=False, indent=None):
|
||||
if indent_only:
|
||||
prefix = indent
|
||||
|
||||
tw = textwrap.TextWrapper(break_long_words = False,
|
||||
break_on_hyphens = False,
|
||||
tw = textwrap.TextWrapper(break_long_words=False,
|
||||
break_on_hyphens=False,
|
||||
width=width,
|
||||
initial_indent=prefix,
|
||||
subsequent_indent=indent)
|
||||
@ -292,8 +294,9 @@ def render_params(parent, width=62):
|
||||
out += '{}{}\n'.format(name, desc)
|
||||
return out.rstrip()
|
||||
|
||||
# Renders a node as Vim help text, recursively traversing all descendants.
|
||||
|
||||
def render_node(n, text, prefix='', indent='', width=62):
|
||||
"""Renders a node as Vim help text, recursively traversing all descendants."""
|
||||
text = ''
|
||||
# space_preceding = (len(text) > 0 and ' ' == text[-1][-1])
|
||||
# text += (int(not space_preceding) * ' ')
|
||||
@ -317,7 +320,11 @@ def render_node(n, text, prefix='', indent='', width=62):
|
||||
text += ' [verbatim] {}'.format(get_text(n))
|
||||
elif n.nodeName == 'listitem':
|
||||
for c in n.childNodes:
|
||||
text += indent + prefix + render_node(c, text, indent=indent+(' ' * len(prefix)), width=width)
|
||||
text += (
|
||||
indent
|
||||
+ prefix
|
||||
+ render_node(c, text, indent=indent + (' ' * len(prefix)), width=width)
|
||||
)
|
||||
elif n.nodeName in ('para', 'heading'):
|
||||
for c in n.childNodes:
|
||||
text += render_node(c, text, indent=indent, width=width)
|
||||
@ -356,6 +363,7 @@ def render_node(n, text, prefix='', indent='', width=62):
|
||||
n.nodeName, n.toprettyxml(indent=' ', newl='\n')))
|
||||
return text
|
||||
|
||||
|
||||
def render_para(parent, indent='', width=62):
|
||||
"""Renders Doxygen <para> containing arbitrary nodes.
|
||||
|
||||
@ -407,11 +415,13 @@ def render_para(parent, indent='', width=62):
|
||||
if len(groups['return']) > 0:
|
||||
chunks.append('\nReturn: ~')
|
||||
for child in groups['return']:
|
||||
chunks.append(render_node(child, chunks[-1][-1], indent=indent, width=width))
|
||||
chunks.append(render_node(
|
||||
child, chunks[-1][-1], indent=indent, width=width))
|
||||
if len(groups['seealso']) > 0:
|
||||
chunks.append('\nSee also: ~')
|
||||
for child in groups['seealso']:
|
||||
chunks.append(render_node(child, chunks[-1][-1], indent=indent, width=width))
|
||||
chunks.append(render_node(
|
||||
child, chunks[-1][-1], indent=indent, width=width))
|
||||
for child in groups['xrefs']:
|
||||
title = get_text(get_child(child, 'xreftitle'))
|
||||
xrefs.add(title)
|
||||
@ -587,6 +597,7 @@ def delete_lines_below(filename, tokenstr):
|
||||
with open(filename, 'wt') as fp:
|
||||
fp.writelines(lines[0:i])
|
||||
|
||||
|
||||
def gen_docs(config):
|
||||
"""Generate documentation.
|
||||
|
||||
@ -619,7 +630,8 @@ def gen_docs(config):
|
||||
continue
|
||||
|
||||
groupname = get_text(find_first(compound, 'name'))
|
||||
groupxml = os.path.join(base, '%s.xml' % compound.getAttribute('refid'))
|
||||
groupxml = os.path.join(base, '%s.xml' %
|
||||
compound.getAttribute('refid'))
|
||||
|
||||
desc = find_first(minidom.parse(groupxml), 'detaileddescription')
|
||||
if desc:
|
||||
@ -680,12 +692,15 @@ def gen_docs(config):
|
||||
i = 0
|
||||
for filename in CONFIG[mode]['section_order']:
|
||||
if filename not in sections:
|
||||
raise RuntimeError('found new module "{}"; update the "section_order" map'.format(filename))
|
||||
raise RuntimeError(
|
||||
'found new module "{}"; update the "section_order" map'.format(
|
||||
filename))
|
||||
title, helptag, section_doc = sections.pop(filename)
|
||||
i += 1
|
||||
if filename not in CONFIG[mode]['append_only']:
|
||||
docs += sep
|
||||
docs += '\n%s%s' % (title, helptag.rjust(text_width - len(title)))
|
||||
docs += '\n%s%s' % (title,
|
||||
helptag.rjust(text_width - len(title)))
|
||||
docs += section_doc
|
||||
docs += '\n\n\n'
|
||||
|
||||
|
@ -63,10 +63,10 @@ fname = sys.argv[1]
|
||||
try:
|
||||
filt = sys.argv[2]
|
||||
except IndexError:
|
||||
filt = lambda entry: True
|
||||
def filt(entry): return True
|
||||
else:
|
||||
_filt = filt
|
||||
filt = lambda entry: eval(_filt, globals(), {'entry': entry})
|
||||
def filt(entry): return eval(_filt, globals(), {'entry': entry})
|
||||
|
||||
poswidth = len(str(os.stat(fname).st_size or 1000))
|
||||
|
||||
|
@ -97,7 +97,8 @@ def main(progname, cfname, only_static, move_all):
|
||||
if not generated_existed:
|
||||
lines[include_line:include_line] = [
|
||||
'#ifdef INCLUDE_GENERATED_DECLARATIONS\n',
|
||||
'# include "{0}.generated.h"\n'.format(os.path.relpath(fname, relname)),
|
||||
'# include "{0}.generated.h"\n'.format(
|
||||
os.path.relpath(fname, relname)),
|
||||
'#endif\n',
|
||||
]
|
||||
|
||||
|
13
src/clint.py
13
src/clint.py
@ -2610,9 +2610,13 @@ def CheckBraces(filename, clean_lines, linenum, error):
|
||||
'Brace starting function body must be placed on its own line')
|
||||
else:
|
||||
func_start_linenum = end_linenum + 1
|
||||
while not clean_lines.lines[func_start_linenum] == '{':
|
||||
attrline = Match(r'^((?!# *define).*?)(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+(?:\(\d+(, \d+)*\))?',
|
||||
clean_lines.lines[func_start_linenum])
|
||||
while not clean_lines.lines[func_start_linenum] == "{":
|
||||
attrline = Match(
|
||||
r'^((?!# *define).*?)'
|
||||
r'(?:FUNC_ATTR|FUNC_API|REAL_FATTR)_\w+'
|
||||
r'(?:\(\d+(, \d+)*\))?',
|
||||
clean_lines.lines[func_start_linenum],
|
||||
)
|
||||
if attrline:
|
||||
if len(attrline.group(1)) != 2:
|
||||
error(filename, func_start_linenum,
|
||||
@ -3182,7 +3186,8 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
|
||||
r'|li_(?:next|prev|tv))\b', line)
|
||||
if match:
|
||||
error(filename, linenum, 'runtime/deprecated', 4,
|
||||
'Accessing list_T internals directly is prohibited (hint: see commit d46e37cb4c71)')
|
||||
'Accessing list_T internals directly is prohibited '
|
||||
'(hint: see commit d46e37cb4c71)')
|
||||
|
||||
# Check for suspicious usage of "if" like
|
||||
# } if (a == b) {
|
||||
|
@ -8,6 +8,7 @@ import locale
|
||||
import io
|
||||
import sys
|
||||
|
||||
|
||||
def set_output_encoding(enc=None):
|
||||
"""Set the encoding of stdout and stderr
|
||||
|
||||
@ -29,6 +30,7 @@ def set_output_encoding(enc=None):
|
||||
writer = io.open(fo.fileno(), mode='w', newline='', **kw)
|
||||
write = writer.write # save the original write() function
|
||||
enc = locale.getpreferredencoding()
|
||||
|
||||
def convwrite(s):
|
||||
if isinstance(s, bytes):
|
||||
write(s.decode(enc)) # convert to unistr
|
||||
|
Loading…
Reference in New Issue
Block a user