【发布时间】:2023-03-03 01:10:02
【问题描述】:
我有一个使用 Sphinx 记录的 C++ 项目。为了保持源目录干净,它使用了源外构建。我有一个教程程序,它作为项目的一部分构建,并在构建目录而不是项目源目录中生成图像。当我无法控制项目的源目录和构建目录的相对位置时,如何在源目录的文档文件中引用图像?
我尝试在 conf.py 中使用 rst_epilog,如下所示:
rst_epilog = """
.. |builddir| replace:: %s
""" % project_build_dir
然后像这样引用图像:
.. figure:: |builddir|/generated.png
但最终会出现“警告:图像文件不可读:|builddir|/generated.png”之类的错误。
【问题讨论】:
标签: image python-sphinx substitution restructuredtext