diff --git a/pdm.lock b/pdm.lock index fc2a180878e627a6b327c9f3e350463bde626029..58ead28a30d4e7f10561ecaa48d2a74c33ad95a2 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "lint", "local"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:ff4b6100ab5701fd2db52fc09ab9dd6fe1204796bef99587a8b440570d0eb515" +content_hash = "sha256:a7320608dc0e3c00f197dee7ada9261e62bd35dd235e56b9532d22126d225946" [[metadata.targets]] requires_python = "==3.13.*" @@ -596,6 +596,17 @@ files = [ {file = "djlint-1.35.2.tar.gz", hash = "sha256:318de9d4b9b0061a111f8f5164ecbacd8215f449dd4bd5a76d2a691c815ee103"}, ] +[[package]] +name = "docutils" +version = "0.21.2" +requires_python = ">=3.9" +summary = "Docutils -- Python Documentation Utilities" +groups = ["dev"] +files = [ + {file = "docutils-0.21.2-py3-none-any.whl", hash = "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2"}, + {file = "docutils-0.21.2.tar.gz", hash = "sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f"}, +] + [[package]] name = "editorconfig" version = "0.12.4" diff --git a/pyproject.toml b/pyproject.toml index 10f698efa1be197bd878f1af19ef9d9dc1611047..ce737d4e3f11d3e6ef3c777d2a38263fbf0c1762 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,6 +68,7 @@ dev = [ "coverage>=7.4.0", "tox-pdm>=0.7.2", "pre-commit>=3.6.0", + "docutils>=0.21.2", ] [tool.pdm.scripts] diff --git a/requirements.dev.txt b/requirements.dev.txt index 78e40571dec34faf789f564d71320f7b05e55175..da13333eeabfcc34a0ea3697db434cabd74c7543 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -39,6 +39,7 @@ django-timezone-field==7.0 django-widget-tweaks==1.5.0 djangorestframework==3.15.2 djlint==1.35.2 +docutils==0.21.2 editorconfig==0.12.4 et-xmlfile==1.1.0 executing==2.1.0 diff --git a/src/hub/settings/default.py b/src/hub/settings/default.py index 7dd95cacf958a8f20aed8418c6198c81f5c3a37a..e18b01a3da1542359ece816cd08c83e21283ae2e 100644 --- a/src/hub/settings/default.py +++ b/src/hub/settings/default.py @@ -82,6 +82,9 @@ if DEBUG and SECRET_KEY is None: # noqa: F405 except OSError: raise Exception(f'Please create a {SECRET_FILE} file with random characters to serve as your Django SECRET_KEY!') +if DEBUG: # noqa: F405 + INSTALLED_APPS.insert(INSTALLED_APPS.index('django.contrib.staticfiles') + 1, ('django.contrib.admindocs')) # noqa: F405 + # include API django api if IS_API: # add 'api' app and ensure 'core' and it are before 'oauth2_provider' and 'rest_framework' for proper template loading diff --git a/src/hub/urls.py b/src/hub/urls.py index cbfbfccf967aca9c8112d409ba91b7cb76d3ce70..a6be1c306a42cf1e4db15d745d81d55ca548d45c 100644 --- a/src/hub/urls.py +++ b/src/hub/urls.py @@ -63,6 +63,9 @@ if not any(services.values()): # Any service that is not the last one is served with a prefix. # The last service is served at root. # Priority: Frontend -> Backoffice -> API -> Admin +if 'django.contrib.staticfiles' in settings.INSTALLED_APPS: + # Add the Admin Docs package to show current Documentation generated from docstrings + urlpatterns += add_service('admin', 'c3admin/docs/', include('django.contrib.admindocs.urls')) urlpatterns += add_service('admin', 'c3admin/', admin.site.urls) urlpatterns += (path('i18n/setlang/', views.set_language, name='set_language'),) services.pop('admin')