12

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's には docstring があり、同じことがモジュールfoo.pyおよびbar.py. ただし、make htmlプロジェクトで実行すると、ドキュメントが表示されません。

4

1 に答える 1

7

概要は次のとおりです。

  1. ソース内の docstring を使用してパッケージを文書化します。
  2. sphinx-quickstartを使用して Sphinx プロジェクトを作成します。
  3. sphinx-apidocを実行して、 autodocで使用するためにセットアップされた .rst ソースを生成します。詳細はこちら

    このコマンドを-Fフラグとともに使用すると、完全な Sphinx プロジェクトも作成されます。API が大幅に変更された場合は、このコマンドを数回再実行する必要がある場合があります。

  4. sphinx-buildを使用してドキュメントをビルドします。

ノート:

于 2014-08-28T18:51:44.360 に答える