sphinxcontrib_django

This is a sphinx extension which improves the documentation of Django apps.

sphinxcontrib_django.setup(app)

Allow this module to be used as sphinx extension.

Setup the two sub-extensions docstrings and roles which can also be imported separately.

Parameters:

app (Sphinx) – The Sphinx application object

Docstrings

Roles

This module adds cross-reference types which are used in the documentation of Django and Sphinx to allow intersphinx mappings to these custom types. The supported text roles are:

Django:

  • :setting:, e.g. :setting:`INSTALLED_APPS` renders as INSTALLED_APPS

  • :templatetag:, e.g. :templatetag:`block` renders as block

  • :templatefilter:, e.g. :templatefilter:`add` renders as add

  • :fieldlookup:, e.g. :fieldlookup:`equals` renders as equals

Sphinx:

This module can also be used separately in conf.py:

extensions = [
    "sphinxcontrib_django.roles",
]
sphinxcontrib_django.roles.add_default_intersphinx_mappings(app, config)

This function provides a default intersphinx mapping to the documentations of Python, Django and Sphinx if intersphinx_mapping is not given in conf.py.

Called on the config-inited event.

Parameters:
  • app (Sphinx) – The Sphinx application object

  • config (Config) – The Sphinx configuration

sphinxcontrib_django.roles.setup(app)

Allow this module to be used as Sphinx extension.

This is also called from the top-level setup().

It adds cross-reference types via add_crossref_type().

Parameters:

app (Sphinx) – The Sphinx application object