6

I have some Sphinx docs like so:

Browse the code-based documentation here:

.. autosummary::
   :toctree: _autosummary
   :template: custom-module-template.rst
   :recursive:

   foo

Where foo is a module which has foo.bar, foo.bar.a, foo.baz, etc. Is there a way to exclude foo.baz?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Dion Moult
  • 109
  • 4
  • 1
    I found this to be a pain as well. My experience with Sphinx, so far, has been that most feature are useless, and the most useful features... are not there. – rrrrrrrrrrrrrrrr Aug 24 '22 at 07:16

1 Answers1

2

On the custom-module-template.rst template, at the part were it iterates through the submodules you can add an if statement to check the name of the module, like so:

{# rest of the module template #}

{% block modules %}
{% if modules %}
.. rubric:: Modules

.. autosummary::
   :toctree:
   :template: custom-module-template.rst
   :recursive:
   {% for item in modules %}
   {% if not item.endswith('.baz') %}
       {{ item }}
   {%- endif %}
   {%- endfor %}
{% endif %}
{% endblock %}

I'm not sure this is the best solution, but this works for me.

Hint for the custom-module-template.rst

Anina7
  • 63
  • 5