我正在使用多个应用程序运行django项目。我正在尝试使用狮身人面像记录它。我安装了狮身人面像并配置了所有内容(-我认为正确-)。为了生成文档,我先运行sphinx-apidoc -o . ..
,然后运行make html
。
现在发生的是,狮身人面像为我的所有迁移都创建了模块,但其中不包含任何视图(我认为这是最重要的)。问题可能是所有导入错误:(我不想在虚拟环境中安装所有导入)
WARNING: autodoc: failed to import module 'adapters' from module 'myapp.users'; the following exception was raised:
No module named 'allauth'
WARNING: autodoc: failed to import module 'admin' from module 'myapp.users'; the following exception was raised:
Traceback (most recent call last):
.....this keeps going for a while like this
WARNING: autodoc: failed to import module 'merge_production_dotenvs_in_dotenv'; the following exception was raised:
No module named 'pytest'
WARNING: autodoc: failed to import module 'admin' from module 'myapp'; the following exception was raised:
No module named 'psycopg2'
WARNING: autodoc: failed to import module 'models' from module 'myapp'; the following exception was raised:
No module named 'psycopg2'
WARNING: autodoc: failed to import module 'urls' from module 'myapp'; the following exception was raised:
No module named 'rest_framework'
我的问题是双重的,一个概括,一个具体。通常,运行sphinx时django项目中应包含一个文档。我的意思是,是的,我想要的一切,但是有标准吗?像文档视图,模型,测试一样,但忽略了设置?
更具体地说,如何告诉Sphinx将配置中的某些模块列入黑名单/白名单?我尝试使用sphinx-apidoc -o . .. */migrations/*
将迁移列入黑名单,但无论如何它只是创建了文件。同样,传递分类参数也不是最优的。我想在设置中的某处指定它,因此不必传递每条路径。
我还假设将黑名单作为首选方法,因为在添加新模块时,我不想每次都将新条目添加到白名单中。我希望狮身人面像能够自动记录所有内容,而没有引发所有错误的有问题的模块,以及由于明显原因(例如迁移)我不想记录的那些模块。
我不明白为什么sphinx会为它们创建模块,因为它们没有文档字符串。
我的设置非常标准:
import os
import sys
sys.path.insert(0,os.path.abspath('..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
from django.conf import settings
settings.configure()
extensions = [
"sphinx.ext.autosummary","sphinx.ext.autodoc","sphinx.ext.coverage","sphinx.ext.doctest","sphinx.ext.napoleon",]
有人可以帮我吗?非常感谢每一个建议或帮助:)预先感谢!