(
name: str,
rawtext: str,
text: str,
lineno: int,
inliner: docutils.parsers.rst.states.Inliner,
options: dict[str, Any] | None = None,
content: Sequence[str] = (),
)
| 575 | # |
| 576 | # TODO: Change to use `SphinxRole` once SphinxRole is fixed to support options. |
| 577 | def code_role( |
| 578 | name: str, |
| 579 | rawtext: str, |
| 580 | text: str, |
| 581 | lineno: int, |
| 582 | inliner: docutils.parsers.rst.states.Inliner, |
| 583 | options: dict[str, Any] | None = None, |
| 584 | content: Sequence[str] = (), |
| 585 | ) -> tuple[list[Node], list[system_message]]: |
| 586 | options = _normalize_options(options) |
| 587 | language = options.get('language', '') |
| 588 | classes = ['code'] |
| 589 | if language: |
| 590 | classes.append('highlight') |
| 591 | if 'classes' in options: |
| 592 | classes.extend(options['classes']) |
| 593 | |
| 594 | if language and language not in classes: |
| 595 | classes.append(language) |
| 596 | |
| 597 | node = nodes.literal(rawtext, text, classes=classes, language=language) |
| 598 | |
| 599 | return [node], [] |
| 600 | |
| 601 | |
| 602 | code_role.options = { # type: ignore[attr-defined] |
nothing calls this directly
no test coverage detected
searching dependent graphs…