django - Sphinx 文档和 autodoc-skip-member

标签 django python-sphinx documentation-generation sphinx-apidoc

我正在通过以下方式为 django 项目构建我的 sphinx 文档:

sphinx-apidoc app -o docs/source/app --force

现在它包括了我不想在我的文档中包含的所有南方迁移。我现在尝试通过以下方式排除它们:
conf.py:
    def skip_migrations(app, what, name, obj, skip, options):
        return skip or (what == 'module' and name.find('Migration') != -1)\ 
               or str(obj).find('migrations') != -1

    def setup(app):
       app.connect('autodoc-skip-member', skip_migrations)

现在它们不再被记录,但仍列在模块下。我怎样才能排除它们?

最佳答案

您可以通过将它们添加到 conf.py 文件中的 exclude_pattern 来排除为迁移创建的第一个文件:

exclude_patterns = ["**/*.migrations.rst",]

关于django - Sphinx 文档和 autodoc-skip-member,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16437778/

相关文章:

python - 属性错误: 'Values' object has no attribute 'tab_width' when running sphinx-build

python - Django - 一个计数器模板标签,即使与嵌套的 for 标签也能很好地工作

python - 是否可以从 Django 服务器端检测浏览器版本?

c++ - 狮身人面像 : Correct way to document an enum?

lua - 如何在ubuntu/linux中使用luadoc?

javascript - 如何给JSDoc添加标签?

documentation - 如何将 LuaDoc 与 LuaForWindows 一起使用

python - 如何在现有应用程序中使用 django-scheduler 应用程序

django - 长时间运行请求的 nginx 502 错误网关

python - Python 模块/包名称的 Sphinx apidoc 部分标题