codeblock#
Build the example as a highlighted code block in which each key is an anchor.
- create_literal_block(settings: Sequence[Entry], fmt: str, rawsource: str) Element[source]#
Build the example as a code block in which each key is an anchor.
The anchor is what sphinx-tippy attaches the tooltip to; it refers to itself so that the key doubles as a permalink to the setting.
The example is highlighted as a whole, so that the lexer sees the full context, and the tokens of each key are then wrapped in its anchor.
Sphinx highlights a literal block again when its
rawsourceequals its text, which would drop the inline nodes built here. Arawsourcethat differs from the text, such as the directive name, marks the block as a parsed literal instead. The surrounding containers give the block the class names that themes and sphinx-copybutton expect from a regular code block.