Patchwork [4,of,7] help: inline minirst.format()

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 22, 2018, 12:19 p.m.
Message ID <f2a08652109f187a75d0.1534940392@mimosa>
Download mbox | patch
Permalink /patch/33970/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 22, 2018, 12:19 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1533438367 -32400
#      Sun Aug 05 12:06:07 2018 +0900
# Node ID f2a08652109f187a75d00dd2af76ba51fb7494e1
# Parent  8c4b4d138cd4139dc5e0579bd82bf89eea8ab395
help: inline minirst.format()

I'm going to make minirst.format() always returns a formatted text, not
text | (text, pruned).

Patch

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -672,8 +672,10 @@  def formattedhelp(ui, commands, name, ke
     text = help_(ui, commands, name,
                  subtopic=subtopic, unknowncmd=unknowncmd, full=full, **opts)
 
-    formatted, pruned = minirst.format(text, textwidth, keep=keep,
-                                       section=section)
+    blocks, pruned = minirst.parse(text, keep=keep)
+    if section:
+        blocks = minirst.filtersections(blocks, section)
+    formatted = minirst.formatplain(blocks, textwidth)
 
     # We could have been given a weird ".foo" section without a name
     # to look for, or we could have simply failed to found "foo.bar"
@@ -685,6 +687,7 @@  def formattedhelp(ui, commands, name, ke
         keep.append('omitted')
     else:
         keep.append('notomitted')
-    formatted, pruned = minirst.format(text, textwidth, keep=keep,
-                                       section=section)
-    return formatted
+    blocks, pruned = minirst.parse(text, keep=keep)
+    if section:
+        blocks = minirst.filtersections(blocks, section)
+    return minirst.formatplain(blocks, textwidth)