diff options
author | Georg Brandl <georg@python.org> | 2010-01-17 19:33:23 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-01-17 19:33:23 +0100 |
commit | b0dbc8bb87461a6ac18acd744472f1eca94a3150 (patch) | |
tree | deb311cb6a8c188e72e69193ef6bb0615a14cdf8 | |
parent | d640630d580aef603fed3e1dd6dfd15703a243f8 (diff) | |
download | sphinx-b0dbc8bb87461a6ac18acd744472f1eca94a3150.tar.gz |
Make the _ gettext alias an explicit import instead of installing into builtins.
-rw-r--r-- | sphinx/builders/changes.py | 1 | ||||
-rw-r--r-- | sphinx/builders/devhelp.py | 3 | ||||
-rw-r--r-- | sphinx/builders/html.py | 1 | ||||
-rw-r--r-- | sphinx/builders/htmlhelp.py | 1 | ||||
-rw-r--r-- | sphinx/builders/latex.py | 1 | ||||
-rw-r--r-- | sphinx/builders/qthelp.py | 3 | ||||
-rw-r--r-- | sphinx/directives/other.py | 2 | ||||
-rw-r--r-- | sphinx/domains/c.py | 2 | ||||
-rw-r--r-- | sphinx/domains/python.py | 2 | ||||
-rw-r--r-- | sphinx/domains/std.py | 2 | ||||
-rw-r--r-- | sphinx/environment.py | 1 | ||||
-rw-r--r-- | sphinx/ext/autodoc.py | 2 | ||||
-rw-r--r-- | sphinx/ext/autosummary/__init__.py | 3 | ||||
-rw-r--r-- | sphinx/ext/inheritance_diagram.py | 4 | ||||
-rw-r--r-- | sphinx/ext/todo.py | 1 | ||||
-rw-r--r-- | sphinx/ext/viewcode.py | 1 | ||||
-rw-r--r-- | sphinx/locale/__init__.py | 9 | ||||
-rw-r--r-- | sphinx/pycode/pgen2/grammar.py | 2 | ||||
-rw-r--r-- | sphinx/pycode/pgen2/pgen.py | 4 | ||||
-rw-r--r-- | sphinx/roles.py | 3 | ||||
-rw-r--r-- | sphinx/writers/html.py | 2 | ||||
-rw-r--r-- | sphinx/writers/latex.py | 2 | ||||
-rw-r--r-- | sphinx/writers/text.py | 2 |
23 files changed, 30 insertions, 24 deletions
diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py index 0571246a..980ed760 100644 --- a/sphinx/builders/changes.py +++ b/sphinx/builders/changes.py @@ -15,6 +15,7 @@ from cgi import escape from sphinx import package_dir from sphinx.util import copy_static_entry +from sphinx.locale import _ from sphinx.theming import Theme from sphinx.builders import Builder from sphinx.util.osutil import ensuredir, os_path diff --git a/sphinx/builders/devhelp.py b/sphinx/builders/devhelp.py index 88fccadc..a5a0f280 100644 --- a/sphinx/builders/devhelp.py +++ b/sphinx/builders/devhelp.py @@ -11,10 +11,7 @@ :license: BSD, see LICENSE for details. """ -import os import re -import cgi -import sys from os import path from docutils import nodes diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 3686628c..7f4e4c66 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -36,6 +36,7 @@ from sphinx.util.nodes import inline_all_toctrees from sphinx.util.matching import patmatch, compile_matchers from sphinx.util.pycompat import any from sphinx.errors import SphinxError +from sphinx.locale import _ from sphinx.search import js_index from sphinx.theming import Theme from sphinx.builders import Builder diff --git a/sphinx/builders/htmlhelp.py b/sphinx/builders/htmlhelp.py index 3ef98f34..b7adc638 100644 --- a/sphinx/builders/htmlhelp.py +++ b/sphinx/builders/htmlhelp.py @@ -18,6 +18,7 @@ from os import path from docutils import nodes from sphinx import addnodes +from sphinx.locale import _ from sphinx.builders.html import StandaloneHTMLBuilder diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py index 21771327..0481b308 100644 --- a/sphinx/builders/latex.py +++ b/sphinx/builders/latex.py @@ -19,6 +19,7 @@ from docutils.frontend import OptionParser from sphinx import package_dir, addnodes from sphinx.util import texescape +from sphinx.locale import _ from sphinx.builders import Builder from sphinx.environment import NoUri from sphinx.util.nodes import inline_all_toctrees diff --git a/sphinx/builders/qthelp.py b/sphinx/builders/qthelp.py index 547bf2fd..623a5c95 100644 --- a/sphinx/builders/qthelp.py +++ b/sphinx/builders/qthelp.py @@ -18,6 +18,7 @@ from os import path from docutils import nodes from sphinx import addnodes +from sphinx.locale import _ from sphinx.builders.html import StandaloneHTMLBuilder _idpattern = re.compile( @@ -233,7 +234,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder): shortname = shortname[:-2] id = '%s.%s' % (id, shortname) else: - id = descr = None + id = None if id: item = ' '*12 + '<keyword name="%s" id="%s" ref="%s"/>' % ( diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index a20ea70c..ef23a32d 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -11,7 +11,7 @@ from docutils import nodes from docutils.parsers.rst import Directive, directives from sphinx import addnodes -from sphinx.locale import pairindextypes +from sphinx.locale import pairindextypes, _ from sphinx.util import url_re, docname_join from sphinx.util.nodes import explicit_title_re from sphinx.util.compat import make_admonition diff --git a/sphinx/domains/c.py b/sphinx/domains/c.py index c332426d..d4de0fa6 100644 --- a/sphinx/domains/c.py +++ b/sphinx/domains/c.py @@ -16,7 +16,7 @@ from docutils import nodes from sphinx import addnodes from sphinx.roles import XRefRole -from sphinx.locale import l_ +from sphinx.locale import l_, _ from sphinx.domains import Domain, ObjType from sphinx.directives import ObjectDescription from sphinx.util.nodes import make_refnode diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 0695e000..b31a3f8c 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -16,7 +16,7 @@ from docutils.parsers.rst import directives from sphinx import addnodes from sphinx.roles import XRefRole -from sphinx.locale import l_ +from sphinx.locale import l_, _ from sphinx.domains import Domain, ObjType from sphinx.directives import ObjectDescription from sphinx.util.nodes import make_refnode diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 4110b5a9..a6f43776 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -16,7 +16,7 @@ from docutils.parsers.rst import directives from sphinx import addnodes from sphinx.roles import XRefRole -from sphinx.locale import l_ +from sphinx.locale import l_, _ from sphinx.domains import Domain, ObjType from sphinx.directives import ObjectDescription from sphinx.util import ws_re diff --git a/sphinx/environment.py b/sphinx/environment.py index d82ce4f7..d95d80e5 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -40,6 +40,7 @@ from sphinx.util.nodes import clean_astext, make_refnode from sphinx.util.osutil import movefile, SEP, ustrftime from sphinx.util.matching import compile_matchers from sphinx.errors import SphinxError, ExtensionError +from sphinx.locale import _ orig_role_function = roles.role diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 720aee38..c08007cd 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -21,6 +21,7 @@ from docutils.utils import assemble_option_dict from docutils.statemachine import ViewList from sphinx.util import rpartition, force_decode +from sphinx.locale import _ from sphinx.pycode import ModuleAnalyzer, PycodeError from sphinx.application import ExtensionError from sphinx.util.nodes import nested_parse_with_titles @@ -868,7 +869,6 @@ class ClassDocumenter(ModuleLevelDocumenter): return ret def format_args(self): - args = None # for classes, the relevant signature is the __init__ method's initmeth = self.get_attr(self.object, '__init__', None) # classes without __init__ method, default __init__ or diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index bd99b313..a48295d1 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -63,7 +63,7 @@ from docutils.parsers.rst import directives from docutils.statemachine import ViewList from docutils import nodes -from sphinx import addnodes, roles +from sphinx import addnodes from sphinx.util.compat import Directive @@ -192,7 +192,6 @@ class Autosummary(Directive): if 'toctree' in self.options: suffix = env.config.source_suffix - all_docnames = env.found_docs.copy() dirname = posixpath.dirname(env.docname) tree_prefix = self.options['toctree'].strip() diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py index 1fb8b0b2..db4c5678 100644 --- a/sphinx/ext/inheritance_diagram.py +++ b/sphinx/ext/inheritance_diagram.py @@ -96,7 +96,7 @@ class InheritanceGraph(object): # two possibilities: either it is a module, then import it try: - module = __import__(fullname) + __import__(fullname) todoc = sys.modules[fullname] except ImportError: # else it is a class, then import the module @@ -109,7 +109,7 @@ class InheritanceGraph(object): 'Could not import class %r specified for ' 'inheritance diagram' % base) try: - module = __import__(path) + __import__(path) todoc = getattr(sys.modules[path], base) except (ImportError, AttributeError): raise InheritanceException( diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py index 59abbbdc..2bebaffe 100644 --- a/sphinx/ext/todo.py +++ b/sphinx/ext/todo.py @@ -14,6 +14,7 @@ from docutils import nodes +from sphinx.locale import _ from sphinx.environment import NoUri from sphinx.util.compat import Directive, make_admonition diff --git a/sphinx/ext/viewcode.py b/sphinx/ext/viewcode.py index 5dd2c076..11ab4b11 100644 --- a/sphinx/ext/viewcode.py +++ b/sphinx/ext/viewcode.py @@ -12,6 +12,7 @@ from docutils import nodes from sphinx import addnodes +from sphinx.locale import _ from sphinx.pycode import ModuleAnalyzer from sphinx.util.nodes import make_refnode diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index bfa23dbb..badcca1c 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -11,8 +11,6 @@ import gettext import UserString -from sphinx import package_dir - class _TranslationProxy(UserString.UserString, object): """Class for proxy strings from gettext translations. This is a helper @@ -163,10 +161,14 @@ pairindextypes = { 'builtin': l_('built-in function'), } +translator = None + +def _(message): + return translator.gettext(message) def init(locale_dirs, language): + global translator # the None entry is the system's default locale path - translator = None has_translation = True for dir_ in locale_dirs: try: @@ -182,5 +184,4 @@ def init(locale_dirs, language): if translator is None: translator = gettext.NullTranslations() has_translation = False - translator.install(unicode=True) return translator, has_translation diff --git a/sphinx/pycode/pgen2/grammar.py b/sphinx/pycode/pgen2/grammar.py index 381d80e8..5a433578 100644 --- a/sphinx/pycode/pgen2/grammar.py +++ b/sphinx/pycode/pgen2/grammar.py @@ -16,7 +16,7 @@ fallback token code OP, but the parser needs the actual token code. import pickle # Local imports -from sphinx.pycode.pgen2 import token, tokenize +from sphinx.pycode.pgen2 import token class Grammar(object): diff --git a/sphinx/pycode/pgen2/pgen.py b/sphinx/pycode/pgen2/pgen.py index d6895eae..b19c5447 100644 --- a/sphinx/pycode/pgen2/pgen.py +++ b/sphinx/pycode/pgen2/pgen.py @@ -157,9 +157,9 @@ class ParserGenerator(object): #self.dump_nfa(name, a, z) dfa = self.make_dfa(a, z) #self.dump_dfa(name, dfa) - oldlen = len(dfa) + #oldlen = len(dfa) self.simplify_dfa(dfa) - newlen = len(dfa) + #newlen = len(dfa) dfas[name] = dfa #print name, oldlen, newlen if startsymbol is None: diff --git a/sphinx/roles.py b/sphinx/roles.py index 41816010..ce30d139 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -16,6 +16,7 @@ from docutils import nodes, utils from docutils.parsers.rst import roles from sphinx import addnodes +from sphinx.locale import _ from sphinx.util import ws_re from sphinx.util.nodes import split_explicit_title @@ -105,7 +106,7 @@ class XRefRole(object): # if the first character is a bang, don't cross-reference at all if text[0:1] == '!': if self.fix_parens: - text, _ = self._fix_parens(env, False, text[1:], "") + text, tgt = self._fix_parens(env, False, text[1:], "") innernode = self.innernodeclass(rawtext, text, classes=['xref']) return self.result_nodes(inliner.document, env, innernode, is_ref=False) diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 937ac56f..1ca61254 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -16,7 +16,7 @@ import os from docutils import nodes from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator -from sphinx.locale import admonitionlabels, versionlabels +from sphinx.locale import admonitionlabels, versionlabels, _ from sphinx.util.smartypants import sphinx_smarty_pants try: diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 0bd60fb4..86c819f2 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -22,7 +22,7 @@ from docutils.writers.latex2e import Babel from sphinx import addnodes from sphinx import highlighting from sphinx.errors import SphinxError -from sphinx.locale import admonitionlabels, versionlabels +from sphinx.locale import admonitionlabels, versionlabels, _ from sphinx.util.osutil import ustrftime from sphinx.util.texescape import tex_escape_map from sphinx.util.smartypants import educateQuotesLatex diff --git a/sphinx/writers/text.py b/sphinx/writers/text.py index 61a412bc..a7e247ce 100644 --- a/sphinx/writers/text.py +++ b/sphinx/writers/text.py @@ -15,7 +15,7 @@ import textwrap from docutils import nodes, writers from sphinx import addnodes -from sphinx.locale import admonitionlabels, versionlabels +from sphinx.locale import admonitionlabels, versionlabels, _ class TextWriter(writers.Writer): |