0

我正在学习Sphinx来记录我的Django项目。

我的项目结构就像

app
|- docs
   |- build
   |- source
      |- conf.py
      |- index.rst
   |- make.bat
   |- Makefile
|- src
   |- authentication
      |- __init__.py
      |- models.py
      |- ...
   |- myapp
      |- __init__.py
      |- settings.py
      |- wsgi.py
   |- manage.py

在 `app/docs/source/conf.py 中,查找 doc 的路径设置为

import os
import sys
sys.path.insert(0, os.path.abspath('../../src'))

并且index.rst有内容

App's documentation!
=============================================

.. automodule:: manage
   :members:

.. toctree::
   :maxdepth: 2
   :caption: Contents:



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

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

在运行中

make html

它生成带有默认内容的空白文档页面,并且没有来自 Django 应用程序的内容。

我创建了许多应用程序,每个应用程序都包含许多文件。我想从整个 Django 应用程序的文档字符串中自动生成文档。

4

1 回答 1

0

看看这个https://medium.com/@sschannak/sphinx-for-django-documentation-2b9c900c6cfa。看起来您缺少 django 设置,您需要.. automodule::为您添加要记录的项目模块。

于 2019-06-19T12:23:05.217 回答