From de672b6d7a3a8e4bd46878525f243368a849e89f Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Thu, 3 Feb 2022 16:28:27 +0100 Subject: chore(gen_vimdoc): remove duplicate extmark.c entry --- scripts/gen_vimdoc.py | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 3e9fb21039..61fa5971a4 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -96,7 +96,6 @@ CONFIG = { 'win_config.c', 'tabpage.c', 'ui.c', - 'extmark.c', ], # List of files/directories for doxygen to read, separated by blanks 'files': os.path.join(base_dir, 'src/nvim/api'), -- cgit From 03e189d1a1d34353c9385ab499e158b57c792024 Mon Sep 17 00:00:00 2001 From: Dundar Göc Date: Wed, 2 Feb 2022 21:20:50 +0100 Subject: chore(gen_vimdoc): correct minimum python version --- scripts/gen_vimdoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 61fa5971a4..36768953f9 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -52,7 +52,7 @@ import logging from xml.dom import minidom -MIN_PYTHON_VERSION = (3, 5) +MIN_PYTHON_VERSION = (3, 6) if sys.version_info < MIN_PYTHON_VERSION: print("requires Python {}.{}+".format(*MIN_PYTHON_VERSION)) -- cgit From 991e472881bf29805982b402c1a010cde051ded3 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 28 May 2021 15:45:34 -0400 Subject: feat(lua): add api and lua autocmds --- scripts/gen_vimdoc.py | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 36768953f9..7b6d974181 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -95,6 +95,7 @@ CONFIG = { 'window.c', 'win_config.c', 'tabpage.c', + 'autocmd.c', 'ui.c', ], # List of files/directories for doxygen to read, separated by blanks -- cgit From 80e6f81862d943b2d31639a0e437b6abdff3373c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Mar 2022 21:16:21 +0800 Subject: docs(lua): reference runtime/lua/vim/_editor.lua --- scripts/gen_vimdoc.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 7b6d974181..af49d57492 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -124,7 +124,7 @@ CONFIG = { 'filename': 'lua.txt', 'section_start_token': '*lua-vim*', 'section_order': [ - 'vim.lua', + '_editor.lua', 'shared.lua', 'uri.lua', 'ui.lua', @@ -132,7 +132,7 @@ CONFIG = { 'keymap.lua', ], 'files': ' '.join([ - os.path.join(base_dir, 'src/nvim/lua/vim.lua'), + os.path.join(base_dir, 'runtime/lua/vim/_editor.lua'), os.path.join(base_dir, 'runtime/lua/vim/shared.lua'), os.path.join(base_dir, 'runtime/lua/vim/uri.lua'), os.path.join(base_dir, 'runtime/lua/vim/ui.lua'), @@ -144,9 +144,18 @@ CONFIG = { 'section_name': { 'lsp.lua': 'core', }, - 'section_fmt': lambda name: f'Lua module: {name.lower()}', - 'helptag_fmt': lambda name: f'*lua-{name.lower()}*', - 'fn_helptag_fmt': lambda fstem, name: f'*{fstem}.{name}()*', + 'section_fmt': lambda name: ( + 'Lua module: vim' + if name.lower() == '_editor' + else f'Lua module: {name.lower()}'), + 'helptag_fmt': lambda name: ( + '*lua-vim*' + if name.lower() == '_editor' + else f'*lua-{name.lower()}*'), + 'fn_helptag_fmt': lambda fstem, name: ( + f'*vim.{name}()*' + if fstem.lower() == '_editor' + else f'*{fstem}.{name}()*'), 'module_override': { # `shared` functions are exposed on the `vim` module. 'shared': 'vim', -- cgit From 2d28c40ef9842ab7cfb9b307bfc07b1d11c7aca8 Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sun, 13 Mar 2022 21:03:38 +0900 Subject: refactor(gen_vimdoc): detect `section_start_token` automatically --- scripts/gen_vimdoc.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index af49d57492..2b119bc589 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -84,8 +84,6 @@ CONFIG = { 'api': { 'mode': 'c', 'filename': 'api.txt', - # String used to find the start of the generated part of the doc. - 'section_start_token': '*api-global*', # Section ordering. 'section_order': [ 'vim.c', @@ -122,7 +120,6 @@ CONFIG = { 'lua': { 'mode': 'lua', 'filename': 'lua.txt', - 'section_start_token': '*lua-vim*', 'section_order': [ '_editor.lua', 'shared.lua', @@ -171,7 +168,6 @@ CONFIG = { 'lsp': { 'mode': 'lua', 'filename': 'lsp.txt', - 'section_start_token': '*lsp-core*', 'section_order': [ 'lsp.lua', 'buf.lua', @@ -214,7 +210,6 @@ CONFIG = { 'diagnostic': { 'mode': 'lua', 'filename': 'diagnostic.txt', - 'section_start_token': '*diagnostic-api*', 'section_order': [ 'diagnostic.lua', ], @@ -231,7 +226,6 @@ CONFIG = { 'treesitter': { 'mode': 'lua', 'filename': 'treesitter.txt', - 'section_start_token': '*lua-treesitter-core*', 'section_order': [ 'treesitter.lua', 'language.lua', @@ -1096,6 +1090,7 @@ def main(config, args): raise RuntimeError( 'found new modules "{}"; update the "section_order" map'.format( set(sections).difference(CONFIG[target]['section_order']))) + first_section_tag = sections[CONFIG[target]['section_order'][0]][1] docs = '' @@ -1121,7 +1116,7 @@ def main(config, args): doc_file = os.path.join(base_dir, 'runtime', 'doc', CONFIG[target]['filename']) - delete_lines_below(doc_file, CONFIG[target]['section_start_token']) + delete_lines_below(doc_file, first_section_tag) with open(doc_file, 'ab') as fp: fp.write(docs.encode('utf8')) -- cgit From cf4786ddfae40a3a0d00e52f4861a2c7ee19e243 Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sun, 13 Mar 2022 21:13:42 +0900 Subject: chore(gen_vimdoc): call `delete_lines_below` only if the file exists Previously, `delete_lines_below` would raise `FileNotFoundError` when adding a new file to `CONFIG` and you had to manually write a file with help tag of the first section as placeholder. This change relieves you of that need. --- scripts/gen_vimdoc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 2b119bc589..a537f80aca 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -1116,7 +1116,8 @@ def main(config, args): doc_file = os.path.join(base_dir, 'runtime', 'doc', CONFIG[target]['filename']) - delete_lines_below(doc_file, first_section_tag) + if os.path.exists(doc_file): + delete_lines_below(doc_file, first_section_tag) with open(doc_file, 'ab') as fp: fp.write(docs.encode('utf8')) -- cgit From 334a16c79113eec1cb9024a71631e1baa4473582 Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sun, 13 Mar 2022 21:30:06 +0900 Subject: refactor(gen_vimdoc): simplify `files` in `CONFIG` --- scripts/gen_vimdoc.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index a537f80aca..433fec828e 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -96,8 +96,8 @@ CONFIG = { 'autocmd.c', 'ui.c', ], - # List of files/directories for doxygen to read, separated by blanks - 'files': os.path.join(base_dir, 'src/nvim/api'), + # List of files/directories for doxygen to read, relative to `base_dir` + 'files': ['src/nvim/api'], # file patterns used by doxygen 'file_patterns': '*.h *.c', # Only function with this prefix are considered @@ -128,14 +128,14 @@ CONFIG = { 'filetype.lua', 'keymap.lua', ], - 'files': ' '.join([ - os.path.join(base_dir, 'runtime/lua/vim/_editor.lua'), - os.path.join(base_dir, 'runtime/lua/vim/shared.lua'), - os.path.join(base_dir, 'runtime/lua/vim/uri.lua'), - os.path.join(base_dir, 'runtime/lua/vim/ui.lua'), - os.path.join(base_dir, 'runtime/lua/vim/filetype.lua'), - os.path.join(base_dir, 'runtime/lua/vim/keymap.lua'), - ]), + 'files': [ + 'runtime/lua/vim/_editor.lua', + 'runtime/lua/vim/shared.lua', + 'runtime/lua/vim/uri.lua', + 'runtime/lua/vim/ui.lua', + 'runtime/lua/vim/filetype.lua', + 'runtime/lua/vim/keymap.lua', + ], 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': { @@ -181,10 +181,10 @@ CONFIG = { 'sync.lua', 'protocol.lua', ], - 'files': ' '.join([ - os.path.join(base_dir, 'runtime/lua/vim/lsp'), - os.path.join(base_dir, 'runtime/lua/vim/lsp.lua'), - ]), + 'files': [ + 'runtime/lua/vim/lsp', + 'runtime/lua/vim/lsp.lua', + ], 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': {'lsp.lua': 'lsp'}, @@ -213,7 +213,7 @@ CONFIG = { 'section_order': [ 'diagnostic.lua', ], - 'files': os.path.join(base_dir, 'runtime/lua/vim/diagnostic.lua'), + 'files': ['runtime/lua/vim/diagnostic.lua'], 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': {'diagnostic.lua': 'diagnostic'}, @@ -233,10 +233,10 @@ CONFIG = { 'highlighter.lua', 'languagetree.lua', ], - 'files': ' '.join([ - os.path.join(base_dir, 'runtime/lua/vim/treesitter.lua'), - os.path.join(base_dir, 'runtime/lua/vim/treesitter/'), - ]), + 'files': [ + 'runtime/lua/vim/treesitter.lua', + 'runtime/lua/vim/treesitter/', + ], 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': {}, @@ -1000,7 +1000,8 @@ def main(config, args): stderr=(subprocess.STDOUT if debug else subprocess.DEVNULL)) p.communicate( config.format( - input=CONFIG[target]['files'], + input=' '.join( + [f'"{file}"' for file in CONFIG[target]['files']]), output=output_dir, filter=filter_cmd, file_patterns=CONFIG[target]['file_patterns']) -- cgit From be2def41006f1f6395be546cc95c3ada32e7966a Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sun, 13 Mar 2022 21:36:46 +0900 Subject: chore(gen_vimdoc): fall back to `brief_desc_node` when `desc_node` is empty --- scripts/gen_vimdoc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 433fec828e..1b7f88cb2a 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -843,7 +843,9 @@ def extract_from_xml(filename, target, width): 'seealso': [], } if fmt_vimhelp: - fn['desc_node'] = desc # HACK :( + # HACK :( + fn['desc_node'] = desc + fn['brief_desc_node'] = brief_desc for m in paras: if 'text' in m: @@ -891,6 +893,8 @@ def fmt_doxygen_xml_as_vimhelp(filename, target): # Generate Vim :help for parameters. if fn['desc_node']: doc = fmt_node_as_vimhelp(fn['desc_node']) + if not doc and fn['brief_desc_node']: + doc = fmt_node_as_vimhelp(fn['brief_desc_node']) if not doc: doc = 'TODO: Documentation' -- cgit From ecc36c3d1c3952541eb1ad667850573ecedd4d36 Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Sun, 13 Mar 2022 21:48:14 +0900 Subject: docs: remove extra whitespaces --- scripts/gen_vimdoc.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 1b7f88cb2a..7152f1005f 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -343,14 +343,6 @@ def self_or_child(n): return n.childNodes[0] -def clean_text(text): - """Cleans text. - - Only cleans superfluous whitespace at the moment. - """ - return ' '.join(text.split()).strip() - - def clean_lines(text): """Removes superfluous lines. @@ -371,12 +363,12 @@ def get_text(n, preformatted=False): if n.nodeName == 'computeroutput': for node in n.childNodes: text += get_text(node) - return '`{}` '.format(text) + return '`{}`'.format(text) for node in n.childNodes: if node.nodeType == node.TEXT_NODE: - text += node.data if preformatted else clean_text(node.data) + text += node.data elif node.nodeType == node.ELEMENT_NODE: - text += ' ' + get_text(node, preformatted) + text += get_text(node, preformatted) return text -- cgit From 7502f1cae0abe9dfdf71e39b8812f269f5ed83b7 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Sun, 1 May 2022 01:16:16 +0200 Subject: docs(api): more API attributes #18336 --- scripts/gen_vimdoc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 7152f1005f..f37198e96a 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -271,8 +271,10 @@ param_exclude = ( # Annotations are displayed as line items after API function descriptions. annotation_map = { - 'FUNC_API_FAST': '{fast}', + 'FUNC_API_FAST': '|api-fast|', 'FUNC_API_CHECK_TEXTLOCK': 'not allowed when |textlock| is active', + 'FUNC_API_REMOTE_ONLY': '|RPC| only', + 'FUNC_API_LUA_ONLY': '|vim.api| only', } -- cgit From 5fc251daebe2eda9e2bf032db877e4183065753f Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Sun, 1 May 2022 17:53:22 +0200 Subject: build(gen_vimdoc): abort if doxygen version is too old There have been a few instances where developers got confused as to why their generated documentation differs from the one generated by the CI. More often than not, the reason is that their doxygen version is older than 1.9.0, which is the current minimum version. Having a simple version check will help save future developers avoid this problem. --- scripts/gen_vimdoc.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index f37198e96a..8d38382405 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -53,11 +53,19 @@ import logging from xml.dom import minidom MIN_PYTHON_VERSION = (3, 6) +MIN_DOXYGEN_VERSION = (1, 9, 0) if sys.version_info < MIN_PYTHON_VERSION: print("requires Python {}.{}+".format(*MIN_PYTHON_VERSION)) sys.exit(1) +doxygen_version = tuple([int(i) for i in subprocess.check_output(["doxygen", "-v"], + universal_newlines=True).split('.')]) + +if doxygen_version < MIN_DOXYGEN_VERSION: + print("requires Doxygen {}.{}.{}+".format(*MIN_DOXYGEN_VERSION)) + sys.exit(1) + # DEBUG = ('DEBUG' in os.environ) INCLUDE_C_DECL = ('INCLUDE_C_DECL' in os.environ) INCLUDE_DEPRECATED = ('INCLUDE_DEPRECATED' in os.environ) -- cgit From 649cdc14ba1f352c14179bd177f6156bd322cbed Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Mon, 2 May 2022 10:58:40 +0200 Subject: ci(gen_vimdoc): handle edge case when checking doxygen version When checking the version of the doxygen installed from conda the output has the following format: 1.9.2 (ee54ebd4f0ad83d9c44f19a459146de64d0ffba2*) This would cause an error in the "Missing API docs" CI job. This fix will correctly parse the doxygen version for both stable releases ("1.9.2") as well as the version with the git commit hash attached. --- scripts/gen_vimdoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 8d38382405..101f0cf5ff 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -60,7 +60,7 @@ if sys.version_info < MIN_PYTHON_VERSION: sys.exit(1) doxygen_version = tuple([int(i) for i in subprocess.check_output(["doxygen", "-v"], - universal_newlines=True).split('.')]) + universal_newlines=True).split()[0].split('.')]) if doxygen_version < MIN_DOXYGEN_VERSION: print("requires Doxygen {}.{}.{}+".format(*MIN_DOXYGEN_VERSION)) -- cgit From 59162584b1d03e7739afb5116ad96e2c16c7b271 Mon Sep 17 00:00:00 2001 From: Dundar Goc Date: Mon, 2 May 2022 11:14:34 +0200 Subject: build(gen_vimdoc): print user's doxygen version if it's too old @theHamsta suggested in https://github.com/neovim/neovim/pull/18348#discussion_r862594173 to also print the users doxygen version if the version is too old. --- scripts/gen_vimdoc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 101f0cf5ff..57b46a381e 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -63,7 +63,8 @@ doxygen_version = tuple([int(i) for i in subprocess.check_output(["doxygen", "-v universal_newlines=True).split()[0].split('.')]) if doxygen_version < MIN_DOXYGEN_VERSION: - print("requires Doxygen {}.{}.{}+".format(*MIN_DOXYGEN_VERSION)) + print("\nRequires doxygen {}.{}.{}+".format(*MIN_DOXYGEN_VERSION)) + print("Your doxygen version is {}.{}.{}\n".format(*doxygen_version)) sys.exit(1) # DEBUG = ('DEBUG' in os.environ) -- cgit From b1b58020094a2ffa85e40194b8beb2945396610a Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 15 May 2022 11:23:56 +0200 Subject: build(gen_vimdoc): eliminate non-constant global variables (#17781) --- scripts/gen_vimdoc.py | 73 ++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 42 deletions(-) (limited to 'scripts/gen_vimdoc.py') 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 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 nodes as Vim :help text. NB: Blank lines in a docstring manifest as 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( -- cgit From 67cbaf58c41a3db19c5014587e72d06be9e3d58e Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Sun, 15 May 2022 14:38:19 -0600 Subject: feat(fs): add vim.fs.parents() vim.fs.parents() is a Lua iterator that returns the next parent directory of the given file or directory on each iteration. --- scripts/gen_vimdoc.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 755749cef6..790c2ba52d 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -134,6 +134,7 @@ CONFIG = { 'ui.lua', 'filetype.lua', 'keymap.lua', + 'fs.lua', ], 'files': [ 'runtime/lua/vim/_editor.lua', @@ -142,6 +143,7 @@ CONFIG = { 'runtime/lua/vim/ui.lua', 'runtime/lua/vim/filetype.lua', 'runtime/lua/vim/keymap.lua', + 'runtime/lua/vim/fs.lua', ], 'file_patterns': '*.lua', 'fn_name_prefix': '', @@ -167,6 +169,7 @@ CONFIG = { 'ui': 'vim.ui', 'filetype': 'vim.filetype', 'keymap': 'vim.keymap', + 'fs': 'vim.fs', }, 'append_only': [ 'shared.lua', -- cgit From 612944c5863caabc7b71b66c9deb73a983c69803 Mon Sep 17 00:00:00 2001 From: bfredl Date: Sun, 12 Jun 2022 19:26:43 +0200 Subject: refactor(api): update vimdoc --- scripts/gen_vimdoc.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 790c2ba52d..220b099df5 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -95,6 +95,8 @@ CONFIG = { 'section_order': [ 'vim.c', 'vimscript.c', + 'command.c', + 'options.c', 'buffer.c', 'extmark.c', 'window.c', -- cgit From ece2960f1b2994c58c7978435309e46d241307ac Mon Sep 17 00:00:00 2001 From: Axis <77634274+blankRiot96@users.noreply.github.com> Date: Sat, 25 Jun 2022 15:33:02 +0530 Subject: build(gen_vimdoc): remove needless list creation and unused variable (#19079) build(gen_vimdoc): remove needless list creation --- scripts/gen_vimdoc.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'scripts/gen_vimdoc.py') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 220b099df5..22fd155d32 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -59,8 +59,8 @@ if sys.version_info < MIN_PYTHON_VERSION: print("requires Python {}.{}+".format(*MIN_PYTHON_VERSION)) sys.exit(1) -doxygen_version = tuple([int(i) for i in subprocess.check_output(["doxygen", "-v"], - universal_newlines=True).split()[0].split('.')]) +doxygen_version = tuple((int(i) for i in subprocess.check_output(["doxygen", "-v"], + universal_newlines=True).split()[0].split('.'))) if doxygen_version < MIN_DOXYGEN_VERSION: print("\nRequires doxygen {}.{}.{}+".format(*MIN_DOXYGEN_VERSION)) @@ -1096,7 +1096,6 @@ def main(config, args): docs = '' - i = 0 for filename in CONFIG[target]['section_order']: try: title, helptag, section_doc = sections.pop(filename) @@ -1104,7 +1103,6 @@ def main(config, args): 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']: docs += sep docs += '\n%s%s' % (title, -- cgit