i18n: make hggettext use original docstring to compute offset
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 02 Aug 2017 01:03:20 +0900
changeset 33815 97ee669f1f6d
parent 33814 81b12f69ef5b
child 33816 1775f93da25c
i18n: make hggettext use original docstring to compute offset Before this patch, hggettext uses __doc__ of each functions to compute offset of document text. But __doc__ of many functions is already modified by decorators in registrar (e.g. @templatekeyword adds ":NAME: " prefix to it), and hggettext can not find it out in original source. This causes many "unknown offset in ..." warning at "make update-pot", and leaving them might cause overlooking serious problems. This patch makes hggettext use original docstring, which decorators in registrar save into _origdoc, to compute offset. Even after this patch, there are still a few "unknown offset in ..." warning at "make update-pot" for specific reasons. These will be fixed later one by one.
i18n/hggettext
--- a/i18n/hggettext	Fri Aug 11 14:21:49 2017 +0200
+++ b/i18n/hggettext	Wed Aug 02 01:03:20 2017 +0900
@@ -122,9 +122,14 @@
             name = "%s.%s" % (actualpath, func.__name__)
             lineno = inspect.getsourcelines(func)[1]
             doc = func.__doc__
+            origdoc = getattr(func, '_origdoc', '')
             if rstrip:
                 doc = doc.rstrip()
-            lineno += offset(src, doc, name, 1)
+                origdoc = origdoc.rstrip()
+            if origdoc:
+                lineno += offset(src, origdoc, name, 1)
+            else:
+                lineno += offset(src, doc, name, 1)
             print(poentry(actualpath, lineno, doc))