Skip to content
Permalink
Browse files

do not overwrite toctree if cannot remove TocTreeCollector

  • Loading branch information...
sdpython committed Aug 31, 2017
1 parent 24b9b6a commit 8f5288615dfb2d2fc12585703b360a029d82009f
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/pyquickhelper/sphinxext/sphinx_toctree_extension.py
@@ -243,13 +243,15 @@ def setup(app):
"""
Setup for ``toctree`` and ``toctree2`` (sphinx).
"""
app.add_directive('toctree', CustomTocTree)
app.add_directive('toctree2', CustomTocTree)
directives.register_directive('toctree', CustomTocTree)
directives.register_directive('toctree2', CustomTocTree)

# We connect a new collector to the app.
# It disables the previous TocTreeCollector.
app.add_env_collector(CustomTocTreeCollector)
if hasattr(app, 'disconnect_env_collector'):
# If we can disable the previous TocTreeCollector,
# we connect a new collector to the app,
# it disables the previous one.
directives.register_directive('toctree', CustomTocTree)
app.add_directive('toctree', CustomTocTree)
app.add_env_collector(CustomTocTreeCollector)

return {'version': sphinx.__display_version__, 'parallel_read_safe': True}

0 comments on commit 8f52886

Please sign in to comment.
You can’t perform that action at this time.