diff options
| author | shimizukawa <shimizukawa@gmail.com> | 2013-02-04 22:23:03 +0900 |
|---|---|---|
| committer | shimizukawa <shimizukawa@gmail.com> | 2013-02-04 22:23:03 +0900 |
| commit | 557979af85df90414188e2149686ea46e9102e5a (patch) | |
| tree | 12db1f6dcfc34eecccc2d307a72ed390755730e5 /sphinx | |
| parent | 38a9f1a75a12ae3227e65f29f8c5e6a47e39e8e9 (diff) | |
| download | sphinx-557979af85df90414188e2149686ea46e9102e5a.tar.gz | |
fix: reporting correct line number when translations have wrong reST syntax or else.
Diffstat (limited to 'sphinx')
| -rw-r--r-- | sphinx/environment.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sphinx/environment.py b/sphinx/environment.py index 2995cbbc..2e70569b 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -189,6 +189,20 @@ class CitationReferences(Transform): citnode.parent.replace(citnode, refnode) +class CustomLocaleReporter(object): + """ + Replacer for document.reporter.get_source_and_line method. + + reST text lines for translation not have original source line number. + This class provide correct line number at reporting. + """ + def __init__(self, source, line): + self.source, self.line = source, line + + def get_source_and_line(self, lineno=None): + return self.source, self.line + + class Locale(Transform): """ Replace translatable nodes with their translated doctree. @@ -229,6 +243,8 @@ class Locale(Transform): # dummy literal node will discard by 'patch = patch[0]' patch = new_document(source, settings) + patch.reporter.get_source_and_line = CustomLocaleReporter( + node.source, node.line).get_source_and_line parser.parse(msgstr, patch) patch = patch[0] # XXX doctest and other block markup |
