python-sphinxautodoc

How to exclude an autodoc object from the toctree?


We are using the autoclass directive a few times in a file, but it doesn't make sense for these to show up in the TOC tree.

However, there are other files where it does make sense for autodoc objects to show up in the TOC tree.

Is there a way to exclude autodoc objects from toctree on a per-file or per-autodoc basis?


Solution

  • Ok, so it seems the :no-index: option does this. Couldn't easily figure out its purpose from the docs.

    .. autoclass:: foo.bar.MyClass
       :no-index:
    

    Note if using Sphinx < 7.2, it's :noindex: (which is still supported at Sphinx 7.2)