Skip to content

Commit

Permalink
fix reading cached toctree data
Browse files Browse the repository at this point in the history
  • Loading branch information
schettino72 committed May 4, 2019
1 parent 59b809b commit b94f932
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Changes
=======


0.4.0 (*unreleased*)
====================

- fix reading cached toctree data


0.3.0 (*2019-04-22*)
====================

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <schetino72>',
Expand Down
9 changes: 8 additions & 1 deletion sphinx_press_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!!!

Expand Down

0 comments on commit b94f932

Please sign in to comment.