[PATCH 4 of 7] help: inline minirst.format()
Yuya Nishihara
yuya at tcha.org
Wed Aug 22 08:19:52 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at 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).
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)
More information about the Mercurial-devel
mailing list