doc/dev: Allow all modules to be imported by Sphinx

Setup Django in Sphinx conf.py so that any Django models can be imported.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2020-02-11 21:04:19 -08:00 committed by James Valleroy
parent 837e8fc6e1
commit 94df52ba73
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -16,8 +16,24 @@ list see the documentation: http://www.sphinx-doc.org/en/master/config
import os
import sys
import django
import django.conf
sys.path.insert(0, os.path.abspath('../../'))
# -- Django setup ------------------------------------------------------------
# Ensure that Django models can be imported by Sphinx
import plinth.settings # noqa pylint: disable=E402 isort:skip
kwargs = {}
for setting in dir(plinth.settings):
if setting.isupper():
kwargs[setting] = getattr(plinth.settings, setting)
django.conf.settings.configure(**kwargs)
django.setup(set_prefix=True)
# -- Project information -----------------------------------------------------
# pylint: disable=invalid-name