From b94f932169e5ffa07df34d05df90669f35ffa6c4 Mon Sep 17 00:00:00 2001 From: Eduardo Schettino Date: Sat, 4 May 2019 21:12:54 +0800 Subject: [PATCH] fix reading cached toctree data --- CHANGES | 6 ++++++ setup.py | 2 +- sphinx_press_theme/__init__.py | 9 ++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 471eee7..d55780d 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,12 @@ Changes ======= +0.4.0 (*unreleased*) +==================== + +- fix reading cached toctree data + + 0.3.0 (*2019-04-22*) ==================== diff --git a/setup.py b/setup.py index c7215e9..2296006 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='sphinx_press_theme', - version='0.3.0', + version='0.4.dev0', url='https://schettino72.github.io/sphinx_press_site/', license='MIT', author='Eduardo Naufel Schettino ', diff --git a/sphinx_press_theme/__init__.py b/sphinx_press_theme/__init__.py index a639b3a..cb35a0d 100644 --- a/sphinx_press_theme/__init__.py +++ b/sphinx_press_theme/__init__.py @@ -15,11 +15,18 @@ class SimpleTocTreeCollector(EnvironmentCollector): """ def enable(self, app): super().enable(app) - app.env.toc_dict = {} + # env is populated from cache, if not cache create/initalize attibute + if not hasattr(app.env, 'toc_dict'): + app.env.toc_dict = {} def clear_doc(self, app, env, docname): env.toc_dict.pop(docname, None) + def merge_other(self, app, env, docnames, other): + for docname in docnames: + env.toc_dict[docname] = other.toc_dict[docname] + + def process_doc(self, app, doctree): docname = app.env.docname # sphinx mutates this, ouch!!!