安装
pip install sphinx
使用
sphinx-quickstart
快速构建框架
mkdir docscd docssphinx-quickstart # 按提示输入

目录结构
.├── build├── make.bat├── Makefile└── source├── conf.py # 配置文件├── index.rst # 入口文件├── _static└── _templates
修改配置文件
import osimport sysBASE_DIR = os.path.dirname(os.path.realpath(__file__))PKG_DIR = os.path.dirname(os.path.dirname(BASE_DIR))print(PKG_DIR)sys.path.insert(0, PKG_DIR) # 添加docs上层目录到PYTHONPATH中,才可以搜索到上层目录的package# ...# 修改extensionsextensions = ['sphinx.ext.autodoc','sphinx.ext.coverage','sphinx.ext.intersphinx','sphinx.ext.viewcode',]# 替换主题# html_theme = 'alabaster'html_theme = 'sphinx_rtd_theme'# 添加master_doc(否则Read the Docs构建时会报错)master_doc = 'index'
sphinx-apidoc
为上层目录的
bam2html目录自动生成apidoc
sphinx-apidoc -o source/api ../bam2html/
make
构建HTML
编辑index.rst
.. bam2html documentation master file, created bysphinx-quickstart on Fri Aug 28 14:33:06 2020.You can adapt this file completely to your liking, but it should at leastcontain the root `toctree` directive.====================================Bam2HTML |version| Documentation====================================Bam2HTML is a tool to generate highlighted html file from bam, which is based onthe command `samtools tview`.API Reference=============.. toctree:::caption: APIs:hidden:api/modules:doc:`api/modules`The APIs of modulesIndices and tables==================* :ref:`genindex`* :ref:`modindex`
make html

浏览器查看效果
cd build/htmlpython -m SimpleHTTPServer 8088

