python .rst转.html

Posted XiaO天

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python .rst转.html相关的知识,希望对你有一定的参考价值。

#先安装lib库
pip install sphinx

 

创建一个文件夹,随便名字,例如 test

 

cmd中执行命令

 

sphinx-quickstart


> Root path for the documentation [.]: doc  # 在当前目录下新建doc文件夹存放sphinx相关信息
> Separate source and build directories (y/n) [n]:   # 默认,直接回车
> Name prefix for templates and static dir [_]:
> Project name: python123   # 输入项目名称
> Author name(s): 123   # 作者
> Project version: 1.0  # 项目版本
> Project release [1.0]:
> Project language [en]:   # 默认,回车
> Source file suffix [.rst]:
> Name of your master document (without suffix) [index]:
> Do you want to use the epub builder (y/n) [n]:
> autodoc: automatically insert docstrings from modules (y/n) [n]: y  # 这个很重要,输入y
> doctest: automatically test code snippets in doctest blocks (y/n) [n]:
> intersphinx: link between Sphinx documentation of different projects (y/n) [n]:
> todo: write "todo" entries that can be shown or hidden on build (y/n) [n]:
> coverage: checks for documentation coverage (y/n) [n]:
> pngmath: include math, rendered as PNG images (y/n) [n]:
> mathjax: include math, rendered in the browser by MathJax (y/n) [n]:
> ifconfig: conditional inclusion of content based on config values (y/n) [n]:
> viewcode: include links to the source code of documented Python objects (y/n) [n]: y  # 很重要,输入y,表示将源码也放到文档中,你看很多python的模块的文档,其实都是包含代码的。
> Create Makefile? (y/n) [y]:
> Create Windows command file? (y/n) [y]:

 

会新增一个doc文件夹,目录结构

 

 

将需要转的rst文件复制到doc文件夹里面 改明为index.rst  如果不想改名字 就到conf.py里面改下配置文件

 

_build中就为需要的html了~

以上是关于python .rst转.html的主要内容,如果未能解决你的问题,请参考以下文章

Python代码阅读(第41篇):矩阵转置

实用代码片段将json数据绑定到html元素 (转)

Python-doc rst文件打开

python调试:pdb基本用法(转)

Python-doc rst文件打开

Python-doc .rst文件打开