Fix building docs

fix_request_path_info
Diederik van der Boor 2019-07-15 09:43:29 +02:00
parent 8c8a920433
commit d314dce4a2
No known key found for this signature in database
GPG Key ID: 4FA014E0305E73C1
6 changed files with 4 additions and 52 deletions

View File

@ -1,4 +1,5 @@
# for readthedocs # for readthedocs
# Remaining requirements are picked up from setup.py # Remaining requirements are picked up from setup.py
Django==1.11 Django==2.1
django-extra-views==0.9.0 django-extra-views==0.9.0
sphinxcontrib-django >= 0.4

View File

@ -1,41 +0,0 @@
"""
Automatically mention all model fields as parameters in the model construction.
Based on http://djangosnippets.org/snippets/2533/
"""
import inspect
from django.utils.encoding import force_text
from django.utils.html import strip_tags
def improve_model_docstring(app, what, name, obj, options, lines):
from django.db import models # must be inside the function, to allow settings initialization first.
if inspect.isclass(obj) and issubclass(obj, models.Model):
model_fields = obj._meta.get_fields()
for field in model_fields:
help_text = strip_tags(force_text(field.help_text))
verbose_name = force_text(field.verbose_name).capitalize()
# Add parameter
if help_text:
lines.append(u':param %s: %s' % (field.attname, help_text))
else:
lines.append(u':param %s: %s' % (field.attname, verbose_name))
# Add type
if isinstance(field, models.ForeignKey):
to = field.rel.to
lines.append(u':type %s: %s to :class:`~%s.%s`' % (field.attname, type(field).__name__, to.__module__, to.__name__))
else:
lines.append(u':type %s: %s' % (field.attname, type(field).__name__))
# Return the extended docstring
return lines
# Allow this module to be used as sphinx extension:
def setup(app):
# Generate docstrings for Django model fields
# Register the docstring processor with sphinx
app.connect('autodoc-process-docstring', improve_model_docstring)

View File

@ -1,8 +0,0 @@
# Allow :django:setting:`SITE_ID` to work.
def setup(app):
app.add_crossref_type(
directivename = "setting",
rolename = "setting",
indextemplate = "pair: %s; setting",
)

View File

@ -36,8 +36,7 @@ extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.autodoc',
'sphinx.ext.graphviz', 'sphinx.ext.graphviz',
'sphinx.ext.intersphinx', 'sphinx.ext.intersphinx',
'djangoext.docstrings', 'sphinxcontrib_django',
'djangoext.roles',
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.

View File

@ -29,6 +29,7 @@ deps =
sphinx_rtd_theme sphinx_rtd_theme
Django Django
django-extra-views django-extra-views
sphinxcontrib-django
changedir = docs changedir = docs
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html