]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Generate tables of statements in doctree-read phase
authorPetr Špaček <pspacek@isc.org>
Mon, 4 Jul 2022 09:30:33 +0000 (11:30 +0200)
committerPetr Špaček <pspacek@isc.org>
Mon, 4 Jul 2022 10:39:43 +0000 (12:39 +0200)
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.

doc/arm/_ext/iscconf.py

index 53eb2f946ae888f10215c30ff550b6f5b164cc63..ebbfa28fe4fca3f6514300778bac45821bbede51 100644 (file)
@@ -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",