diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gen_vimdoc.py | 76 | ||||
-rw-r--r-- | scripts/lua2dox.lua | 21 | ||||
-rwxr-xr-x | scripts/pvscheck.sh | 2 |
3 files changed, 88 insertions, 11 deletions
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index b4d896fecc..d46306d41a 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -186,6 +186,48 @@ CONFIG = { 'module_override': {}, 'append_only': [], }, + 'treesitter': { + 'mode': 'lua', + 'filename': 'treesitter.txt', + 'section_start_token': '*lua-treesitter-core*', + 'section_order': [ + 'treesitter.lua', + 'language.lua', + 'query.lua', + 'highlighter.lua', + 'languagetree.lua', + 'health.lua', + ], + 'files': ' '.join([ + os.path.join(base_dir, 'runtime/lua/vim/treesitter.lua'), + os.path.join(base_dir, 'runtime/lua/vim/treesitter/'), + ]), + 'file_patterns': '*.lua', + 'fn_name_prefix': '', + 'section_name': {}, + 'section_fmt': lambda name: ( + 'Lua module: vim.treesitter' + if name.lower() == 'treesitter' + else f'Lua module: vim.treesitter.{name.lower()}'), + 'helptag_fmt': lambda name: ( + '*lua-treesitter-core*' + if name.lower() == 'treesitter' + else f'*treesitter-{name.lower()}*'), + 'fn_helptag_fmt': lambda fstem, name: ( + f'*{name}()*' + if name != 'new' + else f'*{fstem}.{name}()*'), + # 'fn_helptag_fmt': lambda fstem, name: ( + # f'*vim.treesitter.{name}()*' + # if fstem == 'treesitter' + # else ( + # '*vim.lsp.client*' + # # HACK. TODO(justinmk): class/structure support in lua2dox + # if 'lsp.client' == f'{fstem}.{name}' + # else f'*vim.lsp.{fstem}.{name}()*')), + 'module_override': {}, + 'append_only': [], + } } param_exclude = ( @@ -666,15 +708,6 @@ def extract_from_xml(filename, target, width): annotations = filter(None, map(lambda x: annotation_map.get(x), annotations.split())) - if not fmt_vimhelp: - pass - else: - fstem = '?' - if '.' in compoundname: - fstem = compoundname.split('.')[0] - fstem = CONFIG[target]['module_override'].get(fstem, fstem) - vimtag = CONFIG[target]['fn_helptag_fmt'](fstem, name) - params = [] type_length = 0 @@ -695,17 +728,37 @@ def extract_from_xml(filename, target, width): if fmt_vimhelp and param_type.endswith('*'): param_type = param_type.strip('* ') param_name = '*' + param_name + type_length = max(type_length, len(param_type)) params.append((param_type, param_name)) + # Handle Object Oriented style functions here. + # We make sure they have "self" in the parameters, + # and a parent function + if return_type.startswith('function') \ + and len(return_type.split(' ')) >= 2 \ + and any(x[1] == 'self' for x in params): + split_return = return_type.split(' ') + name = f'{split_return[1]}:{name}' + c_args = [] for param_type, param_name in params: c_args.append((' ' if fmt_vimhelp else '') + ( '%s %s' % (param_type.ljust(type_length), param_name)).strip()) + if not fmt_vimhelp: + pass + else: + fstem = '?' + if '.' in compoundname: + fstem = compoundname.split('.')[0] + fstem = CONFIG[target]['module_override'].get(fstem, fstem) + vimtag = CONFIG[target]['fn_helptag_fmt'](fstem, name) + prefix = '%s(' % name suffix = '%s)' % ', '.join('{%s}' % a[1] for a in params if a[0] not in ('void', 'Error')) + if not fmt_vimhelp: c_decl = '%s %s(%s);' % (return_type, name, ', '.join(c_args)) signature = prefix + suffix @@ -774,7 +827,9 @@ def extract_from_xml(filename, target, width): xrefs.clear() - fns = collections.OrderedDict(sorted(fns.items())) + 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) @@ -1002,6 +1057,7 @@ def main(config, args): title, helptag, section_doc = sections.pop(filename) except KeyError: msg(f'warning: empty docs, skipping (target={target}): {filename}') + msg(f' existing docs: {sections.keys()}') continue i += 1 if filename not in CONFIG[target]['append_only']: diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 1dc4c0a5a0..0b36a1e061 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -491,6 +491,27 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename) end end + -- Big hax + if string.find(fn, ":") then + -- TODO: We need to add a first parameter of "SELF" here + -- local colon_place = string.find(fn, ":") + -- local name = string.sub(fn, 1, colon_place) + fn = fn:gsub(":", ".", 1) + outStream:writeln("/// @param self") + + local paren_start = string.find(fn, "(", 1, true) + local paren_finish = string.find(fn, ")", 1, true) + + -- Nothing in between the parens + local comma + if paren_finish == paren_start + 1 then + comma = "" + else + comma = ", " + end + fn = string.sub(fn, 1, paren_start) .. "self" .. comma .. string.sub(fn, paren_start + 1) + end + -- add vanilla function outStream:writeln(fn_type .. 'function ' .. fn .. '{}') end diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index f054f6e6fe..f3371b485e 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -389,7 +389,7 @@ run_analysis() {( detect_url() { local url="${1:-detect}" if test "$url" = detect ; then - curl --silent -L 'https://www.viva64.com/en/pvs-studio-download/' \ + curl --silent -L 'https://pvs-studio.com/en/pvs-studio/download-all/' \ | grep -o 'https\{0,1\}://[^"<>]\{1,\}/pvs-studio[^/"<>]*-x86_64\.tgz' \ || echo FAILED else |