1 |
commit: a7f75d8b7bb207469b83d602600487f36346dc8b |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Feb 24 06:56:38 2020 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Feb 25 15:15:25 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/policy-guide.git/commit/?id=a7f75d8b |
7 |
|
8 |
Use #pg links in TOC |
9 |
|
10 |
Thanks for arzano for the solution. |
11 |
|
12 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
13 |
Closes: https://github.com/gentoo/policy-guide/pull/14 |
14 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
15 |
|
16 |
exts/policyident.py | 6 ++++++ |
17 |
1 file changed, 6 insertions(+) |
18 |
|
19 |
diff --git a/exts/policyident.py b/exts/policyident.py |
20 |
index 7ecc9f2..8cdc636 100644 |
21 |
--- a/exts/policyident.py |
22 |
+++ b/exts/policyident.py |
23 |
@@ -7,6 +7,7 @@ import collections |
24 |
from docutils import nodes |
25 |
|
26 |
from sphinx.domains import Index |
27 |
+from sphinx.environment.collectors.toctree import TocTreeCollector |
28 |
from sphinx.util import logging |
29 |
|
30 |
|
31 |
@@ -15,6 +16,8 @@ logger = logging.getLogger(__name__) |
32 |
Policy = collections.namedtuple('Policy', ('id', 'title', 'docname', |
33 |
'chapter')) |
34 |
|
35 |
+toccollector = TocTreeCollector() |
36 |
+ |
37 |
|
38 |
class PolicyIndex(Index): |
39 |
name = 'policy-index' |
40 |
@@ -90,6 +93,9 @@ def on_doctree_read(app, doctree): |
41 |
env.policy_index.append(Policy(pg_id, title, env.docname, |
42 |
chapter)) |
43 |
|
44 |
+ # update the table of conents to use the 'pgXXXX' ids |
45 |
+ toccollector.process_doc(app, doctree) |
46 |
+ |
47 |
|
48 |
def on_env_purge_doc(app, env, docname): |
49 |
if not hasattr(env, 'policy_index'): |