欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

[SphinxDoc]离线构建支持导出PDF的Sphinx-Doc环境

程序员文章站 2022-03-09 13:55:25
...

Offline-install Sphinx with PDF export

OS:Windows 7 Pro x64 EN

Url:https://pan.baidu.com/s/1T2QXMb186mugSxBXH_uqVg Pass:jyxt

Install & Replace Python 3.6.4 64-bit

Install Python 3.6.4(64-bit)
Customize installation
Install for all users
Add Python 3.6 to PATH

Advanced Options
Install for all users
Directory: C:\Python36

Extract Python36.7z and replace install directory
Including sphinx-1.7.1sphinx_rtd_theme-0.2.5b2
C:\Python36

Install & Replace MiKTex-0.2.5b2

Install MiKTex
1. Install MiKTex for anyone who users this computer(all users)
2. Install missing packages on-the-fly: Yes

Extract MiKTeX 2.9.7z and replace multi-directory
C:\Program Files\MiKTeX 2.9
%AppData%\Local\MiKTeX
%AppData%\Roaming\MiKTeX

Update Sphinx Conf.py

# -- Options for LaTeX output ---------------------------------------------

# The LaTeX engine to build the docs. 
# pdflatex, xelatex, lualatex, platex
latex_engine = 'xelatex'

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, 'MyTex.tex', u'Title',
     u'Gaearrow', 'manual'),
]

# This value determines how to group the document tree into LaTeX source files. It must be a list of tuples
#  (startdocname, targetname, title, author, documentclass, toctree_only)
latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    'papersize': 'a4paper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    'pointsize': '11pt',

    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',



    # Additional stuff for the LaTeX preamble.
    #
    'preamble': '''
    \usepackage{xeCJK}
    \usepackage{indentfirst}
    \setlength{\parindent}{2em}
    \setmainfont{Times New Roman}
    \setCJKmainfont[BoldFont=Microsoft YaHei, ItalicFont=KaiTi]{SimSun}
    '''
}

# If given, this must be the name of an image file (relative to the configuration directory) 
# that is the logo of the docs. It is placed at the top of the title page. Default: None.
latex_logo = 'Mylogo.png'

makepdf.bat

::
cmd /c start make clean
ping -n 3 127.0.0.1>nul
cmd /c start make latex
ping -n 8 127.0.0.1>nul
::
cd build\latex\
xelatex MyTex.tex
xelatex MyTex.tex
cd ..
rd /s /q pdf
mkdir pdf
copy latex\MyTex.pdf pdf\MyTex.pdf
pause

Recommand

Sphinx-doc编写文档