(self, _docnames: Set[str])
| 116 | return "all pydoc topics" |
| 117 | |
| 118 | def write_documents(self, _docnames: Set[str]) -> None: |
| 119 | env = self.env |
| 120 | |
| 121 | labels: dict[str, tuple[str, str, str]] |
| 122 | labels = env.domains.standard_domain.labels |
| 123 | |
| 124 | # docname -> list of (topic_label, label_id) pairs |
| 125 | doc_labels: dict[str, list[tuple[str, str]]] = {} |
| 126 | for topic_label in _PYDOC_TOPIC_LABELS: |
| 127 | try: |
| 128 | docname, label_id, _section_name = labels[topic_label] |
| 129 | except KeyError: |
| 130 | logger.warning("label %r not in documentation", topic_label) |
| 131 | continue |
| 132 | doc_labels.setdefault(docname, []).append((topic_label, label_id)) |
| 133 | |
| 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 | |
| 143 | for docname, label_ids in status_iterator( |
| 144 | doc_labels.items(), |
| 145 | "building topics... ", |
| 146 | length=len(doc_labels), |
| 147 | stringify_func=_display_labels, |
| 148 | ): |
| 149 | doctree = env.get_and_resolve_doctree(docname, builder=self) |
| 150 | doc_ids = doctree.ids |
| 151 | for topic_label, label_id in label_ids: |
| 152 | document = new_document("<section node>") |
| 153 | document.append(doc_ids[label_id]) |
| 154 | visitor = TextTranslator(document, builder=self) |
| 155 | document.walkabout(visitor) |
| 156 | body = "\n".join(map(str.rstrip, visitor.body.splitlines())) |
| 157 | self.topics[topic_label] = body + "\n" |
| 158 | |
| 159 | def finish(self) -> None: |
| 160 | topics_repr = "\n".join( |
nothing calls this directly
no test coverage detected