django - Django 文档字符串和 Sphinx 的未知解释文本角色 "setting"

标签 django python-sphinx

我正在记录 Djagno 2.2 应用程序。

Django documentation链接到设置的状态为

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

在我的文档中,声明是

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

使用Sphinx生成文档时

make html

给出警告

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

我已将 sphinx.ext.intersphinx 添加到 Sphinxconf.py 中。

最佳答案

根据Django documentation ,它有自己特定的标记。

您需要从 Django 的 conf.py 添加 djangodocs进入你的:

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

然后放置djangodocs extension file进入您的 docs/_ext/djangodocs.py

最后import its path像这样的东西:

sys.path.append(abspath(join(dirname(__file__), "_ext")))

关于django - Django 文档字符串和 Sphinx 的未知解释文本角色 "setting",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56803854/

相关文章:

latex - Sphinx latexpdf 忽略文件的一部分

python - 在 Python 模块中使用部分构建 Sphinx autodoc 文档

python - Django/python 查询集 - 将另一个 "child"查询集作为项目添加到每个列表对象?

python - 在 Sphinx : how to show documentation 中嵌入 matplotlib 图

html - 将 HTML 下载为单独的页面

python - 忽略 autodoc 中的一些模块

python - 使用 virtualenv 和 pip 的工作流程

python - Django 中 ModelAdmin 的标签名称

database - 我们可以跨多个 oracle 用户查询多个表并在 Django 的管理 UI 中将行表格化吗

python - django-filter 和聚合函数