Skip to content
Snippets Groups Projects
Commit b388bef2 authored by Benjamin Hättasch's avatar Benjamin Hättasch
Browse files

Build docs using Sphinx & deliver under /docs/

Add requirements to automatically build the documentation using sphinx
Add basic configuration for documentation
Add django-docs app to deliver documentation as part of the app under /docs/
Add generating/updating of the docs to the setup and update scripts
parent 20f1d8f2
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,7 @@ INSTALLED_APPS = [ ...@@ -55,6 +55,7 @@ INSTALLED_APPS = [
'bootstrap_datepicker_plus', 'bootstrap_datepicker_plus',
'django_tex', 'django_tex',
'compressor', 'compressor',
'docs',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -234,4 +235,9 @@ CSP_FONT_SRC = ("'self'", "data:", "fonts.gstatic.com") ...@@ -234,4 +235,9 @@ CSP_FONT_SRC = ("'self'", "data:", "fonts.gstatic.com")
SEND_MAILS = True SEND_MAILS = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Documentation
DOCS_ROOT = os.path.join(BASE_DIR, 'docs/_build/html')
DOCS_ACCESS = 'public'
include(optional("settings/*.py")) include(optional("settings/*.py"))
"""AKPlanning URL Configuration """
AKPlanning URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see: The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/ https://docs.djangoproject.com/en/2.2/topics/http/urls/
...@@ -13,13 +14,15 @@ Including another URLconf ...@@ -13,13 +14,15 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path 1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
import debug_toolbar import debug_toolbar
from django.apps import apps from django.apps import apps
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include, re_path
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
re_path(r'^docs/', include('docs.urls')),
path('accounts/', include('django.contrib.auth.urls')), path('accounts/', include('django.contrib.auth.urls')),
path('accounts/', include('registration.backends.simple.urls')), path('accounts/', include('registration.backends.simple.urls')),
path('', include('AKModel.urls', namespace='model')), path('', include('AKModel.urls', namespace='model')),
......
...@@ -26,4 +26,9 @@ python manage.py compilemessages -l de_DE ...@@ -26,4 +26,9 @@ python manage.py compilemessages -l de_DE
# Credentials are entered interactively on CLI # Credentials are entered interactively on CLI
python manage.py createsuperuser python manage.py createsuperuser
# Generate documentation
cd docs
./make html
cd ..
deactivate deactivate
...@@ -27,4 +27,10 @@ pip install --upgrade -r requirements.txt ...@@ -27,4 +27,10 @@ pip install --upgrade -r requirements.txt
./manage.py collectstatic --noinput ./manage.py collectstatic --noinput
./manage.py compilemessages -l de_DE ./manage.py compilemessages -l de_DE
# Update documentation
cd docs
./make html
cd ..
touch AKPlanning/wsgi.py touch AKPlanning/wsgi.py
_build/
code/
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Code
=====
.. toctree::
code/AKDashboard
code/AKModel
code/AKOnline
code/AKPlan
code/AKScheduling
code/AKSubmission
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys
from recommonmark.parser import CommonMarkParser
import django
import sphinx_bootstrap_theme
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'AK Planning'
copyright = '2023, N. Geisler, B. Hättasch & more'
author = 'N. Geisler, B. Hättasch & more'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinxcontrib.apidoc', # runs sphinx-apidoc automatically as part of sphinx-build
'sphinx.ext.autodoc', # the autodoc extensions uses files generated by apidoc
"sphinx.ext.autosummary",
"sphinxcontrib_django",
'sphinx.ext.viewcode', # enable viewing autodoc'd code
]
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Django specific settings ------------------------------------------------
# Add source directory to sys.path
sys.path.insert(0, os.path.abspath(".."))
# Configure the path to the Django settings module
django_settings = "AKPlanning.settings"
os.environ['DJANGO_SETTINGS_MODULE'] = django_settings
django.setup()
# Auto-generate API documentation.
os.environ['SPHINX_APIDOC_OPTIONS'] = "members,show-inheritance"
# -- Input ----
source_parsers = {
'.md': CommonMarkParser,
}
source_suffix = ['.rst', '.md']
# -- Extension Conf ----
autodoc_member_order = 'bysource'
autodoc_inherit_docstrings = False
apidoc_module_dir = '../'
apidoc_output_dir = 'code'
apidoc_excluded_paths = ['AKDashboard/migrations',
'AKModel/migrations',
'AKOnline/migrations',
'AKPlan/migrations',
'AKScheduling/migrations',
'AKSubmission/migrations',
'AKPlanning/',
'manage.py',
'docs',
'locale',
'Utils'
]
apidoc_separate_modules = True
apidoc_toc_file = False
apidoc_module_first = True
apidoc_extra_args = ['-f']
apidoc_project = project
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
#html_theme = 'alabaster'
html_static_path = ['_static']
html_theme = 'sphinx_rtd_theme'
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
.. AK Planning documentation master file, created by
sphinx-quickstart on Wed Jun 21 09:54:11 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Start
=======================================
.. toctree::
:maxdepth: 2
:caption: Contents:
usage/usage
code
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
Usage
=====
.. toctree::
...@@ -16,3 +16,11 @@ django-libsass==0.9 ...@@ -16,3 +16,11 @@ django-libsass==0.9
django-betterforms==2.0.0 django-betterforms==2.0.0
mysqlclient==2.1.1 # for production deployment mysqlclient==2.1.1 # for production deployment
tzdata==2023.3 tzdata==2023.3
# Documentation
sphinxcontrib-django==2.3
sphinxcontrib-apidoc==0.3.0
recommonmark==0.7.1
django-docs==0.3.3
sphinx-rtd-theme==1.2.2
sphinx==7.0.1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment