From dcd6413c67a54f407e0e84577a1328d1f7730bd8 Mon Sep 17 00:00:00 2001 From: dgarcia360 Date: Wed, 20 Feb 2019 18:31:22 +0000 Subject: [PATCH 1/2] Added localtoc --- sphinxcontrib/fulltoc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sphinxcontrib/fulltoc.py b/sphinxcontrib/fulltoc.py index 9abb83e..f9ceae0 100644 --- a/sphinxcontrib/fulltoc.py +++ b/sphinxcontrib/fulltoc.py @@ -37,6 +37,9 @@ def html_page_context(app, pagename, templatename, context, doctree): context['toc'] = rendered_toc context['display_toc'] = True # force toctree to display + if "toc" in context: + # keeps original toc + context['localtoc'] = context['toc'] if "toctree" not in context: # json builder doesn't use toctree func, so nothing to replace return From 4568b236d18335f038513d1984ad12a6ad9d363a Mon Sep 17 00:00:00 2001 From: dgarcia360 Date: Thu, 21 Feb 2019 18:09:03 +0000 Subject: [PATCH 2/2] Fixed order --- sphinxcontrib/fulltoc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sphinxcontrib/fulltoc.py b/sphinxcontrib/fulltoc.py index f9ceae0..127bf81 100644 --- a/sphinxcontrib/fulltoc.py +++ b/sphinxcontrib/fulltoc.py @@ -33,13 +33,13 @@ def html_page_context(app, pagename, templatename, context, doctree): document structure, ignores the maxdepth argument, and uses only prune and collapse. """ + if "toc" in context: + # keeps original toc + context['localtoc'] = context['toc'] rendered_toc = get_rendered_toctree(app.builder, pagename) context['toc'] = rendered_toc context['display_toc'] = True # force toctree to display - if "toc" in context: - # keeps original toc - context['localtoc'] = context['toc'] if "toctree" not in context: # json builder doesn't use toctree func, so nothing to replace return