summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-02-24 07:56:38 +0100
committerMichał Górny <mgorny@gentoo.org>2020-02-25 16:15:25 +0100
commita7f75d8b7bb207469b83d602600487f36346dc8b (patch)
tree583ebe04139f2eb0572fb638c277d98d733141b3
parentCopy singlehtml into html directory (diff)
downloadpolicy-guide-a7f75d8b7bb207469b83d602600487f36346dc8b.tar.gz
policy-guide-a7f75d8b7bb207469b83d602600487f36346dc8b.tar.bz2
policy-guide-a7f75d8b7bb207469b83d602600487f36346dc8b.zip
Use #pg links in TOC
Thanks for arzano for the solution. Signed-off-by: Michał Górny <mgorny@gentoo.org> Closes: https://github.com/gentoo/policy-guide/pull/14 Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--exts/policyident.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/exts/policyident.py b/exts/policyident.py
index 7ecc9f2..8cdc636 100644
--- a/exts/policyident.py
+++ b/exts/policyident.py
@@ -7,6 +7,7 @@ import collections
from docutils import nodes
from sphinx.domains import Index
+from sphinx.environment.collectors.toctree import TocTreeCollector
from sphinx.util import logging
@@ -15,6 +16,8 @@ logger = logging.getLogger(__name__)
Policy = collections.namedtuple('Policy', ('id', 'title', 'docname',
'chapter'))
+toccollector = TocTreeCollector()
+
class PolicyIndex(Index):
name = 'policy-index'
@@ -90,6 +93,9 @@ def on_doctree_read(app, doctree):
env.policy_index.append(Policy(pg_id, title, env.docname,
chapter))
+ # update the table of conents to use the 'pgXXXX' ids
+ toccollector.process_doc(app, doctree)
+
def on_env_purge_doc(app, env, docname):
if not hasattr(env, 'policy_index'):