Sphinx使用总结

文章介绍了如何使用Sphinx构建项目文档,包括通过pip安装Sphinx和sphinx_rtd_theme,初始化项目,配置conf.py以引入代码路径,使用sphinx-apidoc自动生成文档结构,编辑index.rst并构建HTML文档的过程。
摘要由CSDN通过智能技术生成

Sphinx使用总结

第一步:

pip install sphinx

pip install sphinx_rtd_theme

第二步:

cd project/doc

第三步:

sphinx-quickstart

image-20230110221740607

第四步:配置conf.py

import os
import sys
sys.path.insert(0, os.path.abspath(r'D:\PythonProject\code'))

html_theme = 'sphinx_rtd_theme'
extensions = ['sphinx.ext.autodoc']

第五步: 在doc目录下执行

sphinx-apidoc -o source "D:/PythonProject/code"

第六步:修改index.rst 文件

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

第七步:在doc目录下执行make html,就会生成html文档,打开html文档,就可以了【注意脚本一定要放在main里边】

.\make clean

.\make html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值