From 70742bfd91a3476514db75e5f4571ad8b44cba4c Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 22 Aug 2024 10:45:47 -0700 Subject: [PATCH] doc/dev: Fix Django related errors with auto-documentation Closes: #2405. - When Django module is mocked, there are some cases where modules using django can't be imported due to errors. - To fix that, don't mock the django module and require django and related Debian packages to be installed on the system generate developer documentation. - Initialize django in Sphinx configuration to allow django modules to be imported without errors. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- doc/dev/README.rst | 5 +++++ doc/dev/conf.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/dev/README.rst b/doc/dev/README.rst index 9df33066e..66612209f 100644 --- a/doc/dev/README.rst +++ b/doc/dev/README.rst @@ -19,6 +19,11 @@ Install the following Debian packages: * python3-sphinx * python3-sphinx-autobuild +* python3-django +* python3-django-axes +* python3-django-captcha +* python3-django-ipware +* python3-django-stronghold If your preferred text editor doesn't have support for the reStructuredText format, you can install a simple desktop application called ReText. It has live diff --git a/doc/dev/conf.py b/doc/dev/conf.py index 3aba53caa..2c96eef73 100644 --- a/doc/dev/conf.py +++ b/doc/dev/conf.py @@ -16,7 +16,11 @@ list see the documentation: http://www.sphinx-doc.org/en/master/config import os import sys +import django + sys.path.insert(0, os.path.abspath('../../')) +os.environ['DJANGO_SETTINGS_MODULE'] = 'plinth.settings' +django.setup() # -- Project information ----------------------------------------------------- @@ -203,7 +207,6 @@ autodoc_mock_imports = [ 'cherrypy', 'configobj', 'dbus', - 'django', 'gi', 'markupsafe', 'OpenSSL',