本文整理汇总了Python中sphinx.util方法的典型用法代码示例。如果您正苦于以下问题:Python sphinx.util方法的具体用法?Python sphinx.util怎么用?Python sphinx.util使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx
的用法示例。
在下文中一共展示了sphinx.util方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
# 需要导入模块: import sphinx [as 别名]
# 或者: from sphinx import util [as 别名]
def setup(app):
app.add_role('ticket', ticket)
app.add_config_value(
'ticket_base_uri',
'https://api.github.com/repos/QubesOS/qubes-issues/issues/{number}',
'env')
app.add_config_value('break_to_pdb', False, 'env')
app.add_node(versioncheck,
html=(visit, depart),
man=(visit, depart))
app.add_directive('versioncheck', VersionCheck)
fdesc = sphinx.util.docfields.GroupedField('parameter', label='Parameters',
names=['param'],
can_collapse=True)
app.add_object_type('event', 'event', 'pair: %s; event', parse_event,
doc_field_types=[fdesc])
app.connect('doctree-resolved', break_to_pdb)
app.connect('doctree-resolved', check_man_args)
# vim: ts=4 sw=4 et
示例2: _app_get_logger
# 需要导入模块: import sphinx [as 别名]
# 或者: from sphinx import util [as 别名]
def _app_get_logger(name):
class SphinxLoggerAdapter:
def _color_to_func(self, kwargs, default=''):
return getattr(sphinx.util.console,
kwargs.pop('color', default),
None)
def error(self, msg, *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs, default='red')
return _app.warn(colorfunc(msg), **kwargs)
def critical(self, msg, *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs, default='red')
return _app.warn(colorfunc(msg), **kwargs)
def warning(self, msg, *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs)
if colorfunc:
# colorfunc is a valid kwarg in 1.5, but not older, so we just
# apply it ourselves.
msg = colorfunc(msg)
return _app.warn(msg, **kwargs)
def info(self, msg='', *args, **kwargs):
msg = msg % args
colorfunc = self._color_to_func(kwargs)
if colorfunc:
msg = colorfunc(msg)
return _app.info(msg, **kwargs)
def verbose(self, msg, *args, **kwargs):
return _app.verbose(msg, *args, **kwargs)
def debug(self, msg, *args, **kwargs):
return _app.debug(msg, *args, **kwargs)
return SphinxLoggerAdapter()
示例3: _app_status_iterator
# 需要导入模块: import sphinx [as 别名]
# 或者: from sphinx import util [as 别名]
def _app_status_iterator(iterable, summary, **kwargs):
global _app
color = kwargs.pop('color', None)
if color is not None:
kwargs['colorfunc'] = getattr(sphinx.util.console, color)
for item in _app.status_iterator(iterable, summary, **kwargs):
yield item
示例4: init
# 需要导入模块: import sphinx [as 别名]
# 或者: from sphinx import util [as 别名]
def init(self):
self.docnames = []
self.document_data = []
self.sphinx_logger = sphinx.util.logging.getLogger(__name__)
示例5: update_need_with_parts
# 需要导入模块: import sphinx [as 别名]
# 或者: from sphinx import util [as 别名]
def update_need_with_parts(env, need, part_nodes):
for part_node in part_nodes:
content = part_node.children[0].children[0] # ->inline->Text
result = part_pattern.match(content)
if result is not None:
inline_id = result.group(1)
part_content = result.group(2)
else:
part_content = content
inline_id = hashlib.sha1(part_content.encode("UTF-8")).hexdigest().upper()[:3]
if 'parts' not in need.keys():
need['parts'] = {}
if inline_id in need['parts'].keys():
log.warning("part_need id {} in need {} is already taken. need_part may get overridden.".format(
inline_id, need['id']))
need['parts'][inline_id] = {
'id': inline_id,
'content': part_content,
'document': need["docname"],
'links_back': [],
'is_part': True,
'is_need': False,
'links': [],
}
part_id_ref = '{}.{}'.format(need['id'], inline_id)
part_id_show = inline_id
part_node['reftarget'] = part_id_ref
part_link_text = ' {}'.format(part_id_show)
part_link_node = nodes.Text(part_link_text, part_link_text)
part_text_node = nodes.Text(part_content, part_content)
from sphinx.util.nodes import make_refnode
part_ref_node = make_refnode(env.app.builder,
need['docname'],
need['docname'],
part_id_ref,
part_link_node)
part_ref_node["classes"] += ['needs-id']
part_node.children = []
node_need_part_line = nodes.inline(ids=[part_id_ref], classes=["need-part"])
node_need_part_line.append(part_text_node)
node_need_part_line.append(part_ref_node)
part_node.append(node_need_part_line)