杂七杂八 · 2022年3月20日

Windows下通过Sphinx生成EPUB文档

前言

这个问题是在阅读李笑来的<自学是门手艺>中遇到的,因为我用的是Windows,他在书里基于MACos,无法完全照搬,需要做一个改变(make换sphinx-build)

步骤

以下步骤基于Python Tutorial制作

conda install -c anaconda sphinx #在Anaconda中安装sphinx
git clone https://github.com/python/cpython.git
cd cpython/Doc/tutorial
sphinx-quickstart -q output –sep -p “The Python Tutorial” -a “Guido van Rossum” -r “1.0” -v “1.0” -l “en” –suffix “.rst” –master “index” –ext-autodoc –ext-doctest –ext-intersphinx –ext-todo –ext-coverage –ext-imgmath –ext-mathjax –ext-ifconfig –ext-viewcode –makefile –no-batchfile –no-use-make-mode #制作目录结构配置文件,注意,这里是双引号
copy *.rst output\source\ #拷贝rst文件至source目录下
cd output
sphinx-build -b epub ./source/ ./build/ #制作Epub文档

忽略中间的警告,只要最后提示“build succeed”就代表制作成功了,可以在output\build下找到epub文件。
如果想制作HTML文档,只需将epub换为HTML。

作者:养猫的老鼠
链接:https://www.jianshu.com/p/318ed5c3f58c
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。