2

I'm trying to use the breathe plugin which is super limited out of the box: https://github.com/michaeljones/breathe

It has this directive that generates a big dump of all classes/interfaces/etc and just puts them on the same page: doxygenindex.

While it generates an anchor on the page for every class/interface/etc it has no features for generating a table of contents.

Does sphinx itself have a way generating a toc from every anchor on a page? I think that would be enough for me. Having it all on one page is nice for ctrl+f, but having a toc as well would improve discoverability for users unfamiliar with the codebase.

Edit

There is a very old GitHub issue for this, maybe this feature has already been added? Or if it's still not possible maybe it is with some plugin: https://github.com/sphinx-doc/sphinx/issues/2954

Edit

Per suggestion using .. contents:: like this does not appear to do anything. I see no toc generated for the page, but maybe I'm not understanding how to use it?

Some page
---------

.. contents:: Table of contents
    :local:
    :backlinks: entry
    :depth: 2

.. doxygenindex::
   :project: myproject
halfer
  • 19,824
  • 17
  • 99
  • 186
red888
  • 27,709
  • 55
  • 204
  • 392

1 Answers1

1

Does the contents directive do what you want?

The "contents" directive generates a table of contents (TOC) in a topic. Topics, and therefore tables of contents, may occur anywhere a section or transition may occur. Body elements and topics may not contain tables of contents.

Here's the directive in its simplest form:

.. contents::

Try the below sample online.

=====
Title
=====

.. contents:: Table of contents
    :local:
    :backlinks: entry
    :depth: 2


Heading
-------

Paragraph

Subheading
^^^^^^^^^^

Paragraph

Subsubheading
#############

Paragraph

Demo

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
  • I'm probably not understanding your suggestion, see my last edit. I tried adding `contents` to the page where I'm calling `doxygenindex`. No toc is generated for the page in the nav bar though, it looks the same. – red888 Feb 03 '22 at 15:16
  • 1
    The assumption is that you have headings which automatically become the anchors. – Steve Piercy Feb 04 '22 at 08:13