Classes
APIDocEnhancer
Post-processes API documentation HTML to inject badges and visual enhancements.
This enhancer tran…
APIDocEnhancer
Post-processes API documentation HTML to inject badges and visual enhancements.
This enhancer transforms marker syntax (e.g., @async, @property) into styled HTML badges. It operates on already-parsed HTML, avoiding Mistune's escaping issues.
Markers are placed in templates after method names and get replaced with proper HTML during post-processing.
Methods 3
should_enhance
Check if a page should be enhanced based on its type.
should_enhance
def should_enhance(self, page_type: str | None) -> bool
Check if a page should be enhanced based on its type.
Parameters 1
page_type |
str | None |
The page type from frontmatter |
Returns
True if the page should be enhancedbool
—
enhance
Enhance HTML with API documentation badges.
This method applies all badge tran…
enhance
def enhance(self, html: str, page_type: str | None = None) -> str
Enhance HTML with API documentation badges.
This method applies all badge transformations to the HTML if the page type indicates it's an API documentation page.
Parameters 2
html |
str |
Parsed HTML from markdown rendering |
page_type |
str | None |
Page type from frontmatter (optional) |
Returns
Enhanced HTML with badges injected (or unchanged HTML if not applicable)str
—
strip_markers
Remove all marker syntax from HTML without adding badges.
Useful for pages tha…
strip_markers
def strip_markers(self, html: str) -> str
Remove all marker syntax from HTML without adding badges.
Useful for pages that want to show API documentation without badges, or for debugging purposes.
Parameters 1
html |
str |
HTML with marker syntax |
Returns
HTML with markers removedstr
—
Internal Methods 1
__init__
Initialize the enhancer.
__init__
def __init__(self) -> None
Initialize the enhancer.
Functions
get_enhancer
Get or create the singleton APIDocEnhancer instance.
get_enhancer
def get_enhancer() -> APIDocEnhancer
Get or create the singleton APIDocEnhancer instance.
Returns
Shared APIDocEnhancer instanceAPIDocEnhancer
—