2016-09-16 66 views
6

遵循了这一环节,从狮身人面像试图生成PDF:如何创建一个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 

编辑:

点子安装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 

介绍 教程 multiple_jobs 部署 项目

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完全不同的所有页面,即使不是吗?

Image of pdf verse HTML same page

+0

为什么使用anconda /畅达?如果您没有具体的原因,请安装pip并运行“pip install rst2pdf”。如果您想更好地控制输出的风格,最好通过LaTeX构建PDF。 –

回答

1

Found this related post其中发现rst2pdf打破了狮身人面像1.4.1因为它导入一个虚拟的数学模块的数学渲染。

In rst2pdf.pdfbuilder:setup() , it calls mathbase.setup() internally to install dummy math module. It causes conflicts and raise errors.

我跑sphinx-build -b pdf

Extension error:
Config value 'math_number_all' already present

当现在看看乳胶选项,并出口到PDF作为@tfv发布了同样的错误。 pdflatex is a larger universe of TeX distribution

0

我已经成功地通过下面的配置产生了DevStack文档PDF文件更改in this link

步骤如下:

  1. 编辑您的conf.py(编辑或追加值)

    extensions = ['rst2pdf.pdfbuilder'] 
    pdf_documents = [('index', u'rst2pdf', u'Sample rst2pdf doc', u'Your Name'),] 
    
  2. 必要时安装“rst2pdf

    pip install rst2pdf 
    
  3. 生成PDF文件是这样的:

    sphinx-build -b pdf doc/source doc/build