@@ -109,6 +109,7 @@ class PydocTopicsBuilder(TextBuilder):
109109 def init (self ) -> None :
110110 super ().init ()
111111 self .topics : dict [str , str ] = {}
112+ self .module_docs : dict [str , str ] = {}
112113
113114 def get_outdated_docs (self ) -> str :
114115 # Return a string describing what an update build will build.
@@ -130,6 +131,15 @@ def write_documents(self, _docnames: Set[str]) -> None:
130131 continue
131132 doc_labels .setdefault (docname , []).append ((topic_label , label_id ))
132133
134+ py_domain = env .domains ['py' ]
135+ for module_name , module_info in py_domain .data ['modules' ].items ():
136+ docname = module_info [0 ]
137+ if docname .startswith ('library/' ):
138+ doc_file = docname .replace ('library/' , '' )
139+ self .module_docs [module_name ] = (
140+ f"{ doc_file } #module-{ module_name } "
141+ )
142+
133143 for docname , label_ids in status_iterator (
134144 doc_labels .items (),
135145 "building topics... " ,
@@ -161,6 +171,22 @@ def finish(self) -> None:
161171"""
162172 self .outdir .joinpath ("topics.py" ).write_text (topics , encoding = "utf-8" )
163173
174+ module_docs_repr = "\n " .join (
175+ f" '{ module } ': '{ doc_file } ',"
176+ for module , doc_file in sorted (self .module_docs .items ())
177+ )
178+ module_docs = f"""\
179+ # Autogenerated by Sphinx on { asctime ()}
180+ # as part of the release process.
181+
182+ module_docs = {{
183+ { module_docs_repr }
184+ }}
185+ """
186+ self .outdir .joinpath ("module_docs.py" ).write_text (
187+ module_docs , encoding = "utf-8"
188+ )
189+
164190
165191def _display_labels (item : tuple [str , Sequence [tuple [str , str ]]]) -> str :
166192 _docname , label_ids = item
0 commit comments