Classes
DirectiveAnalyzer
Analyzes directive usage across a site.
Extracts directives from markdown content, validates their…
DirectiveAnalyzer
Analyzes directive usage across a site.
Extracts directives from markdown content, validates their structure, and collects statistics for reporting.
Build-Integrated Validation: When analyze_from_context() is used with cached content, the analyzer avoids disk I/O entirely, reducing health check time from ~4.6s to <100ms.
Methods 1
analyze
Analyze all directives in site source files.
Uses cached content from build_co…
analyze
def analyze(self, site: Site, build_context: BuildContext | Any | None = None) -> dict[str, Any]
Analyze all directives in site source files.
Uses cached content from build_context when available to avoid redundant disk I/O (~4 seconds saved for 773-page sites).
Parameters 2
site |
Site |
Site instance to analyze |
build_context |
BuildContext | Any | None |
Optional BuildContext with cached page contents. When provided, uses cached content instead of reading from disk (build-integrated validation). |
Returns
Dictionary with directive statistics and issuesdict[str, Any]
—
Internal Methods 9
_is_inside_code_block
Check if a position in content is inside a markdown code block.
_is_inside_code_block
def _is_inside_code_block(self, content: str, position: int) -> bool
Check if a position in content is inside a markdown code block.
Parameters 2
content |
str |
Full markdown content |
position |
int |
Character position to check |
Returns
True if position is inside a code block (bool
— ..., ~~~...~~~, or indented 4+ spaces)
_check_code_block_nesting
Check for markdown code blocks that contain nested code blocks with the same fe…
_check_code_block_nesting
def _check_code_block_nesting(self, content: str, file_path: Path) -> list[dict[str, Any]]
Check for markdown code blocks that contain nested code blocks with the same fence length.
Parameters 2
content |
str |
|
file_path |
Path |
Returns
List of warning dictionarieslist[dict[str, Any]]
—
_is_inside_colon_directive
Check if a position is inside a colon directive (:::{name}).
_is_inside_colon_directive
def _is_inside_colon_directive(self, content: str, position: int) -> bool
Check if a position is inside a colon directive (:::{name}).
Parameters 2
content |
str |
|
position |
int |
Returns
bool
_is_inside_inline_code
Check if a position in content is inside inline code (single backticks).
_is_inside_inline_code
def _is_inside_inline_code(self, content: str, position: int) -> bool
Check if a position in content is inside inline code (single backticks).
Parameters 2
content |
str |
|
position |
int |
Returns
bool
_extract_directives
Extract all directive blocks from markdown content (colon fences only).
_extract_directives
def _extract_directives(self, content: str, file_path: Path) -> list[dict[str, Any]]
Extract all directive blocks from markdown content (colon fences only).
Parameters 2
content |
str |
Markdown content |
file_path |
Path |
Path to file (for error reporting) |
Returns
List of directive dictionaries with metadatalist[dict[str, Any]]
—
_validate_tabs_directive
Validate tabs directive content.
_validate_tabs_directive
def _validate_tabs_directive(self, directive: dict[str, Any]) -> None
Validate tabs directive content.
Parameters 1
directive |
dict[str, Any] |
_validate_code_tabs_directive
Validate code-tabs directive content.
_validate_code_tabs_directive
def _validate_code_tabs_directive(self, directive: dict[str, Any]) -> None
Validate code-tabs directive content.
Parameters 1
directive |
dict[str, Any] |
_validate_dropdown_directive
Validate dropdown directive content.
_validate_dropdown_directive
def _validate_dropdown_directive(self, directive: dict[str, Any]) -> None
Validate dropdown directive content.
Parameters 1
directive |
dict[str, Any] |
_check_fence_nesting
Check for fence nesting issues.
_check_fence_nesting
def _check_fence_nesting(self, directive: dict[str, Any]) -> None
Check for fence nesting issues.
Parameters 1
directive |
dict[str, Any] |