diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-01-09 17:36:46 +0000 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-01-11 16:24:12 +0000 |
commit | 2f9ee9b6cfc61a0504fc0bc22bdf481828e2ea91 (patch) | |
tree | 06884cc40b3f6e7c0dd47f4018c8ba0f671ba610 /scripts/gen_vimdoc.py | |
parent | a767c046f4e6bff1412269d56a8edfe33857d954 (diff) | |
download | rneovim-2f9ee9b6cfc61a0504fc0bc22bdf481828e2ea91.tar.gz rneovim-2f9ee9b6cfc61a0504fc0bc22bdf481828e2ea91.tar.bz2 rneovim-2f9ee9b6cfc61a0504fc0bc22bdf481828e2ea91.zip |
fix(doc): improve doc generation of types using lpeg
Added a lpeg grammar for LuaCATS and use it in lua2dox.lua
Diffstat (limited to 'scripts/gen_vimdoc.py')
-rwxr-xr-x | scripts/gen_vimdoc.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 698336cf3e..01532cc3d3 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -717,12 +717,14 @@ def render_node(n: Element, text: str, prefix='', *, elif n.nodeName in ('para', 'heading'): did_prefix = False for c in n.childNodes: + c_text = render_node(c, text, prefix=(prefix if not did_prefix else ''), indent=indent, width=width) if (is_inline(c) - and '' != get_text(c).strip() + and '' != c_text.strip() and text - and ' ' != text[-1]): + and text[-1] not in (' ', '(', '|') + and not c_text.startswith(')')): text += ' ' - text += render_node(c, text, prefix=(prefix if not did_prefix else ''), indent=indent, width=width) + text += c_text did_prefix = True elif n.nodeName == 'itemizedlist': for c in n.childNodes: @@ -840,15 +842,17 @@ def para_as_map(parent: Element, raise RuntimeError('unhandled simplesect: {}\n{}'.format( child.nodeName, child.toprettyxml(indent=' ', newl='\n'))) else: + child_text = render_node(child, text, indent=indent, width=width) if (prev is not None and is_inline(self_or_child(prev)) and is_inline(self_or_child(child)) and '' != get_text(self_or_child(child)).strip() and text - and ' ' != text[-1]): + and text[-1] not in (' ', '(', '|') + and not child_text.startswith(')')): text += ' ' - text += render_node(child, text, indent=indent, width=width) + text += child_text prev = child chunks['text'] += text |