2016-09-16 64 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