我使用 sphinx 和 RST 生成一些HTML技术文档,并且在将本地PDF引用作为超链接时遇到问题。我看到有人使用:download:
链接到本地PDF,但我将PDF嵌入/docs
目录中以供参考。我不喜欢:download:
,因为它没有在浏览器中显示PDF内嵌,这需要对用户进行额外的操作。代表消费。
sphinx-build -b html
不会复制任何文件,除非它们在config.py
hook html_static_path
或html_extra_path
中指定 - 即使这样,它们也会被删除到root
目录或_static
个文件夹。
是否存在在sphinx中嵌入链接二进制文件的建议方法,或者这是一种不好的做法?通常链接是幻灯片或设计图表,而不是在其他地方托管。
.. important:: View the agile course on scrum basics
- View `these slides to dive deeper into Agile Basics <docs/agile-101.pdf>`_.
答案 0 :(得分:1)
我提出的解决方案是将PDF添加到html_static_path
并引用链接中的_static
输出路径,而不是它所在的docs
路径。现在PDF在浏览器中打开,而不必下载它们来查看。
如果有一个sphinx扩展/指令来处理这个(:download-inline:
)会很棒。
html_static_path = ['_static', 'agile-101/docs']
.. important:: View the agile course on scrum basics
- View `these slides to dive deeper into Agile Basics <../_static/agile-101.pdf>`_.