diff mercurial/templatekw.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 ad2ee188f4a5
children a8d13ee0ce68
line wrap: on
line diff
--- a/mercurial/templatekw.py	Sat Mar 12 12:46:31 2011 +0100
+++ b/mercurial/templatekw.py	Sat Mar 12 12:46:31 2011 +0100
@@ -6,8 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 from node import hex
-import encoding, patch, util, error
-from i18n import gettext
+import encoding, patch, util, error, help
 
 def showlist(name, values, plural=None, **args):
     '''expand set of values.
@@ -316,19 +315,7 @@
 }
 
 def makedoc(topic, doc):
-    """Generate and include keyword help in templating topic."""
-    kw = []
-    for name in sorted(keywords):
-        text = (keywords[name].__doc__ or '').rstrip()
-        if not text:
-            continue
-        text = gettext(text)
-        lines = text.splitlines()
-        lines[1:] = [('  ' + l.strip()) for l in lines[1:]]
-        kw.append('\n'.join(lines))
-    kw = '\n\n'.join(kw)
-    doc = doc.replace('.. keywordsmarker', kw)
-    return doc
+    return help.makeitemsdoc(topic, doc, '.. keywordsmarker', keywords)
 
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = keywords.values()