Code style nits.

This commit is contained in:
Georg Brandl 2010-08-21 19:19:12 +02:00
parent 7a40e07eda
commit c170c5f5da
4 changed files with 8 additions and 9 deletions

View File

@ -13,8 +13,6 @@ import collections
from datetime import datetime
from os import path
from docutils import nodes
from sphinx.builders import Builder
from sphinx.util.nodes import extract_messages
from sphinx.util.osutil import SEP

View File

@ -184,6 +184,7 @@ class CitationReferences(Transform):
refnode += nodes.Text('[' + cittext + ']')
citnode.parent.replace(citnode, refnode)
class Locale(Transform):
"""
Replace translatable nodes with their translated doctree.
@ -207,10 +208,11 @@ class Locale(Transform):
parser = RSTParser()
for node, msg in extract_messages(self.document):
ctx = node.parent
# XXX ctx not used
#ctx = node.parent
patch = new_document(source, settings)
msgstr = catalog.ugettext(msg)
#XXX add marker to untranslated parts
# XXX add marker to untranslated parts
if not msgstr or msgstr == msg: # as-of-yet untranslated
continue
parser.parse(msgstr, patch)
@ -221,7 +223,6 @@ class Locale(Transform):
node.children = patch.children
class SphinxStandaloneReader(standalone.Reader):
"""
Add our own transforms.
@ -792,7 +793,6 @@ class BuildEnvironment:
if node['level'] < filterlevel:
node.parent.remove(node)
def process_dependencies(self, docname, doctree):
"""
Process docutils-generated dependency info.

View File

@ -191,9 +191,9 @@ else:
def init(locale_dirs, language, catalog='sphinx'):
"""
Look for message catalogs in `locale_dirs` and *ensure* that there is at
least a NullTranslations catalog set in `translators`. If called multiple
times or several ``.mo`` files are found their contents are merged
together (thus making `init` reentrable).
least a NullTranslations catalog set in `translators`. If called multiple
times or if several ``.mo`` files are found, their contents are merged
together (thus making ``init`` reentrable).
"""
global translators
translator = translators.get(catalog)

View File

@ -28,6 +28,7 @@ def extract_messages(doctree):
if isinstance(node, (nodes.Invisible, nodes.Inline)):
continue
# <field_name>orphan</field_name>
# XXX ignore all metadata (== docinfo)
if isinstance(node, nodes.field_name) and node.children[0] == 'orphan':
continue
msg = node.rawsource.replace('\n', ' ').strip()