簡體   English   中英

如何使用 Sphinx 記錄 Python 包

[英]How to document Python packages using Sphinx

我正在嘗試用 Python 記錄一個包。 目前我有以下目錄結構:

.
└── project
    ├── _build
    │   ├── doctrees
    │   └── html
    │       ├── _sources
    │       └── _static
    ├── conf.py
    ├── index.rst
    ├── __init__.py
    ├── make.bat
    ├── Makefile
    ├── mod1
    │   ├── foo.py
    │   └── __init__.py
    ├── mod2
    │   ├── bar.py
    │   └── __init__.py
    ├── _static
    └── _templates

這棵樹是sphinx-quickstart觸發的結果。 conf.py我取消注釋sys.path.insert(0, os.path.abspath('.'))並且我有extensions = ['sphinx.ext.autodoc']

我的index.rst是:

.. FooBar documentation master file, created by
   sphinx-quickstart on Thu Aug 28 14:22:57 2014.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to FooBar's documentation!
==================================

Contents:

.. toctree::
   :maxdepth: 2

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

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

在所有__init__.py ,我有一個文檔字符串,同樣適用於模塊foo.pybar.py 但是,在項目中運行make html時,我看不到任何文檔。

這是一個大綱:

  1. 使用源文件中的文檔字符串記錄您的包。
  2. 使用sphinx-quickstart創建一個 Sphinx 項目。
  3. 運行sphinx-apidoc以生成設置為與autodoc一起使用的 .rst 源。 更多信息 在這里

    將此命令與-F標志一起使用還可以創建一個完整的 Sphinx 項目。 如果您的 API 變化很大,您可能需要多次重新運行此命令。

  4. 使用sphinx-build構建文檔。

筆記:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM