Mercurial > hg-stable
changeset 15015:ee6988aea74e
minirst: add decorateblocks search helper
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 02 Aug 2011 17:43:20 -0500 |
parents | a814e986859f |
children | 871c77e78f5d |
files | mercurial/minirst.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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