disable lazy translation in sphinx extension

The sphinx extension depends on all of the help text associated with an
option being regular strings. When oslo_i18n's lazy translation feature
is turned on, the marker functions return Message objects that do not
support all of the features of strings. Add a step to turn off lazy
evaluation when the oslo_context.sphinxext extension is activated.

Change-Id: Icaec4691135cd07d96994f01498e0f9d2e09af58
Closes-Bug: #1605648
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2016-07-27 11:35:04 -04:00
parent cdfe1c9028
commit b40925328e
1 changed files with 10 additions and 0 deletions

View File

@ -25,6 +25,7 @@ from sphinx.util.nodes import nested_parse_with_titles
from oslo_config import cfg
from oslo_config import generator
import oslo_i18n
import six
@ -432,5 +433,14 @@ class ConfigDomain(Domain):
def setup(app):
# NOTE(dhellmann): Try to turn off lazy translation from oslo_i18n
# so any translated help text or deprecation messages associated
# with configuration options are treated as regular strings
# instead of Message objects. Unfortunately this is a bit
# order-dependent, and so it's still possible that importing code
# from another module such as through the autodoc features, or
# even through the plugin scanner, will turn lazy evaluation back
# on.
oslo_i18n.enable_lazy(False)
app.add_directive('show-options', ShowOptionsDirective)
app.add_domain(ConfigDomain)