简体   繁体   English

如何从Django模型生成文档?

[英]How to generate documentation from Django models?

At the moment we use Sphinx for project documentation and Django models field description. 目前,我们将Sphinx用于项目文档和Django模型字段描述。

The main problem is that: after changing models, we manually updated Sphinx docs and sometimes forget/miss some fields in docs. 主要问题是:更改模型后,我们手动更新了Sphinx文档,有时会忘记/错过文档中的某些字段。

Is there some tool for generate docs based on Django models? 有一些用于基于Django模型生成文档的工具吗?

The documentation says: 文件说:

Django's documentation uses the Sphinx documentation system, which in turn is based on docutils. Django的文档使用Sphinx文档系统,该系统又基于docutils。 The basic idea is that lightly-formatted plain-text documentation is transformed into HTML, PDF, and any other output format. 基本思想是将格式简单的纯文本文档转换为HTML,PDF和任何其他输出格式。

So you should just use sphinx to generate the doc for your django application. 因此,您应该只使用sphinx为django应用程序生成文档。 You should activate pulling documentation from docstrings in sphinx using the autodoc extension, to activate put this in your conf.py for sphinx: 您应该使用autodoc扩展名激活从sphinx中的文档字符串中提取文档,以激活将其放入conf.py以获取sphinx:

extensions = [
    'sphinx.ext.autodoc',
]

为Django生成文档的最佳方法-使用admindocs 应用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM