(self)
| 490 | } |
| 491 | |
| 492 | def run(self) -> list[Node]: |
| 493 | # Copy old option names to new ones |
| 494 | # xref RemovedInSphinx90Warning |
| 495 | # # deprecate noindex in Sphinx 9.0 |
| 496 | if 'no-index' not in self.options and 'noindex' in self.options: |
| 497 | self.options['no-index'] = self.options['noindex'] |
| 498 | |
| 499 | domain = self.env.domains.python_domain |
| 500 | |
| 501 | modname = self.arguments[0].strip() |
| 502 | no_index = 'no-index' in self.options |
| 503 | self.env.ref_context['py:module'] = modname |
| 504 | |
| 505 | content_nodes = self.parse_content_to_nodes(allow_section_headings=True) |
| 506 | |
| 507 | ret: list[Node] = [] |
| 508 | if not no_index: |
| 509 | # note module to the domain |
| 510 | node_id = make_id(self.env, self.state.document, 'module', modname) |
| 511 | target = nodes.target('', '', ids=[node_id], ismod=True) |
| 512 | self.set_source_info(target) |
| 513 | self.state.document.note_explicit_target(target) |
| 514 | |
| 515 | domain.note_module( |
| 516 | name=modname, |
| 517 | node_id=node_id, |
| 518 | synopsis=self.options.get('synopsis', ''), |
| 519 | platform=self.options.get('platform', ''), |
| 520 | deprecated='deprecated' in self.options, |
| 521 | ) |
| 522 | domain.note_object(modname, 'module', node_id, location=target) |
| 523 | |
| 524 | # the platform and synopsis aren't printed; in fact, they are only |
| 525 | # used in the modindex currently |
| 526 | |
| 527 | if 'no-index-entry' not in self.options: |
| 528 | index_text = f'module; {modname}' |
| 529 | inode = addnodes.index( |
| 530 | entries=[('pair', index_text, node_id, '', None)] |
| 531 | ) |
| 532 | # The node order is: index node first, then target node. |
| 533 | ret.append(inode) |
| 534 | ret.append(target) |
| 535 | ret.extend(content_nodes) |
| 536 | return ret |
| 537 | |
| 538 | |
| 539 | class PyCurrentModule(SphinxDirective): |
no test coverage detected