django app/models.py的Sphinx apidoc奇怪输出
我在django项目生成的文档中得到了一些遗漏的信息,例如django app/models.py的Sphinx apidoc奇怪输出,django,python-3.x,python-sphinx,sphinx-apidoc,Django,Python 3.x,Python Sphinx,Sphinx Apidoc,我在django项目生成的文档中得到了一些遗漏的信息,例如first\u name和last\u name,email遗漏了(尽管它们是在父抽象类中定义的)。如何控制基于sphinx apidoc扫描添加到文档中的内容?我的目标是根据文档自动生成文档,但sphinx apidoc似乎只用于初始搭建一次 我尝试使用:继承的成员:,如下所示,但它仍然没有生成AbstractUser类中存在的名字、姓氏和电子邮件 .. automodule:: apps.users.models :membe
first\u name
和last\u name
,email
遗漏了(尽管它们是在父抽象类中定义的)。如何控制基于sphinx apidoc扫描添加到文档中的内容?我的目标是根据文档自动生成文档,但sphinx apidoc似乎只用于初始搭建一次
我尝试使用:继承的成员:,如下所示,但它仍然没有生成AbstractUser
类中存在的名字、姓氏和电子邮件
.. automodule:: apps.users.models
:members:
:inherited-members:
:show-inheritance:
我执行以下命令
输出
我的应用程序/用户/型号.py
我的狮身人面像
好的,结果我不得不使用
:undoc成员:
,但这造成了混乱
这是必需的,因为django的AbstractUser类没有正确的文档记录,而且sphinx必须被迫只显示定义了UNOC成员的字段。但是undoc成员会造成混乱,所以解决方案就是在docstr子类中为父类中未记录的属性/方法添加文档,然后我的文档显示这些字段
class AppUser(AbstractUser):
"""Custom user model.
Attributes:
avatar (file): user's avatar, cropeed to fill 300x300 px
notifications (dict): settings for notifications to user
first_name (str): first name
last_name (str): last name
"""
好的,结果我不得不使用
:undoc成员:
,但这造成了混乱
这是必需的,因为django的AbstractUser类没有正确的文档记录,而且sphinx必须被迫只显示定义了UNOC成员的字段。但是undoc成员会造成混乱,所以解决方案就是在docstr子类中为父类中未记录的属性/方法添加文档,然后我的文档显示这些字段
class AppUser(AbstractUser):
"""Custom user model.
Attributes:
avatar (file): user's avatar, cropeed to fill 300x300 px
notifications (dict): settings for notifications to user
first_name (str): first name
last_name (str): last name
"""
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import django
import sphinx_py3doc_enhanced_theme
sys.path.insert(0, os.path.abspath('../'))
sys.path.insert(0, os.path.abspath('.'))
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "config.settings.local")
django.setup()
# Extensions
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinxcontrib.blockdiag'
]
napoleon_google_docstring = True
napoleon_use_param = True
napoleon_use_ivar = False
napoleon_use_rtype = True
napoleon_include_special_with_doc = False
# RST support
source_suffix = '.rst'
# Name of master doc
master_doc = 'index'
# General information about the project.
project = 'crm'
copyright = '2017, Company'
author = 'Company'
version = '0.1'
release = '0.1'
language = None
exclude_patterns = []
todo_include_todos = False
# Read the docs theme
html_theme = 'sphinx_py3doc_enhanced_theme'
html_theme_path = [sphinx_py3doc_enhanced_theme.get_html_theme_path()]
html_static_path = []
htmlhelp_basename = 'crmdoc'
latex_elements = {}
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'crm', 'crm Documentation',
[author], 1)
]
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'crm', 'crm Documentation',
author, 'crm', 'One line description of project.',
'Miscellaneous'),
]
html_theme_options = {
'githuburl': 'https://github.com/ionelmc/sphinx-py3doc-enhanced-theme/',
'bodyfont': '"Lucida Grande",Arial,sans-serif',
'headfont': '"Lucida Grande",Arial,sans-serif',
'codefont': '"Deja Vu Sans Mono",consolas,monospace,sans-serif',
'linkcolor': '#0072AA',
'visitedlinkcolor': '#6363bb',
'extrastyling': False,
'sidebarwide': True
}
pygments_style = 'friendly'
html_context = {
'css_files': ['_static/custom.css'],
}
class AppUser(AbstractUser):
"""Custom user model.
Attributes:
avatar (file): user's avatar, cropeed to fill 300x300 px
notifications (dict): settings for notifications to user
first_name (str): first name
last_name (str): last name
"""