本文整理汇总了Python中sphinx.util.copy_static_entry函数的典型用法代码示例。如果您正苦于以下问题:Python copy_static_entry函数的具体用法?Python copy_static_entry怎么用?Python copy_static_entry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copy_static_entry函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: copy_static_readthedocs_files
def copy_static_readthedocs_files(self):
log.info(bold('copying readthedocs static files... '), nonl=True)
for filename in self.static_readthedocs_files:
path_dest = os.path.join(self.outdir, '_static')
path_src = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'_static',
filename
)
ctx = self.get_static_readthedocs_context()
if sphinx.version_info < (1, 5):
copy_static_entry(
path_src,
path_dest,
self,
context=ctx,
)
else:
copy_asset(
path_src,
path_dest,
context=ctx,
renderer=self.templates
)
log.info('done')
开发者ID:rtfd,项目名称:readthedocs-sphinx-ext,代码行数:25,代码来源:mixins.py
示例2: copy_media
def copy_media(app, exception):
""" Move our dynamically generated files after build. """
if app.builder.name in ["readthedocs", "readthedocsdirhtml"] and not exception:
for file in ["readthedocs-dynamic-include.js_t", "readthedocs-data.js_t", "searchtools.js_t"]:
app.info(bold("Copying %s... " % file), nonl=True)
dest_dir = os.path.join(app.builder.outdir, "_static")
source = os.path.join(os.path.abspath(os.path.dirname(__file__)), "_static", file)
try:
ctx = app.builder.globalcontext
except AttributeError:
ctx = {}
if app.builder.indexer is not None:
ctx.update(app.builder.indexer.context_for_searchtool())
copy_static_entry(source, dest_dir, app.builder, ctx)
app.info("done")
if "comments" in app.builder.name and not exception:
for file in STATIC_FILES:
app.info(bold("Copying %s... " % file), nonl=True)
dest_dir = os.path.join(app.builder.outdir, "_static")
source = os.path.join(os.path.abspath(os.path.dirname(__file__)), "_static", file)
try:
ctx = app.builder.globalcontext
except AttributeError:
ctx = {}
ctx["websupport2_base_url"] = app.builder.config.websupport2_base_url
ctx["websupport2_static_url"] = app.builder.config.websupport2_static_url
copy_static_entry(source, dest_dir, app.builder, ctx)
app.info("done")
开发者ID:rtfd,项目名称:readthedocs-sphinx-ext,代码行数:29,代码来源:readthedocs.py
示例3: copy_static_files
def copy_static_files(self):
# copy static files
self.info(bold('copying static files... '), nonl=True)
ensuredir(path.join(self.outdir, '_static'))
# first, create pygments style file
f = open(path.join(self.outdir, '_static', 'pygments.css'), 'w')
f.write(self.highlighter.get_stylesheet())
f.close()
# then, copy translations JavaScript file
if self.config.language is not None:
jsfile = self._get_translations_js()
if jsfile:
copyfile(jsfile, path.join(self.outdir, '_static',
'translations.js'))
# add context items for search function used in searchtools.js_t
ctx = self.globalcontext.copy()
ctx.update(self.indexer.context_for_searchtool())
# then, copy over theme-supplied static files
if self.theme:
themeentries = [path.join(themepath, 'static')
for themepath in self.theme.get_dirchain()[::-1]]
for entry in themeentries:
copy_static_entry(entry, path.join(self.outdir, '_static'),
self, ctx)
# then, copy over all user-supplied static files
staticentries = [path.join(self.confdir, spath)
for spath in self.config.html_static_path]
matchers = compile_matchers(
self.config.exclude_patterns +
['**/' + d for d in self.config.exclude_dirnames]
)
for entry in staticentries:
if not path.exists(entry):
self.warn('html_static_path entry %r does not exist' % entry)
continue
copy_static_entry(entry, path.join(self.outdir, '_static'), self,
ctx, exclude_matchers=matchers)
# copy logo and favicon files if not already in static path
if self.config.html_logo:
logobase = path.basename(self.config.html_logo)
logotarget = path.join(self.outdir, '_static', logobase)
if not path.isfile(path.join(self.confdir, self.config.html_logo)):
self.warn('logo file %r does not exist' % self.config.html_logo)
elif not path.isfile(logotarget):
copyfile(path.join(self.confdir, self.config.html_logo),
logotarget)
if self.config.html_favicon:
iconbase = path.basename(self.config.html_favicon)
icontarget = path.join(self.outdir, '_static', iconbase)
if not path.isfile(path.join(self.confdir, self.config.html_favicon)):
self.warn('favicon file %r does not exist' % self.config.html_favicon)
elif not path.isfile(icontarget):
copyfile(path.join(self.confdir, self.config.html_favicon),
icontarget)
self.info('done')
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:57,代码来源:html.py
示例4: copy_media
def copy_media(app, exception):
if app.builder.name != "readthedocs" or exception:
return
for file in ["readthedocs-ext.js_t"]:
app.info(bold("Copying %s... " % file), nonl=True)
dest_dir = os.path.join(app.builder.outdir, "_static")
source = os.path.join(os.path.abspath(os.path.dirname(__file__)), "_static", file)
ctx = app.builder.globalcontext
copy_static_entry(source, dest_dir, app.builder, ctx)
app.info("done")
开发者ID:rvercesi,项目名称:readthedocs-sphinx-ext,代码行数:10,代码来源:readthedocshtmldir.py
示例5: copy_extra_files
def copy_extra_files(self):
# copy html_extra_path files
self.info(bold('copying extra files... '), nonl=True)
extraentries = [path.join(self.confdir, epath)
for epath in self.config.html_extra_path]
for entry in extraentries:
if not path.exists(entry):
self.warn('html_extra_path entry %r does not exist' % entry)
continue
copy_static_entry(entry, self.outdir, self)
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:10,代码来源:html.py
示例6: build_finished
def build_finished(app, exception):
"""
When the build is finished, we copy the javascript files (if specified)
to the build directory (the static folder)
"""
# Skip for non-html or if javascript is not inlined
if not app.env.config.wavedrom_html_jsinline:
return
if app.config.offline_skin_js_path is not None:
copy_static_entry(path.join(app.builder.srcdir, app.config.offline_skin_js_path), path.join(app.builder.outdir, '_static'), app.builder)
if app.config.offline_wavedrom_js_path is not None:
copy_static_entry(path.join(app.builder.srcdir, app.config.offline_wavedrom_js_path), path.join(app.builder.outdir, '_static'), app.builder)
开发者ID:bavovanachte,项目名称:sphinx-wavedrom,代码行数:13,代码来源:wavedrom.py
示例7: copy_media
def copy_media(app, exception):
if app.builder.name != 'readthedocs' or exception:
return
for file in ['readthedocs-ext.js_t']:
app.info(bold('Copying %s... ' % file), nonl=True)
dest_dir = os.path.join(app.builder.outdir, '_static')
source = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'_static',
file
)
ctx = app.builder.globalcontext
copy_static_entry(source, dest_dir, app.builder, ctx)
app.info('done')
开发者ID:rvercesi,项目名称:readthedocs-sphinx-ext,代码行数:14,代码来源:readthedocs.py
示例8: copy_localized_files
def copy_localized_files(self):
source_dir = path.join(self.confdir,
self.config.applehelp_locale + '.lproj')
target_dir = self.outdir
if path.isdir(source_dir):
self.info(bold('copying localized files... '), nonl=True)
ctx = self.globalcontext.copy()
matchers = compile_matchers(self.config.exclude_patterns)
copy_static_entry(source_dir, target_dir, self, ctx,
exclude_matchers=matchers)
self.info('done')
开发者ID:Source-Python-Dev-Team,项目名称:Source.Python,代码行数:14,代码来源:applehelp.py
示例9: copy_visual_placeholder
def copy_visual_placeholder(self):
"""
based on builders.html.copy_image_files
:param sphinx.builders.Builder self:
"""
outdir = path.join(self.outdir, self.imagedir)
ensuredir(outdir)
source = path.join(package_dir, 'theme', 'default', 'static', 'FFFFFF-0.png')
try:
copy_static_entry(source, outdir, self)
except Exception as err:
self.warn('cannot copy image file %r: %s' %
(source, err))
开发者ID:cognifloyd,项目名称:sphinxext-visuals,代码行数:15,代码来源:sphinx_ext.py
示例10: copy_static_files
def copy_static_files(self):
result = super(AbstractSlideBuilder, self).copy_static_files()
# add context items for search function used in searchtools.js_t
ctx = self.globalcontext.copy()
ctx.update(self.indexer.context_for_searchtool())
for theme in self._additional_themes[1:]:
themeentries = [os.path.join(themepath, "static") for themepath in theme.get_dirchain()[::-1]]
for entry in themeentries:
copy_static_entry(entry, os.path.join(self.outdir, "_static"), self, ctx)
return result
开发者ID:harrisonfeng,项目名称:hieroglyph,代码行数:15,代码来源:builder.py
示例11: copy_static_files
def copy_static_files(self):
# copy static files
self.info(bold("copying static files... "), nonl=True)
ensuredir(path.join(self.outdir, "_static"))
ctx = self.globalcontext.copy()
# copy over all user-supplied static files
staticentries = [path.join(self.confdir, spath) for spath in self.config.html_static_path]
matchers = compile_matchers(self.config.exclude_patterns)
for entry in staticentries:
if not path.exists(entry):
self.warn("html_static_path entry %r does not exist" % entry)
continue
copy_static_entry(entry, path.join(self.outdir, "_static"), self, ctx, exclude_matchers=matchers)
self.info("done")
开发者ID:CartoDB,项目名称:bigmetadata,代码行数:16,代码来源:markdown.py
示例12: copy_media
def copy_media(app, exception):
if app.builder.name != 'websupport2' or exception:
return
for file in STATIC_FILES:
app.info(bold('Copying %s... ' % file), nonl=True)
dest_dir = os.path.join(app.builder.outdir, '_static')
source = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
'_static',
file
)
ctx = app.builder.globalcontext
ctx['websupport2_base_url'] = app.builder.config.websupport2_base_url
ctx['websupport2_static_url'] = app.builder.config.websupport2_static_url
copy_static_entry(source, dest_dir, app.builder, ctx)
app.info('done')
开发者ID:ericholscher,项目名称:sphinx-websupport2,代码行数:16,代码来源:websupport2.py
示例13: html_visit_chefserver
def html_visit_chefserver(self, node):
"""
This function generates html content from:
- Mustache template file
- Chef infos
"""
# Gets sources
content = node.content(self.builder)
# Generate html content
loader=jinja2.FileSystemLoader(self.builder.config.chefserver_templates)
env=jinja2.Environment(loader=loader)
template=env.get_template(node.config.get('filename', self.builder.config.chefserver_default_template)+'.html')
html = template.render(content=content)
self.body.append(html)
# Copy css file
for file in self.builder.config.chefserver_css_files:
copy_static_entry(path.join(self.builder.config.chefserver_css_path, file),
path.join(self.builder.outdir, '_static'),
self.builder)
self.builder.css_files.append(path.join('_static', file))
raise nodes.SkipNode
开发者ID:baloo,项目名称:sphinx-chef,代码行数:24,代码来源:__init__.py
示例14: copy_static_entry
staticdirnames = [path.join(themepath, 'static')
for themepath in self.theme.get_dirchain()[::-1]]
else:
staticdirnames = []
staticdirnames += [path.join(self.confdir, spath)
for spath in self.config.html_static_path]
for staticdirname in staticdirnames:
if not path.isdir(staticdirname):
self.warn('static directory %r does not exist' % staticdirname)
continue
for filename in os.listdir(staticdirname):
if filename.startswith('.'):
continue
fullname = path.join(staticdirname, filename)
targetname = path.join(self.outdir, '_static', filename)
copy_static_entry(fullname, targetname, self,
self.globalcontext)
# last, copy logo file (handled differently)
if self.config.html_logo:
logobase = path.basename(self.config.html_logo)
copyfile(path.join(self.confdir, self.config.html_logo),
path.join(self.outdir, '_static', logobase))
# write build info file
fp = open(path.join(self.outdir, '.buildinfo'), 'w')
try:
fp.write('# Sphinx build info version 1\n'
'# This file hashes the configuration used when building'
' these files. When it is not found, a full rebuild will'
' be done.\nconfig: %s\ntags: %s\n' %
(self.config_hash, self.tags_hash))
finally:
开发者ID:89sos98,项目名称:main,代码行数:32,代码来源:html.py
示例15: write
#.........这里部分代码省略.........
for type, docname, lineno, module, descname, content in \
self.env.versionchanges[version]:
if isinstance(descname, tuple):
descname = descname[0]
ttext = self.typemap[type]
context = content.replace('\n', ' ')
if descname and docname.startswith('c-api'):
if not descname:
continue
if context:
entry = '<b>%s</b>: <i>%s:</i> %s' % (descname, ttext,
context)
else:
entry = '<b>%s</b>: <i>%s</i>.' % (descname, ttext)
apichanges.append((entry, docname, lineno))
elif descname or module:
if not module:
module = _('Builtins')
if not descname:
descname = _('Module level')
if context:
entry = '<b>%s</b>: <i>%s:</i> %s' % (descname, ttext,
context)
else:
entry = '<b>%s</b>: <i>%s</i>.' % (descname, ttext)
libchanges.setdefault(module, []).append((entry, docname,
lineno))
else:
if not context:
continue
entry = '<i>%s:</i> %s' % (ttext.capitalize(), context)
title = self.env.titles[docname].astext()
otherchanges.setdefault((docname, title), []).append(
(entry, docname, lineno))
ctx = {
'project': self.config.project,
'version': version,
'docstitle': self.config.html_title,
'shorttitle': self.config.html_short_title,
'libchanges': sorted(iteritems(libchanges)),
'apichanges': sorted(apichanges),
'otherchanges': sorted(iteritems(otherchanges)),
'show_copyright': self.config.html_show_copyright,
'show_sphinx': self.config.html_show_sphinx,
}
f = codecs.open(path.join(self.outdir, 'index.html'), 'w', 'utf8')
try:
f.write(self.templates.render('changes/frameset.html', ctx))
finally:
f.close()
f = codecs.open(path.join(self.outdir, 'changes.html'), 'w', 'utf8')
try:
f.write(self.templates.render('changes/versionchanges.html', ctx))
finally:
f.close()
hltext = ['.. versionadded:: %s' % version,
'.. versionchanged:: %s' % version,
'.. deprecated:: %s' % version]
def hl(no, line):
line = '<a name="L%s"> </a>' % no + htmlescape(line)
for x in hltext:
if x in line:
line = '<span class="hl">%s</span>' % line
break
return line
self.info(bold('copying source files...'))
for docname in self.env.all_docs:
f = codecs.open(self.env.doc2path(docname), 'r',
self.env.config.source_encoding)
try:
lines = f.readlines()
except UnicodeDecodeError:
self.warn('could not read %r for changelog creation' % docname)
continue
finally:
f.close()
targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html'
ensuredir(path.dirname(targetfn))
f = codecs.open(targetfn, 'w', 'utf-8')
try:
text = ''.join(hl(i+1, line) for (i, line) in enumerate(lines))
ctx = {
'filename': self.env.doc2path(docname, None),
'text': text
}
f.write(self.templates.render('changes/rstsource.html', ctx))
finally:
f.close()
themectx = dict(('theme_' + key, val) for (key, val) in
iteritems(self.theme.get_options({})))
copy_static_entry(path.join(package_dir, 'themes', 'default',
'static', 'default.css_t'),
self.outdir, self, themectx)
copy_static_entry(path.join(package_dir, 'themes', 'basic',
'static', 'basic.css'),
self.outdir, self)
开发者ID:861008761,项目名称:standard_flask_web,代码行数:101,代码来源:changes.py
示例16: Flask
from flask import Flask
import runserver
app = Flask(__name__)
app.config.from_envvar('SPHINXWEB_SETTINGS')
import shutil
from sphinx.util import copy_static_entry
from sphinx.websupport import WebSupport
try:
os.makedirs(os.path.join(app.config['BUILD_DIR'], 'templates'))
except os.error:
pass
support = WebSupport(srcdir=app.config['SOURCE_DIR'],
builddir=app.config['BUILD_DIR'],
storage=app.config['DATABASE_URI'])
support.build()
# copy resources from this webapp
for name in ['static', 'templates']:
source_dir = os.path.join(os.getcwd(), 'sphinxweb', name)
target_dir = os.path.join(app.config['BUILD_DIR'], name)
copy_static_entry(source_dir, target_dir, None)
shutil.copy(
os.path.join(os.getcwd(), 'sphinxweb', 'static', 'websupport.js'),
os.path.join(app.config['BUILD_DIR'], 'static', '_static', 'websupport.js'))
开发者ID:nishio,项目名称:sphinxweb,代码行数:30,代码来源:build.py
示例17: write
def write(self, *ignored):
version = self.config.version
libchanges = {}
apichanges = []
otherchanges = {}
if version not in self.env.versionchanges:
self.info(bold("no changes in version %s." % version))
return
self.info(bold("writing summary file..."))
for type, docname, lineno, module, descname, content in self.env.versionchanges[version]:
if isinstance(descname, tuple):
descname = descname[0]
ttext = self.typemap[type]
context = content.replace("\n", " ")
if descname and docname.startswith("c-api"):
if not descname:
continue
if context:
entry = "<b>%s</b>: <i>%s:</i> %s" % (descname, ttext, context)
else:
entry = "<b>%s</b>: <i>%s</i>." % (descname, ttext)
apichanges.append((entry, docname, lineno))
elif descname or module:
if not module:
module = _("Builtins")
if not descname:
descname = _("Module level")
if context:
entry = "<b>%s</b>: <i>%s:</i> %s" % (descname, ttext, context)
else:
entry = "<b>%s</b>: <i>%s</i>." % (descname, ttext)
libchanges.setdefault(module, []).append((entry, docname, lineno))
else:
if not context:
continue
entry = "<i>%s:</i> %s" % (ttext.capitalize(), context)
title = self.env.titles[docname].astext()
otherchanges.setdefault((docname, title), []).append((entry, docname, lineno))
ctx = {
"project": self.config.project,
"version": version,
"docstitle": self.config.html_title,
"shorttitle": self.config.html_short_title,
"libchanges": sorted(libchanges.iteritems()),
"apichanges": sorted(apichanges),
"otherchanges": sorted(otherchanges.iteritems()),
"show_copyright": self.config.html_show_copyright,
"show_sphinx": self.config.html_show_sphinx,
}
f = codecs.open(path.join(self.outdir, "index.html"), "w", "utf8")
try:
f.write(self.templates.render("changes/frameset.html", ctx))
finally:
f.close()
f = codecs.open(path.join(self.outdir, "changes.html"), "w", "utf8")
try:
f.write(self.templates.render("changes/versionchanges.html", ctx))
finally:
f.close()
hltext = [".. versionadded:: %s" % version, ".. versionchanged:: %s" % version, ".. deprecated:: %s" % version]
def hl(no, line):
line = '<a name="L%s"> </a>' % no + htmlescape(line)
for x in hltext:
if x in line:
line = '<span class="hl">%s</span>' % line
break
return line
self.info(bold("copying source files..."))
for docname in self.env.all_docs:
f = codecs.open(self.env.doc2path(docname), "r", self.env.config.source_encoding)
try:
lines = f.readlines()
finally:
f.close()
targetfn = path.join(self.outdir, "rst", os_path(docname)) + ".html"
ensuredir(path.dirname(targetfn))
f = codecs.open(targetfn, "w", "utf-8")
try:
text = "".join(hl(i + 1, line) for (i, line) in enumerate(lines))
ctx = {"filename": self.env.doc2path(docname, None), "text": text}
f.write(self.templates.render("changes/rstsource.html", ctx))
finally:
f.close()
themectx = dict(("theme_" + key, val) for (key, val) in self.theme.get_options({}).iteritems())
copy_static_entry(
path.join(package_dir, "themes", "default", "static", "default.css_t"), self.outdir, self, themectx
)
copy_static_entry(path.join(package_dir, "themes", "basic", "static", "basic.css"), self.outdir, self)
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:92,代码来源:changes.py
注:本文中的sphinx.util.copy_static_entry函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论