如何自定义sphinx.ext.autosummary第一个模板?

How to customize sphinx.ext.autosummary rst template?

Here 在 Sphinx 的文档中说可以重新定义那些模板。 因此,我尝试将 module.rst/site-packages/sphinx/ext/autosummary 复制到 source/_templates/autosummary(也尝试了 source/_templates),并做了一些细微的改动。但是在我重新生成文档之后没有任何改变。

也许我应该在 .. autosummary:: 标签中添加一些特定的选项来指定自定义模板目录? (在 conf.py 目录中设置正确,sphinx 也参见 html 模板)

UPD:源代码:https://github.com/actionless/wooper/blob/master/docs.sh

如果您执行以下操作,它应该会起作用:

  1. 确保templates_path配置变量的值在conf py中设置为['_templates']
  2. 将自定义模板放在 _templates 子目录中。
  3. 使用:template:选项:

    .. autosummary::
      :template: mytemplate.rst
    

已编辑:我最初在这里发布了错误问题的答案。但是,在这里也可能有所帮助。

  • Sphinx autosummary: How to remove automember for __init__

可以通过将自定义文件添加到 _templates 文件夹来 'overrule' 默认模板。例如,如果您想更改调用自动摘要指令时使用的 类 的模板,请在此路径下创建自定义 class.rst 文件:

  • _templates/autosummary/class.rst

无需明确指定 :template: 即可自动获取。