From 94df52ba734c7fef83a770c156483fd56ac43890 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 11 Feb 2020 21:04:19 -0800 Subject: [PATCH] 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 --- doc/dev/conf.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/dev/conf.py b/doc/dev/conf.py index db3c54f9f..fa0bc7b69 100644 --- a/doc/dev/conf.py +++ b/doc/dev/conf.py @@ -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