本文整理汇总了Python中sphinx.builders.Builder.post_process_images方法的典型用法代码示例。如果您正苦于以下问题:Python Builder.post_process_images方法的具体用法?Python Builder.post_process_images怎么用?Python Builder.post_process_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.builders.Builder
的用法示例。
在下文中一共展示了Builder.post_process_images方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_process_images
# 需要导入模块: from sphinx.builders import Builder [as 别名]
# 或者: from sphinx.builders.Builder import post_process_images [as 别名]
def post_process_images(self, doctree):
"""Pick the best candidate for an image and link down-scaled images to
their high res version.
"""
Builder.post_process_images(self, doctree)
for node in doctree.traverse(nodes.image):
scale_keys = ("scale", "width", "height")
if not any((key in node) for key in scale_keys) or isinstance(node.parent, nodes.reference):
# docutils does unfortunately not preserve the
# ``target`` attribute on images, so we need to check
# the parent node here.
continue
uri = node["uri"]
reference = nodes.reference("", "", internal=True)
if uri in self.images:
reference["refuri"] = posixpath.join(self.imgpath, self.images[uri])
else:
reference["refuri"] = uri
node.replace_self(reference)
reference.append(node)
示例2: post_process_images
# 需要导入模块: from sphinx.builders import Builder [as 别名]
# 或者: from sphinx.builders.Builder import post_process_images [as 别名]
def post_process_images(self, doctree):
"""Pick the best candidate for an image and link down-scaled images to
their high res version.
"""
Builder.post_process_images(self, doctree)
for node in doctree.traverse(nodes.image):
if not node.has_key('scale') or \
isinstance(node.parent, nodes.reference):
# docutils does unfortunately not preserve the
# ``target`` attribute on images, so we need to check
# the parent node here.
continue
uri = node['uri']
reference = nodes.reference('', '', internal=True)
if uri in self.images:
reference['refuri'] = posixpath.join(self.imgpath,
self.images[uri])
else:
reference['refuri'] = uri
node.replace_self(reference)
reference.append(node)
示例3: post_process_images
# 需要导入模块: from sphinx.builders import Builder [as 别名]
# 或者: from sphinx.builders.Builder import post_process_images [as 别名]
def post_process_images(self, doctree):
Builder.post_process_images(self, doctree)