docs ├── etc ├── ops ├── setup.py └── example 根据py代码生成rst风格文件,这里我只生成ops/api/contrib下面的py文档 # sphinx-apidoc Creating file docs/make.bat. sphinx-apidoc具体用法参考: http://zh-sphinx-doc.readthedocs.org/en/latest/invocation.html
conf.py文件中启用napoleon: 在conf.py中,将napoleon添加到extensions列表中 extensions = ['sphinxcontrib.napoleon'] 使用sphinx-apidoc 构建你的API文档: $ sphinx-apidoc -f -o docs/source projectdir 这将创建.rst文件供Sphinx处理 $ make html *参考来源:GitHub
这些rst文件没有被自动生成的情况下,可能需要使用sphinx-apidoc去手动的添加: [dechin@dechin-manjaro hiqfermion]$ sphinx-apidoc -f src 还有一点需要注意的是,如果我们直接使用sphinx-apidoc -f src/hiqfermion -o docs/source/这样的指令去生成的话,最终文档中的结构都是hiqfermion.module1 当然,首先我们需要逐一的去执行sphinx-apidoc来生成一些模块化的rst文件:sphinx-apidoc -f src/hiqfermion/module1 -o docs/source/以及sphinx-apidoc
# 代码示例:使用Sphinx生成文档 sphinx-quickstart # 初始化Sphinx项目 sphinx-apidoc -o docs/source mymodule # 生成API文档
WARNING: The scripts sphinx-apidoc, sphinx-autogen, sphinx-build and sphinx-quickstart are installed