##// END OF EJS Templates
hggettext: handle i18nfunctions declaration for docstrings translations
Patrick Mezard -
r12823:80deae3b stable
parent child Browse files
Show More
@@ -566,3 +566,6 b' cmdtable = {'
566 }
566 }
567
567
568 colortable = {'bookmarks.current': 'green'}
568 colortable = {'bookmarks.current': 'green'}
569
570 # tell hggettext to extract docstrings from these functions:
571 i18nfunctions = [bmrevset]
@@ -625,3 +625,6 b' cmdtable = {'
625 _('hg transplant [-s REPO] [-b BRANCH [-a]] [-p REV] '
625 _('hg transplant [-s REPO] [-b BRANCH [-a]] [-p REV] '
626 '[-m REV] [REV]...'))
626 '[-m REV] [REV]...'))
627 }
627 }
628
629 # tell hggettext to extract docstrings from these functions:
630 i18nfunctions = [revsettransplanted]
@@ -97,19 +97,25 b' def docstrings(path):'
97 lineno = 1 + offset(src, mod.__doc__, path, 7)
97 lineno = 1 + offset(src, mod.__doc__, path, 7)
98 print poentry(path, lineno, mod.__doc__)
98 print poentry(path, lineno, mod.__doc__)
99
99
100 functions = list(getattr(mod, 'i18nfunctions', []))
101 functions = [(f, True) for f in functions]
102
100 cmdtable = getattr(mod, 'cmdtable', {})
103 cmdtable = getattr(mod, 'cmdtable', {})
101 if not cmdtable:
104 if not cmdtable:
102 # Maybe we are processing mercurial.commands?
105 # Maybe we are processing mercurial.commands?
103 cmdtable = getattr(mod, 'table', {})
106 cmdtable = getattr(mod, 'table', {})
107 functions.extend((c[0], False) for c in cmdtable.itervalues())
104
108
105 for entry in cmdtable.itervalues():
109 for func, rstrip in functions:
106 func = entry[0]
107 if func.__doc__:
110 if func.__doc__:
108 src = inspect.getsource(func)
111 src = inspect.getsource(func)
109 name = "%s.%s" % (path, func.__name__)
112 name = "%s.%s" % (path, func.__name__)
110 lineno = func.func_code.co_firstlineno
113 lineno = func.func_code.co_firstlineno
111 lineno += offset(src, func.__doc__, name, 1)
114 doc = func.__doc__
112 print poentry(path, lineno, func.__doc__)
115 if rstrip:
116 doc = doc.rstrip()
117 lineno += offset(src, doc, name, 1)
118 print poentry(path, lineno, doc)
113
119
114
120
115 def rawtext(path):
121 def rawtext(path):
@@ -791,3 +791,6 b' def makedoc(topic, doc):'
791 predicates = '\n'.join(predicates)
791 predicates = '\n'.join(predicates)
792 doc = doc.replace('.. predicatesmarker', predicates)
792 doc = doc.replace('.. predicatesmarker', predicates)
793 return doc
793 return doc
794
795 # tell hggettext to extract docstrings from these functions:
796 i18nfunctions = symbols.values()
General Comments 0
You need to be logged in to leave comments. Login now