aboutsummaryrefslogtreecommitdiff
path: root/scripts/gen_vimdoc.py
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2023-07-06 22:47:27 +0200
committerJustin M. Keyes <justinkz@gmail.com>2023-07-08 15:06:36 +0200
commitd2e44da516816e2616b531886eb9ba7f4c271fb4 (patch)
tree4b1fb0e796810f67a36488019fc5ea3474ca79d9 /scripts/gen_vimdoc.py
parent3a721820c39b7524a2e6d6a73774498104a38962 (diff)
downloadrneovim-d2e44da516816e2616b531886eb9ba7f4c271fb4.tar.gz
rneovim-d2e44da516816e2616b531886eb9ba7f4c271fb4.tar.bz2
rneovim-d2e44da516816e2616b531886eb9ba7f4c271fb4.zip
docs: gather @notes items into one section
related: 21eacbfef399
Diffstat (limited to 'scripts/gen_vimdoc.py')
-rwxr-xr-xscripts/gen_vimdoc.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py
index eea56840ef..8ad6442f3b 100755
--- a/scripts/gen_vimdoc.py
+++ b/scripts/gen_vimdoc.py
@@ -585,10 +585,12 @@ def render_node(n, text, prefix='', indent='', width=text_width - indentation,
indent=indent, width=width))
i = i + 1
elif n.nodeName == 'simplesect' and 'note' == n.getAttribute('kind'):
- text += '\nNote:\n '
+ text += ind(' ')
for c in n.childNodes:
- text += render_node(c, text, indent=' ', width=width)
- text += '\n'
+ if is_blank(render_node(c, text, prefix='• ', indent=' ', width=width)):
+ continue
+ text += render_node(c, text, prefix='• ', indent=' ', width=width)
+ # text += '\n'
elif n.nodeName == 'simplesect' and 'warning' == n.getAttribute('kind'):
text += 'Warning:\n '
for c in n.childNodes:
@@ -620,6 +622,7 @@ def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=F
Keys:
'text': Text from this <para> element
+ 'note': List of @note strings
'params': <parameterlist> map
'return': List of @return strings
'seealso': List of @see strings
@@ -627,6 +630,7 @@ def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=F
"""
chunks = {
'text': '',
+ 'note': [],
'params': collections.OrderedDict(),
'return': [],
'seealso': [],
@@ -635,6 +639,7 @@ def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=F
# Ordered dict of ordered lists.
groups = collections.OrderedDict([
+ ('note', []),
('params', []),
('return', []),
('seealso', []),
@@ -645,7 +650,6 @@ def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=F
# nodes to appear together.
text = ''
kind = ''
- last = ''
if is_inline(parent):
# Flatten inline text from a tree of non-block nodes.
text = doc_wrap(render_node(parent, "", fmt_vimhelp=fmt_vimhelp),
@@ -658,13 +662,14 @@ def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=F
elif child.nodeName == 'xrefsect':
groups['xrefs'].append(child)
elif child.nodeName == 'simplesect':
- last = kind
kind = child.getAttribute('kind')
- if kind == 'return' or (kind == 'note' and last == 'return'):
+ if kind == 'note':
+ groups['note'].append(child)
+ elif kind == 'return':
groups['return'].append(child)
elif kind == 'see':
groups['seealso'].append(child)
- elif kind in ('note', 'warning'):
+ elif kind == 'warning':
text += render_node(child, text, indent=indent,
width=width, fmt_vimhelp=fmt_vimhelp)
else:
@@ -689,6 +694,9 @@ def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=F
if len(groups['params']) > 0:
for child in groups['params']:
update_params_map(child, ret_map=chunks['params'], width=width)
+ for child in groups['note']:
+ chunks['note'].append(render_node(
+ child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp).rstrip())
for child in groups['return']:
chunks['return'].append(render_node(
child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp))
@@ -741,6 +749,10 @@ def fmt_node_as_vimhelp(parent, width=text_width - indentation, indent='',
# Generate text from the gathered items.
chunks = [para['text']]
+ if len(para['note']) > 0:
+ chunks.append('\nNote: ~')
+ for s in para['note']:
+ chunks.append(s)
if len(para['params']) > 0 and has_nonexcluded_params(para['params']):
chunks.append('\nParameters: ~')
chunks.append(fmt_param_doc(para['params']))