changeset 26237:1c6f7cc52da9

minirst: establish leveling for nested definitions
author timeless@mozdev.org
date Thu, 10 Sep 2015 10:48:20 -0400
parents 2e42517129ca
children 69da16b366ad
files mercurial/minirst.py tests/test-help.t
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/minirst.py	Sun Sep 13 16:30:21 2015 -0400
+++ b/mercurial/minirst.py	Thu Sep 10 10:48:20 2015 -0400
@@ -722,6 +722,20 @@
                 nest += i
             level = nest.index(i) + 1
             nest = nest[:level]
+            for i in range(1, len(secs) + 1):
+                sec = secs[-i]
+                if sec[1] < level:
+                    break
+                siblings = [a for a in sec[2] if a['type'] == 'definition']
+                if siblings:
+                    siblingindent = siblings[-1]['indent']
+                    indent = b['indent']
+                    if siblingindent < indent:
+                        level += 1
+                        break
+                    elif siblingindent == indent:
+                        level = sec[1]
+                        break
             secs.append((getname(b), level, [b]))
         else:
             if not secs:
--- a/tests/test-help.t	Sun Sep 13 16:30:21 2015 -0400
+++ b/tests/test-help.t	Thu Sep 10 10:48:20 2015 -0400
@@ -936,6 +936,12 @@
   $ hg help config.charsets |grep "Email example:" > /dev/null
   [1]
 
+Show nested definitions
+("profiling.type"[break]"ls"[break]"stat"[break])
+
+  $ hg help config.type | egrep '^$'|wc -l
+  \s*3 (re)
+
 Last item in help config.*:
 
   $ hg help config.`hg help config|grep '^    "'| \