1

I am trying to document some of my python codes. I am using the sphinx_rtd_theme. I have added a simple table of content by doing:

Welcome to my documentation!
===========================================

.. toctree::
   :maxdepth: 5
   :caption: Introduction:


   chapter1
   chapter2

.. toctree::
   :maxdepth: 5
   :caption: Equations:


   chapter3
   chapter4

After running make html command, here is how it looks:

enter image description here

Now I want to collapse the CHAPTER 1 and CHAPTER 2 under INTRODUCTION in a way that if I click on the plus sign next to the INTRODUCTION, the CHAPTER 1 and CHAPTER 2 appears. I want to do the same thing for the CHAPTER 3 and CHAPTER 4 to be collapsed and expanded under the EQUATIONS. I tried many things. I added this line:

html_theme_options = {'collapse_navigation':True} 

to the config.py file but I was not able to get it done. What is the solution to add this capability to the html file?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Leo
  • 479
  • 2
  • 6
  • 16
  • I do not see a plus sign next to the captions. Do you insist on using captions, or are you open to suggestions that do not use captions? – Steve Piercy Jun 04 '21 at 08:31
  • I just want to have a plus sign for example on the left of the INTRODUCTION that when I click on it CHAPTER 1 and CHAPTER 2 are shown and by clicking again on it they get collapsed under the INTRODUCTION. Any help is appreciated! – Leo Jun 04 '21 at 16:54
  • Something like this? https://training.plone.org/5/index.html If so, here's the structure of the source documentation: https://github.com/plone/training It's a folder with nested folders, and each folder has an index.rst which contains the `toctree` directive that generates the sidebar navigation. – Steve Piercy Jun 05 '21 at 08:08
  • Yes the example you provided is exactly what I want to do . I looked at the github page you suggested and the format of their rst files seems to be same mine as I showed above but I am not sure why it does not work for me. – Leo Jun 05 '21 at 16:27
  • You expect a caption to function like a page or section heading. They are not the same. Additionally their project has multiple subdirectories in the parent directory, each of which corresponds to an expandable navigation element, whereas it appears that yours has only one directory. – Steve Piercy Jun 06 '21 at 06:13

0 Answers0