diff options
Diffstat (limited to 'sphinx/jinja2glue.py')
-rw-r--r-- | sphinx/jinja2glue.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index f19454c27..b491ce44e 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ sphinx.jinja2glue ~~~~~~~~~~~~~~~~~ @@ -17,7 +16,6 @@ from jinja2 import FileSystemLoader, BaseLoader, TemplateNotFound, \ contextfunction from jinja2.sandbox import SandboxedEnvironment from jinja2.utils import open_if_exists -from six import string_types from sphinx.application import TemplateBridge from sphinx.util import logging @@ -32,14 +30,14 @@ if False: def _tobool(val): - # type: (unicode) -> bool - if isinstance(val, string_types): + # type: (str) -> bool + if isinstance(val, str): return val.lower() in ('true', '1', 'yes', 'on') return bool(val) def _toint(val): - # type: (unicode) -> int + # type: (str) -> int try: return int(val) except ValueError: @@ -47,7 +45,7 @@ def _toint(val): def _todim(val): - # type: (Union[int, unicode]) -> unicode + # type: (Union[int, str]) -> str """ Make val a css dimension. In particular the following transformations are performed: @@ -88,7 +86,7 @@ def _slice_index(values, slices): def accesskey(context, key): - # type: (Any, unicode) -> unicode + # type: (Any, str) -> str """Helper to output each access key only once.""" if '_accesskeys' not in context: context.vars['_accesskeys'] = {} @@ -98,7 +96,7 @@ def accesskey(context, key): return '' -class idgen(object): +class idgen: def __init__(self): # type: () -> None self.id = 0 @@ -116,7 +114,7 @@ class idgen(object): @contextfunction def warning(context, message, *args, **kwargs): - # type: (Dict, unicode, Any, Any) -> unicode + # type: (Dict, str, Any, Any) -> str if 'pagename' in context: filename = context.get('pagename') + context.get('file_suffix', '') message = 'in rendering %s: %s' % (filename, message) @@ -132,7 +130,7 @@ class SphinxFileSystemLoader(FileSystemLoader): """ def get_source(self, environment, template): - # type: (Environment, unicode) -> Tuple[unicode, unicode, Callable] + # type: (Environment, str) -> Tuple[str, str, Callable] for searchpath in self.searchpath: filename = path.join(searchpath, template) f = open_if_exists(filename) @@ -161,7 +159,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader): # TemplateBridge interface def init(self, builder, theme=None, dirs=None): - # type: (Builder, Theme, List[unicode]) -> None + # type: (Builder, Theme, List[str]) -> None # create a chain of paths to search if theme: # the theme's own dir and its bases' dirs @@ -205,11 +203,11 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader): self.environment.install_gettext_translations(builder.app.translator) # type: ignore # NOQA def render(self, template, context): # type: ignore - # type: (unicode, Dict) -> unicode + # type: (str, Dict) -> str return self.environment.get_template(template).render(context) def render_string(self, source, context): - # type: (unicode, Dict) -> unicode + # type: (str, Dict) -> str return self.environment.from_string(source).render(context) def newest_template_mtime(self): @@ -219,7 +217,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader): # Loader interface def get_source(self, environment, template): - # type: (Environment, unicode) -> Tuple[unicode, unicode, Callable] + # type: (Environment, str) -> Tuple[str, str, Callable] loaders = self.loaders # exclamation mark starts search from theme if template.startswith('!'): |