From 6ac047cfaa670a77b6f039e1c30c2b1f9af2d0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pa=C4=8Dek?= Date: Mon, 4 Jul 2022 11:30:33 +0200 Subject: [PATCH] Generate tables of statements in doctree-read phase This change allows us to generate "unresolved" references and let Sphinx deal with dereferencing them in later stages. It is not useful by itself but it serves as preparation for the next commit. (cherry picked from commit b109c8680594f0796ec2726ab9de5ef53b2a9bd1) --- doc/arm/_ext/iscconf.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/arm/_ext/iscconf.py b/doc/arm/_ext/iscconf.py index 53eb2f946a..ebbfa28fe4 100644 --- a/doc/arm/_ext/iscconf.py +++ b/doc/arm/_ext/iscconf.py @@ -429,7 +429,7 @@ def domain_factory(domainname, domainlabel, todolist, grammar): ) @classmethod - def process_statementlist_nodes(cls, app, doctree, fromdocname): + def process_statementlist_nodes(cls, app, doctree): """ Replace todolist objects (placed into document using .. statementlist::) with automatically generated table @@ -464,7 +464,7 @@ def domain_factory(domainname, domainlabel, todolist, grammar): ) ) ), - iscconf.list_all(fromdocname), + iscconf.list_all(), ), key=lambda x: x["fullname"], ) @@ -481,24 +481,24 @@ def domain_factory(domainname, domainlabel, todolist, grammar): gen_replacement_table(acceptable_blocks, acceptable_tags) ) - def list_all(self, fromdocname): + def list_all(self): for statement in self.data["statements"].values(): + sig = statement["signature"] block_names = set( - path[-1] - for path in self.statement_blocks.get(statement["signature"], []) + path[-1] for path in self.statement_blocks.get(sig, []) ) tags_txt = ", ".join(statement["tags"]) refpara = nodes.inline() - refpara += self.resolve_xref( - self.env, - fromdocname, - self.env.app.builder, - None, - statement["signature"], - None, - nodes.Text(statement["signature"]), + refnode = addnodes.pending_xref( + sig, + reftype="statement", + refdomain=domainname, + reftarget=sig, + refwarn=True, ) + refnode += nodes.Text(sig) + refpara += refnode copy = statement.copy() copy["block_names"] = block_names @@ -574,7 +574,7 @@ def setup(app, domainname, confname, docutilsplaceholder, grammar): Conf = domain_factory(domainname, confname, docutilsplaceholder, grammar) app.add_domain(Conf) - app.connect("doctree-resolved", Conf.process_statementlist_nodes) + app.connect("doctree-read", Conf.process_statementlist_nodes) return { "version": "0.1",