Patchwork [2,of,2] minirst: handle edge in hunting for parents

login
register
mail settings
Submitter timeless@mozdev.org
Date Sept. 4, 2015, 9:52 a.m.
Message ID <7f972d8f7b8f5365fab2.1441360339@waste.org>
Download mbox | patch
Permalink /patch/10393/
State Accepted
Headers show

Comments

timeless@mozdev.org - Sept. 4, 2015, 9:52 a.m.
# HG changeset patch
# User timeless@mozdev.org
# Date 1441314387 14400
#      Thu Sep 03 17:06:27 2015 -0400
# Node ID 7f972d8f7b8f5365fab2e2247ecc2c9e229b2c5c
# Parent  787c49c6b44fe9338ff4fef7aaf8b6b84fb201fa
minirst: handle edge in hunting for parents

test for "hg help -c config" in help config

``section``
-----------
section text

``def1``
    definition of def1
    $ hg help scope.def1
    should list this paragraph, but not section text below...

section text

``def2``
    definition of def2
    $ hg help scope.def2
    should list this paragraph, but not section text below...

section text
$ hg help scope.section should show everything from the first
section text to this last line.

``section2``
------------
Augie Fackler - Sept. 8, 2015, 4:38 p.m.
On Fri, Sep 04, 2015 at 04:52:19AM -0500, timeless@mozdev.org wrote:
> # HG changeset patch
> # User timeless@mozdev.org
> # Date 1441314387 14400
> #      Thu Sep 03 17:06:27 2015 -0400
> # Node ID 7f972d8f7b8f5365fab2e2247ecc2c9e229b2c5c
> # Parent  787c49c6b44fe9338ff4fef7aaf8b6b84fb201fa
> minirst: handle edge in hunting for parents

queued, thanks

>
> test for "hg help -c config" in help config
>
> ``section``
> -----------
> section text
>
> ``def1``
>     definition of def1
>     $ hg help scope.def1
>     should list this paragraph, but not section text below...
>
> section text
>
> ``def2``
>     definition of def2
>     $ hg help scope.def2
>     should list this paragraph, but not section text below...
>
> section text
> $ hg help scope.section should show everything from the first
> section text to this last line.
>
> ``section2``
> ------------
>
> diff --git a/mercurial/minirst.py b/mercurial/minirst.py
> --- a/mercurial/minirst.py
> +++ b/mercurial/minirst.py
> @@ -741,7 +741,10 @@
>                              break
>                      pointer += 1
>                  if pointer > 1:
> -                    secs.append(('', secs[-pointer][1] + 1, []))
> +                    blevel = secs[-pointer][1]
> +                    if section['type'] != b['type']:
> +                        blevel += 1
> +                    secs.append(('', blevel, []))
>              secs[-1][2].append(b)
>      return secs
>
> diff --git a/tests/test-help.t b/tests/test-help.t
> --- a/tests/test-help.t
> +++ b/tests/test-help.t
> @@ -922,6 +922,11 @@
>        "smtp.host"
>            Host name of mail server, e.g. "mail.example.com".
>
> +Unrelated trailing paragraphs shouldn't be included
> +
> +  $ hg help config.extramsg | grep '^$'
> +
> +
>  Test capitalized section name
>
>    $ hg help scripting.HGPLAIN > /dev/null
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -741,7 +741,10 @@ 
                             break
                     pointer += 1
                 if pointer > 1:
-                    secs.append(('', secs[-pointer][1] + 1, []))
+                    blevel = secs[-pointer][1]
+                    if section['type'] != b['type']:
+                        blevel += 1
+                    secs.append(('', blevel, []))
             secs[-1][2].append(b)
     return secs
 
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -922,6 +922,11 @@ 
       "smtp.host"
           Host name of mail server, e.g. "mail.example.com".
   
+Unrelated trailing paragraphs shouldn't be included
+
+  $ hg help config.extramsg | grep '^$'
+  
+
 Test capitalized section name
 
   $ hg help scripting.HGPLAIN > /dev/null