Closed eli-collins closed 7 years ago
If it helps this get merged you can see in the sphinx-doc/sphinx repository the code at https://github.com/sphinx-doc/sphinx/blob/70600e99818ab517585035f46d9146133a68f91a/sphinx/builders/html.py#L773-L840 is what is executed for the html builder, which contains the lines
ctx['toctree'] = lambda **kw: self._get_local_toctree(pagename, **kw)
self.add_sidebars(pagename, ctx)
These are responsible for triggering the toc generation for the HTML pages, however for the JSON builder the handle_page method is overridden with one from the SerializingHTMLBuilder class https://github.com/sphinx-doc/sphinx/blob/70600e99818ab517585035f46d9146133a68f91a/sphinx/builders/html.py#L1124-L1146, which does not have toctree. So the fix will work for all builders based on the SerializingHTMLBuilder class.
I think this change fixes issue #10 - the json builder doesn't define a toctree function, and omitting the replacement if it wasn't already set seems to build correctly.