minirst: add decorateblocks search helper
authorMatt Mackall <mpm@selenic.com>
Tue, 02 Aug 2011 17:43:20 -0500
changeset 15015 ee6988aea74e
parent 15014 a814e986859f
child 15016 871c77e78f5d
minirst: add decorateblocks search helper
mercurial/minirst.py
--- a/mercurial/minirst.py	Tue Aug 02 17:43:18 2011 -0500
+++ b/mercurial/minirst.py	Tue Aug 02 17:43:20 2011 -0500
@@ -485,6 +485,15 @@
             secs[-1][2].append(b)
     return secs
 
+def decorateblocks(blocks, width):
+    '''generate a list of (section name, line text) pairs for search'''
+    lines = []
+    for s in getsections(blocks):
+        section = s[0]
+        text = formatblocks(s[2], width)
+        lines.append([(section, l) for l in text.splitlines(True)])
+    return lines
+
 if __name__ == "__main__":
     from pprint import pprint