Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional toctree in Sphinx

I want to do multiple versions of a documentation, which differ in the sections that are included. To achieve this I would usually use either the only directive or the ifconfig extension. However, I cannot use any of those in combination with the toctree directive.

What I basically want is something like this:

.. toctree::
   :maxdepth: 2

   intro
   strings
   datatypes
   numeric
   .. only:: university
      complex

Is there a way to do that?

like image 459
Michael Avatar asked Feb 21 '13 12:02

Michael


People also ask

What is Toctree Sphinx?

.. toctree is a Sphinx-defined directive in which you explicitly list documents whose TOCs will be listed out.

What is Genindex?

GEN has partnered with American City Business Journals to create the GEN Index, a regional ranking of equity-centered workplaces.

What is a directive Sphinx?

A directive (ref) is a generic block of explicit markup. Along with roles, it is one of the extension mechanisms of reST, and Sphinx makes heavy use of it. Docutils supports the following directives: Admonitions: attention, caution, danger, error, hint, important, note, tip, warning and the generic admonition.


1 Answers

A very simple solution is to maintain two separate index files under different names. You can specify which index file to use by default in conf.py and override it for a special build using -D master_doc=alternate-index on the sphinx-build command line.

like image 112
David Weber Avatar answered Oct 12 '22 10:10

David Weber