使用Sphinx与Django的autodoc

时间:2015-08-05 16:21:47

标签: python django python-sphinx

我无法通过应用程序让Sphinx为我的Django项目生成自动文档。 models.py个文件。当我运行make html时,我收到了警告

WARNING: toctree contains reference to nonexisting document u'modules/models'

我的目录设置是:

.../www/proj/manage.py
             /proj/settings.py
                  /urls.py
                  ...
             /myapp1/models.py
                   /views.py
                   ...
             /docs/Makefile
                  /build/
                  /modules/models.rst
                  /source/conf.py
                         /index.rst
                         ...

index.rst的相关位是:

Documentation for qdb
=====================

Contents:

.. toctree::
   :maxdepth: 2

   modules/models



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

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

modules/models.rst是:

Models
======
.. automodule:: myapp1.models
    :members:

来自conf.py的位是:

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../..'))
from django.conf import settings
settings.configure()

我也尝试过:

sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'qdb.settings'

但这也不起作用。如何告诉Sphinx在哪里找到modules/models.rst

[我在Python 2.7上,Django 1.8,Sphinx 1.3.1]

0 个答案:

没有答案