43

sphinx-buildを使用してドキュメントディレクトリ(html)を作成するのに問題があります。

私は試した

sphinx-build -b html source build

と同様

make html

ただし、どちらの場合も、htmlファイルsearch.html、index.html、およびgenindex.htmlのみが生成されます。ファイルmodindex.htmlがありません。

conf.pyファイルで設定しました

html_domain_indices = True

したがって、modindex.htmlファイルが必要です。私は何が間違っているのですか?htmlファイルをビルドした後もエラーメッセージは表示されません。WindowsXPでSphinx1.1.3とPython2.7を使用しています。

4

3 に答える 3

40

短縮版

  • 走るsphinx-apidoc -o . mymodule
  • コメントを外して変更しconf.pyます。この例では、sys.path.insert(0, os.path.abspath('mymodule'))
  • 再実行make html

長い答え

このサンプル モジュールで問題を再現できます。

$cat mymodule/mymodule.py
def fn1():
    '''First function'''
    pass

def fn2():
    '''Second function'''
    pass

実行sphinx-quickstartすると、次のツリーが生成されます。

$tree
.
├── Makefile
├── _build
├── _static
├── _templates
├── conf.py
├── index.rst
├── mymodule
    └── mymodule.py

$cat index.rst
.. sphinx example documentation master file, created by
   sphinx-quickstart on Mon Mar 30 15:28:37 2015.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

デフォルトでindex.rst:

Welcome to sphinx example's documentation!
==========================================

Contents:

.. toctree::
   :maxdepth: 2



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

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

make htmlこの時点で実行しても、 には何も出力されません_build/html/py-modindex.html。これは、sphinxすべてのモジュールを記述する .rst ファイルが必要だからです。幸いなことに、 を使用して簡単に作成できsphinx-apidoc -o . mymoduleます。これにより、mymodule.rst問題の modindex 問題を修正するためにのみ必要な 2 つの新しいファイルが作成されます。

$head *mod*rst
==> modules.rst <==
mymodule
========

.. toctree::
   :maxdepth: 4

   mymodule

==> mymodule.rst <==
mymodule module
===============

.. automodule:: mymodule
    :members:
    :undoc-members:
    :show-inheritance:

この時点での実行make htmlはまだ機能しません。sys.path.insertしかし、コメントを外してin で始まる行を変更すると問題が解決しconf.pyます。

私は:sys.path.insert(0, os.path.abspath('mymodule'))

PS: 追加の警告を回避するには、ファイルの toctree に追加modulesしてください。Contents:index.rst

于 2015-03-30T22:55:06.660 に答える