From d314dce4a2a1cd7a448d646d775d657774745aa7 Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Mon, 15 Jul 2019 09:43:29 +0200 Subject: [PATCH] Fix building docs --- docs/_ext/djangodummy/requirements.txt | 3 +- docs/_ext/djangoext/__init__.py | 0 docs/_ext/djangoext/docstrings.py | 41 -------------------------- docs/_ext/djangoext/roles.py | 8 ----- docs/conf.py | 3 +- tox.ini | 1 + 6 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 docs/_ext/djangoext/__init__.py delete mode 100644 docs/_ext/djangoext/docstrings.py delete mode 100644 docs/_ext/djangoext/roles.py diff --git a/docs/_ext/djangodummy/requirements.txt b/docs/_ext/djangodummy/requirements.txt index b182c33..e1da1ca 100644 --- a/docs/_ext/djangodummy/requirements.txt +++ b/docs/_ext/djangodummy/requirements.txt @@ -1,4 +1,5 @@ # for readthedocs # Remaining requirements are picked up from setup.py -Django==1.11 +Django==2.1 django-extra-views==0.9.0 +sphinxcontrib-django >= 0.4 diff --git a/docs/_ext/djangoext/__init__.py b/docs/_ext/djangoext/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/docs/_ext/djangoext/docstrings.py b/docs/_ext/djangoext/docstrings.py deleted file mode 100644 index d52abbb..0000000 --- a/docs/_ext/djangoext/docstrings.py +++ /dev/null @@ -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) diff --git a/docs/_ext/djangoext/roles.py b/docs/_ext/djangoext/roles.py deleted file mode 100644 index b5ed3e1..0000000 --- a/docs/_ext/djangoext/roles.py +++ /dev/null @@ -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", - ) diff --git a/docs/conf.py b/docs/conf.py index 77db62e..a93456c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -36,8 +36,7 @@ extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.graphviz', 'sphinx.ext.intersphinx', - 'djangoext.docstrings', - 'djangoext.roles', + 'sphinxcontrib_django', ] # Add any paths that contain templates here, relative to this directory. diff --git a/tox.ini b/tox.ini index 005cd78..7346aa2 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,7 @@ deps = sphinx_rtd_theme Django django-extra-views + sphinxcontrib-django changedir = docs commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html