aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_vimdoc.py
diff options
context:
space:
mode:
authorMatthieu Coudron <mcoudron@hotmail.com>2021-02-28 15:49:43 +0100
committerMatthieu Coudron <mcoudron@hotmail.com>2021-03-04 15:44:40 +0100
commit513ac58043ae8273c40bccb154551951e8547505 (patch)
tree85e4a99134988c5e8986021305aa2e8c11ef60e9 /scripts/gen_vimdoc.py
parent55d6699dfd58edb53d32270a5a9a567a48ce7c08 (diff)
downloadrneovim-513ac58043ae8273c40bccb154551951e8547505.tar.gz
rneovim-513ac58043ae8273c40bccb154551951e8547505.tar.bz2
rneovim-513ac58043ae8273c40bccb154551951e8547505.zip
fix: section_name must be a dict {filename:name}
else it was triggering an error during regeneration of the files.
Diffstat (limited to 'scripts/gen_vimdoc.py')
-rwxr-xr-xscripts/gen_vimdoc.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py
index 0507e4b7b6..b4d896fecc 100755
--- a/scripts/gen_vimdoc.py
+++ b/scripts/gen_vimdoc.py
@@ -48,6 +48,7 @@ import textwrap
import subprocess
import collections
import msgpack
+import logging
from xml.dom import minidom
@@ -57,10 +58,18 @@ if sys.version_info < MIN_PYTHON_VERSION:
print("requires Python {}.{}+".format(*MIN_PYTHON_VERSION))
sys.exit(1)
-DEBUG = ('DEBUG' in os.environ)
+# DEBUG = ('DEBUG' in os.environ)
INCLUDE_C_DECL = ('INCLUDE_C_DECL' in os.environ)
INCLUDE_DEPRECATED = ('INCLUDE_DEPRECATED' in os.environ)
+log = logging.getLogger(__name__)
+
+LOG_LEVELS = {
+ logging.getLevelName(level): level for level in [
+ logging.DEBUG, logging.INFO, logging.ERROR
+ ]
+}
+
fmt_vimhelp = False # HACK
text_width = 78
script_path = os.path.abspath(__file__)
@@ -157,7 +166,7 @@ CONFIG = {
]),
'file_patterns': '*.lua',
'fn_name_prefix': '',
- 'section_name': {},
+ 'section_name': {'lsp.lua': 'lsp'},
'section_fmt': lambda name: (
'Lua module: vim.lsp'
if name.lower() == 'lsp'
@@ -726,8 +735,8 @@ def extract_from_xml(filename, target, width):
if desc:
for child in desc.childNodes:
paras.append(para_as_map(child))
- if DEBUG:
- print(textwrap.indent(
+ log.debug(
+ textwrap.indent(
re.sub(r'\n\s*\n+', '\n',
desc.toprettyxml(indent=' ', newl='\n')), ' ' * 16))
@@ -885,12 +894,13 @@ def main(config, args):
os.remove(mpack_file)
output_dir = out_dir.format(target=target)
+ debug = args.log_level >= logging.DEBUG
p = subprocess.Popen(
['doxygen', '-'],
stdin=subprocess.PIPE,
# silence warnings
# runtime/lua/vim/lsp.lua:209: warning: argument 'foo' not found
- stderr=(subprocess.STDOUT if DEBUG else subprocess.DEVNULL))
+ stderr=(subprocess.STDOUT if debug else subprocess.DEVNULL))
p.communicate(
config.format(
input=CONFIG[target]['files'],
@@ -1039,6 +1049,10 @@ def filter_source(filename):
def parse_args():
targets = ', '.join(CONFIG.keys())
ap = argparse.ArgumentParser()
+ ap.add_argument(
+ "--log-level", "-l", choices=LOG_LEVELS.keys(),
+ default=logging.getLevelName(logging.ERROR), help="Set log verbosity"
+ )
ap.add_argument('source_filter', nargs='*',
help="Filter source file(s)")
ap.add_argument('-k', '--keep-tmpfiles', action='store_true',
@@ -1085,6 +1099,10 @@ Doxyfile = textwrap.dedent('''
if __name__ == "__main__":
args = parse_args()
+ print("Setting log level to %s" % args.log_level)
+ args.log_level = LOG_LEVELS[args.log_level]
+ log.setLevel(args.log_level)
+
if len(args.source_filter) > 0:
filter_source(args.source_filter[0])
else: