按照此链接尝试从 Sphinx 生成 pdf:
https://www.quora.com/How-to-create-a-PDF-out-of-Sphinx-documentation-tool
$ sphinx-build -b pdf source build/pdf
Error: Cannot find source directory `/Users/seb/mydocs/source'.
$ make all-pdf
make: *** No rule to make target `all-pdf'. Stop.
$ make pdf
make: *** No rule to make target `pdf'. Stop.
自从在 OSX 中尝试过:
$ conda install -c dfroger rst2pdf=0.93
Fetching package metadata .........
Solving package specifications: .
Error: Package missing in current osx-64 channels:
- rst2pdf 0.93*
您可以在 anaconda.org 上搜索软件包
anaconda search -t conda rst2pdf
编辑:
pip 安装 rst2pdf 后
install rst2pdf
register rst2pdf in your conf.py Sphinx config
extensions = ['sphinx.ext.autodoc','rst2pdf.pdfbuilder']
但是添加“rst2pdf.pdfbuilder”会导致
Extension error:
Config value 'math_number_all' already present
make: *** [html] Error 1
$ sphinx-build -bpdf sourcedir outdir
但是我应该指定什么作为 sourcedir 和 outdir 呢?请举例。
编辑:
现在制作 html 后
然后:
$ rst2pdf index.rst output.pdf
index.rst:14: (ERROR/3) Unknown directive type "toctree".
.. toctree::
:maxdepth: 2
简介 教程 多个工作 部署 项目
index.rst:26: (ERROR/3) Unknown interpreted text role "ref".
index.rst:27: (ERROR/3) Unknown interpreted text role "ref".
index.rst:28: (ERROR/3) Unknown interpreted text role "ref".
另外:
$rst2pdf.py index.rst -o mydocument.pdf
是否会生成 mydocument.pdf,但与 html 和 toc 完全不同,甚至所有页面都不存在?
最佳答案
这来自official Sphinx documentation 。如果您有pdfTex
安装在您机器上的工具,您所需要的只是:
$ make latexpdf
然后,生成的pdf文件将位于_build/latex/<PROJECT-NAME>.pdf
下
所以,从头开始的完整过程如下:
$ pip install -U sphinx # install the package
$ sphinx-quickstart # create a new project (answer the questions)
$ make latexpdf # compile and generate pdf file
请注意,您还可以通过编辑文件config.py
“选择性”安装所需的任何扩展。
注意:此答案假设您的计算机上安装了 LaTeX 引擎。
关于pdf - 如何创建 PDF-out-of-Sphinx 文档工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39534718/