actionless
actionless

Reputation: 198

How to customize sphinx.ext.autosummary rst template?

Here in Sphinx's documentation it is said what those templates can be redefined. So I tried to copy module.rst from /site-packages/sphinx/ext/autosummary to source/_templates/autosummary (also tried just source/_templates) with some slight changes. But after I regenerated the docs nothing changed.

Maybe i should add some specific option to .. autosummary:: tag to specify custom template directory? (in conf.py directory is set right and sphinx see html templates as well)

UPD: source code: https://github.com/actionless/wooper/blob/master/docs.sh

Upvotes: 6

Views: 6033

Answers (2)

Reto Stauffer
Reto Stauffer

Reputation: 99

Edited: I've originally posted an answer to the wrong issue here. However, might help as well here.

One can 'overrule' the default templates by adding a custom file into the _templates folder. E.g., if you want to change the template for classes used when calling the autosummary directive create a custom class.rst file under this path:

  • _templates/autosummary/class.rst

Should be taken automatically without the need of specifying :template: explicitly.

Upvotes: 0

mzjn
mzjn

Reputation: 50947

It should work if you do the following:

  1. Ensure that the value of the templates_path configuration variable is set to ['_templates'] in conf py.
  2. Put the custom template in the _templates subdirectory.
  3. Use the :template: option:

    .. autosummary::
      :template: mytemplate.rst
    

Upvotes: 6

Related Questions