mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Code style nits.
This commit is contained in:
parent
7a40e07eda
commit
c170c5f5da
@ -13,8 +13,6 @@ import collections
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from docutils import nodes
|
|
||||||
|
|
||||||
from sphinx.builders import Builder
|
from sphinx.builders import Builder
|
||||||
from sphinx.util.nodes import extract_messages
|
from sphinx.util.nodes import extract_messages
|
||||||
from sphinx.util.osutil import SEP
|
from sphinx.util.osutil import SEP
|
||||||
|
@ -184,6 +184,7 @@ class CitationReferences(Transform):
|
|||||||
refnode += nodes.Text('[' + cittext + ']')
|
refnode += nodes.Text('[' + cittext + ']')
|
||||||
citnode.parent.replace(citnode, refnode)
|
citnode.parent.replace(citnode, refnode)
|
||||||
|
|
||||||
|
|
||||||
class Locale(Transform):
|
class Locale(Transform):
|
||||||
"""
|
"""
|
||||||
Replace translatable nodes with their translated doctree.
|
Replace translatable nodes with their translated doctree.
|
||||||
@ -207,10 +208,11 @@ class Locale(Transform):
|
|||||||
parser = RSTParser()
|
parser = RSTParser()
|
||||||
|
|
||||||
for node, msg in extract_messages(self.document):
|
for node, msg in extract_messages(self.document):
|
||||||
ctx = node.parent
|
# XXX ctx not used
|
||||||
|
#ctx = node.parent
|
||||||
patch = new_document(source, settings)
|
patch = new_document(source, settings)
|
||||||
msgstr = catalog.ugettext(msg)
|
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
|
if not msgstr or msgstr == msg: # as-of-yet untranslated
|
||||||
continue
|
continue
|
||||||
parser.parse(msgstr, patch)
|
parser.parse(msgstr, patch)
|
||||||
@ -221,7 +223,6 @@ class Locale(Transform):
|
|||||||
node.children = patch.children
|
node.children = patch.children
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SphinxStandaloneReader(standalone.Reader):
|
class SphinxStandaloneReader(standalone.Reader):
|
||||||
"""
|
"""
|
||||||
Add our own transforms.
|
Add our own transforms.
|
||||||
@ -792,7 +793,6 @@ class BuildEnvironment:
|
|||||||
if node['level'] < filterlevel:
|
if node['level'] < filterlevel:
|
||||||
node.parent.remove(node)
|
node.parent.remove(node)
|
||||||
|
|
||||||
|
|
||||||
def process_dependencies(self, docname, doctree):
|
def process_dependencies(self, docname, doctree):
|
||||||
"""
|
"""
|
||||||
Process docutils-generated dependency info.
|
Process docutils-generated dependency info.
|
||||||
|
@ -191,9 +191,9 @@ else:
|
|||||||
def init(locale_dirs, language, catalog='sphinx'):
|
def init(locale_dirs, language, catalog='sphinx'):
|
||||||
"""
|
"""
|
||||||
Look for message catalogs in `locale_dirs` and *ensure* that there is at
|
Look for message catalogs in `locale_dirs` and *ensure* that there is at
|
||||||
least a NullTranslations catalog set in `translators`. If called multiple
|
least a NullTranslations catalog set in `translators`. If called multiple
|
||||||
times or several ``.mo`` files are found their contents are merged
|
times or if several ``.mo`` files are found, their contents are merged
|
||||||
together (thus making `init` reentrable).
|
together (thus making ``init`` reentrable).
|
||||||
"""
|
"""
|
||||||
global translators
|
global translators
|
||||||
translator = translators.get(catalog)
|
translator = translators.get(catalog)
|
||||||
|
@ -28,6 +28,7 @@ def extract_messages(doctree):
|
|||||||
if isinstance(node, (nodes.Invisible, nodes.Inline)):
|
if isinstance(node, (nodes.Invisible, nodes.Inline)):
|
||||||
continue
|
continue
|
||||||
# <field_name>orphan</field_name>
|
# <field_name>orphan</field_name>
|
||||||
|
# XXX ignore all metadata (== docinfo)
|
||||||
if isinstance(node, nodes.field_name) and node.children[0] == 'orphan':
|
if isinstance(node, nodes.field_name) and node.children[0] == 'orphan':
|
||||||
continue
|
continue
|
||||||
msg = node.rawsource.replace('\n', ' ').strip()
|
msg = node.rawsource.replace('\n', ' ').strip()
|
||||||
|
Loading…
Reference in New Issue
Block a user