def get_image_node(self, source):
file_name = self.name_source_snippet(source)
file_path = os.path.join(VISUAL_EXAMPLES_DIR, file_name)
env = self.state.document.settings.env
if all([
render_snippet,
env.config['render_examples'],
not os.environ.get('SPHINX_DISABLE_RENDER', False),
]):
try:
render_snippet(
source, file_path,
output_dir=SOURCE_DIR, **self.options
)
except:
print("problematic code:\n%s" % source)
raise
img = nodes.image()
img['uri'] = "/" + file_path
return img
评论列表
文章目录