Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown interpreted text role "setting" with Django docstring and Sphinx

I'm documenting a Djagno 2.2 application.

The Django documentation states linking to the settings as

Add :mod:`django.contrib.auth` to your :setting:`INSTALLED_APPS`...

In my documentation, The statement is

The length is defined in the :setting:`URL_ID_LENGTH`

When generating the documentation using Sphinx

make html

Gives WARNING

:docstring of app.models.Class.function:4: WARNING: Unknown interpreted text role "setting".

I have sphinx.ext.intersphinx added to the conf.py of Sphinx.

like image 695
Anuj TBE Avatar asked Oct 19 '25 06:10

Anuj TBE


1 Answers

According to the Django documentation, it has its own specific markup.

You will need to add djangodocs from Django's conf.py into yours:

extensions = [
    "djangodocs",
    'sphinx.ext.extlinks',
    "sphinx.ext.intersphinx",
    "sphinx.ext.viewcode",
]

Then place the djangodocs extension file into your docs/_ext/djangodocs.py.

And finally import its path with something like this:

sys.path.append(abspath(join(dirname(__file__), "_ext")))
like image 148
Steve Piercy Avatar answered Oct 21 '25 00:10

Steve Piercy