9

In Sphinx docs, I define a reference document like this:

Reference
=========

.. toctree::

   reference_api
   reference_cli
   reference_client
   reference_downloads
   reference_options
   reference_stats
   reference_utils

The reference_api document looks like this:

API module
==========

.. automodule:: aria2p.api
    :no-members:

API
---

.. autoclass:: aria2p.api.API
    :members:

Now I get this list in the sidebar:

Reference
  API module
    API

I would like to also add all the API methods that were documented through :members: in the sidebar, something like:

Reference
  API module
    API
      __init__
      add_magnet
      add_metalink
      ...

Is this possible? Should I change how Sphinx writes modules functions and classes' methods to add anchors to them, so the sidebar can display them?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
pawamoy
  • 3,382
  • 1
  • 26
  • 44
  • 1
    Quick answer: it's not possible. And it's not going to happen soon unless someone sends a PR (see https://github.com/sphinx-doc/sphinx/issues/6316). I wrote an "autodoc"-like plugin for mkdocs called mkdocstrings that adds the auto-documented objects to the TOC: https://github.com/pawamoy/mkdocstrings if you want to take a look! – pawamoy Feb 26 '20 at 12:50

1 Answers1

2

This is now possible with Sphinx 5.2.0. See https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-toc_object_entries_show_parents

toc_object_entries_show_parents
A string that determines how domain objects (e.g. functions, classes, attributes, etc.) are displayed in their table of contents entry. Use domain to allow the domain to determine the appropriate number of parents to show. For example, the Python domain would show Class.method() and function(), leaving out the module. level of parents. This is the default setting. Use hide to only show the name of the element without any parents (i.e. method()). Use all to show the fully-qualified name for the object (i.e. module.Class.method()), displaying all parents.

pawamoy
  • 3,382
  • 1
  • 26
  • 44