help: inline minirst.format()
authorYuya Nishihara <yuya@tcha.org>
Sun, 05 Aug 2018 12:06:07 +0900
changeset 39308 9b800601701c
parent 39307 92e9aa38a578
child 39309 0a766cb1092a
help: inline minirst.format() I'm going to make minirst.format() always returns a formatted text, not text | (text, pruned).
mercurial/help.py
--- a/mercurial/help.py	Sun Aug 05 11:43:05 2018 +0900
+++ b/mercurial/help.py	Sun Aug 05 12:06:07 2018 +0900
@@ -672,8 +672,10 @@
     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 @@
         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)