本文整理匯總了Python中sphinx.jinja2glue.BuiltinTemplateLoader方法的典型用法代碼示例。如果您正苦於以下問題:Python jinja2glue.BuiltinTemplateLoader方法的具體用法?Python jinja2glue.BuiltinTemplateLoader怎麽用?Python jinja2glue.BuiltinTemplateLoader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sphinx.jinja2glue
的用法示例。
在下文中一共展示了jinja2glue.BuiltinTemplateLoader方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _templates
# 需要導入模塊: from sphinx import jinja2glue [as 別名]
# 或者: from sphinx.jinja2glue import BuiltinTemplateLoader [as 別名]
def _templates(builder):
global _default_templates
# Some builders have no templates manager at all, and some
# have the attribute set to None.
templates = getattr(builder, 'templates', None)
if not templates:
if not _default_templates:
# Initialize default templates manager once
_default_templates = BuiltinTemplateLoader()
_default_templates.init(builder)
templates = _default_templates
return templates
示例2: get_source
# 需要導入模塊: from sphinx import jinja2glue [as 別名]
# 或者: from sphinx.jinja2glue import BuiltinTemplateLoader [as 別名]
def get_source(self, environment, template):
# If template name in Jinja's "extends" is prepended with "!"
# Sphinx skips project's template paths.
# In BuiltinTemplateLoader self.templatepathlen is used to remove
# project's template paths and leave only Sphinx's paths.
# This hack should leave the last path, so "!layout.html" will find
# the template from Fityk. To avoid recursion, Fityk template
# is not using "!".
loaders = self.loaders
# exclamation mark starts search from theme
if template.startswith('!'):
loaders = loaders[self.templatepathlen-1:]
template = template[1:]
for loader in loaders:
try:
return loader.get_source(environment, template)
except TemplateNotFound:
pass
raise TemplateNotFound(template)
示例3: __init__
# 需要導入模塊: from sphinx import jinja2glue [as 別名]
# 或者: from sphinx.jinja2glue import BuiltinTemplateLoader [as 別名]
def __init__(self, app, extra_context):
template_loader = BuiltinTemplateLoader()
template_loader.init(app.builder)
template_env = SandboxedEnvironment(loader=template_loader)
template_env.filters['rst_escape'] = rst_escape_filter
template_env.filters['underline'] = underline_filter
template_env.filters['as_extlink'] = as_extlink_filter
template_env.filters['prefixes'] = prefixes_filter
template_env.filters['rst_link'] = rst_link_filter
self.env = template_env
self.templates: Dict[str, Any] = {}
self.extra_context = extra_context
示例4: init
# 需要導入模塊: from sphinx import jinja2glue [as 別名]
# 或者: from sphinx.jinja2glue import BuiltinTemplateLoader [as 別名]
def init(self):
# type: () -> None
PickleHTMLBuilder.init(self)
# templates are needed for this builder, but the serializing
# builder does not initialize them
self.init_templates()
if not isinstance(self.templates, BuiltinTemplateLoader):
raise RuntimeError('websupport builder must be used with '
'the builtin templates')
# add our custom JS
self.script_files.append('_static/websupport.js')
示例5: init
# 需要導入模塊: from sphinx import jinja2glue [as 別名]
# 或者: from sphinx.jinja2glue import BuiltinTemplateLoader [as 別名]
def init(self, builder, *args, **kw):
self.jinja2_fallback = BuiltinTemplateLoader()
self.jinja2_fallback.init(builder, *args, **kw)
builder.config.html_context['site_base'] = builder.config['site_base']
self.lookup = TemplateLookup(
directories=builder.config.templates_path,
imports=[
"from builder import util"
],
#format_exceptions=True,
)