Sphinx:链接到嵌入式二进制文件(PDF)

时间:2016-07-27 12:57:02

标签: python-2.7 python-sphinx restructuredtext read-the-docs

我使用 sphinx RST 生成一些HTML技术文档,并且在将本地PDF引用作为超链接时遇到问题。我看到有人使用:download:链接到本地​​PDF,但我将PDF嵌入/docs目录中以供参考。我不喜欢:download:,因为它没有在浏览器中显示PDF内嵌,这需要对用户进行额外的操作。代表消费。

sphinx-build -b html不会复制任何文件,除非它们在config.py hook html_static_pathhtml_extra_path中指定 - 即使这样,它们也会被删除到root目录或_static个文件夹。

是否存在在sphinx中嵌入链接二进制文件的建议方法,或者这是一种不好的做法?通常链接是幻灯片或设计图表,而不是在其他地方托管。

链接PDF的示例RST

.. important:: View the agile course on scrum basics

    - View `these slides to dive deeper into Agile Basics <docs/agile-101.pdf>`_. 

1 个答案:

答案 0 :(得分:1)

我提出的解决方案是将PDF添加到html_static_path并引用链接中的_static输出路径,而不是它所在的docs路径。现在PDF在浏览器中打开,而不必下载它们来查看。

如果有一个sphinx扩展/指令来处理这个(:download-inline:)会很棒。

conf.py

html_static_path = ['_static', 'agile-101/docs']

敏捷101.rst

.. important:: View the agile course on scrum basics

- View `these slides to dive deeper into Agile Basics <../_static/agile-101.pdf>`_. 
相关问题