Module

directives.builtins.admonition

Admonition directive for callout boxes.

Supports standard admonition types:

  • note: General information
  • warning: Potential issues
  • tip: Helpful suggestions
  • danger: Serious risk
  • error: Error conditions
  • info: Informational callout
  • example: Example content
  • success: Success messages
  • caution: Proceed carefully (maps to warning CSS)
  • seealso: Related information

Example:

Optional Title

This is the note content.

Thread Safety:

Stateless handler. Safe for concurrent use across threads.

Classes

AdmonitionDirective 7 ▼
Handler for admonition directives. Renders callout boxes for notes, warnings, tips, etc. Thread S…

Handler for admonition directives.

Renders callout boxes for notes, warnings, tips, etc.

Thread Safety:

Stateless handler. Safe for concurrent use.

Attributes

Name Type Description
names ClassVar[tuple[str, ...]] —
token_type ClassVar[str] —
contract ClassVar[DirectiveContract | None] —
options_class ClassVar[type[AdmonitionOptions]] —
preserves_raw_content ClassVar[bool] —

Methods

parse 6 Directive[AdmonitionOpti… ▼
Build admonition AST node.
def parse(self, name: str, title: str | None, options: AdmonitionOptions, content: str, children: Sequence[Block], location: SourceLocation) -> Directive[AdmonitionOptions]
Parameters
Name Type Description
name —

Admonition type (note, warning, etc.)

title —

Custom title (uses type name if None)

options —

Typed admonition options

content —

Raw content (unused, prefer children)

children —

Parsed child blocks

location —

Source location

Returns
Directive[AdmonitionOptions] Directive node for AST
render 3 ▼
Render admonition to HTML.
def render(self, node: Directive[AdmonitionOptions], rendered_children: str, sb: StringBuilder) -> None
Parameters
Name Type Description
node —

Directive AST node

rendered_children —

Pre-rendered child content

sb —

StringBuilder for output

Functions

_render_admonition_icon 1 str ▼
Render admonition icon using icon resolver.
def _render_admonition_icon(icon_name: str) -> str
Parameters
Name Type Description
icon_name str

Name of the icon to render

Returns
str