TOC in HtmlHelp format

3 views
Skip to first unread message

ChrisD

unread,
Feb 29, 2016, 9:58:54 AM2/29/16
to sphin...@googlegroups.com
I am producing HtmlHelp as one of my output formats. I have a couple of problems with the table of contents.

1) I want the TOC to appear in the contents pane (left pane) of the htmlhelp viewer, but I do not want a TOC to appear in the text pane (since it already appears in the contents pane). If I set the :hidden: option on the toctree directive, the TOC does not appear in the text pane, but the contents pane has only a single entry with the title, none of the normal TOC appears. If I do not set the :hidden: option, the TOC is fully populated in the contents pane, but of course the TOC now also appears as links in the text pane.

2) When I do not hide the TOC, the TOC in the contents pane does not respect the :maxdepth: option on the toctree directive. The contents pane TOC includes all levels of headings. The TOC in the text pane does respect the :maxdepth: option, but of course I want to get rid of the TOC in the text pane anyway

I was able to fix both problems by making a one line change to the htmlhelp builder.

In <PythonRoot>\Lib\site-packages\sphinx\builders\htmlhelp.py, just before the definition of the write_toc function, change the function call:

tocdoc = self.env.get_and_resolve_doctree(
self.config.master_doc, self, prune_toctrees=False)

to:

tocdoc = self.env.get_and_resolve_doctree(
self.config.master_doc, self, prune_toctrees=True, includehidden=True)

I don't know whether this should be considered a bug or not. In my use case, this gives the desired behavior. Also, it mimics what the default navigation side-bar does in html output. But the alabaster theme, at least, has the option sidebar_includehidden, which lets you either include or not include hidden entries in the navigation side-bar. There is a similar epub_tocscope config option that lets you control this for epub output. So there probably should be an option for this in the htmlhelp output, rather than making a fixed change.

Chris

Reply all
Reply to author
Forward
0 new messages