# HG changeset patch # User timeless@mozdev.org # Date 2015-09-10 14:48:20 # Node ID 1c6f7cc52da9d42c1098b1c0fae6f0e0da627556 # Parent 2e42517129caca9bcf4420e6f466f2205af22d43 minirst: establish leveling for nested definitions diff --git a/mercurial/minirst.py b/mercurial/minirst.py --- a/mercurial/minirst.py +++ b/mercurial/minirst.py @@ -722,6 +722,20 @@ def getsections(blocks): 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: diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -936,6 +936,12 @@ Help subsection: $ 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 '^ "'| \