Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 13593:cc4721ed7a2a
help: extract items doc generation function
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 12 Mar 2011 12:46:31 +0100 |
parents | 117990768fe0 |
children | 54b198fe9768 |
comparison
equal
deleted
inserted
replaced
13592:ad2ee188f4a5 | 13593:cc4721ed7a2a |
---|---|
4 # | 4 # |
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 import re | 8 import re |
9 import parser, util, error, discovery | 9 import parser, util, error, discovery, help |
10 import bookmarks as bookmarksmod | 10 import bookmarks as bookmarksmod |
11 import match as matchmod | 11 import match as matchmod |
12 from i18n import _, gettext | 12 from i18n import _ |
13 | 13 |
14 elements = { | 14 elements = { |
15 "(": (20, ("group", 1, ")"), ("func", 1, ")")), | 15 "(": (20, ("group", 1, ")"), ("func", 1, ")")), |
16 "-": (5, ("negate", 19), ("minus", 5)), | 16 "-": (5, ("negate", 19), ("minus", 5)), |
17 "::": (17, ("dagrangepre", 17), ("dagrange", 17), | 17 "::": (17, ("dagrangepre", 17), ("dagrange", 17), |
813 def mfunc(repo, subset): | 813 def mfunc(repo, subset): |
814 return getset(repo, subset, tree) | 814 return getset(repo, subset, tree) |
815 return mfunc | 815 return mfunc |
816 | 816 |
817 def makedoc(topic, doc): | 817 def makedoc(topic, doc): |
818 """Generate and include predicates help in revsets topic.""" | 818 return help.makeitemsdoc(topic, doc, '.. predicatesmarker', symbols) |
819 predicates = [] | |
820 for name in sorted(symbols): | |
821 text = symbols[name].__doc__ | |
822 if not text: | |
823 continue | |
824 text = gettext(text.rstrip()) | |
825 lines = text.splitlines() | |
826 lines[1:] = [(' ' + l.strip()) for l in lines[1:]] | |
827 predicates.append('\n'.join(lines)) | |
828 predicates = '\n\n'.join(predicates) | |
829 doc = doc.replace('.. predicatesmarker', predicates) | |
830 return doc | |
831 | 819 |
832 # tell hggettext to extract docstrings from these functions: | 820 # tell hggettext to extract docstrings from these functions: |
833 i18nfunctions = symbols.values() | 821 i18nfunctions = symbols.values() |