Classes
RenderResult
dataclass
Result of rendering a shortcode/directive.
RenderResult
dataclass Result of rendering a shortcode/directive.
Attributes
| Name | Type | Description |
|---|---|---|
input_content |
str |
|
html |
str |
|
success |
bool |
|
directive_name |
str | None |
|
errors |
list[str] |
|
warnings |
list[str] |
|
parse_time_ms |
float |
|
render_time_ms |
float |
Methods 1
format_summary
Format a summary of the render result.
format_summary
def format_summary(self) -> str
Format a summary of the render result.
Returns
str
ValidationResult
dataclass
Result of syntax validation.
ValidationResult
dataclass Result of syntax validation.
Attributes
| Name | Type | Description |
|---|---|---|
content |
str |
|
valid |
bool |
|
directive_name |
str | None |
|
errors |
list[str] |
|
suggestions |
list[str] |
ShortcodeSandbox
Sandbox for testing shortcodes/directives in isolation.
Provides:
- Isolated rendering without sit…
ShortcodeSandbox
Sandbox for testing shortcodes/directives in isolation.
Provides:
- Isolated rendering without site context
- Syntax validation before render
- Error detection and suggestions
- Batch testing from files
- Interactive REPL mode
DebugToolAttributes
| Name | Type | Description |
|---|---|---|
name |
str |
|
description |
str |
Methods 7
run
Run sandbox testing.
run
def run(self, content: str | None = None, file_path: Path | None = None, validate_only: bool = False, **kwargs: Any) -> DebugReport
Run sandbox testing.
Parameters 3
content |
str | None |
Markdown content to test |
file_path |
Path | None |
Path to file containing content |
validate_only |
bool |
Only validate syntax, don't render **kwargs: Additional arguments |
Returns
DebugReport with findingsDebugReport
—
analyze
Perform analysis and return report.
This is the abstract method required by De…
analyze
def analyze(self) -> DebugReport
Perform analysis and return report.
This is the abstract method required by DebugTool. For parameterized analysis, use run() instead.
Returns
DebugReport
validate
Validate directive/shortcode syntax.
validate
def validate(self, content: str) -> ValidationResult
Validate directive/shortcode syntax.
Parameters 1
content |
str |
Markdown content with directive |
Returns
ValidationResult with errors and suggestionsValidationResult
—
render
Render directive/shortcode content to HTML.
render
def render(self, content: str) -> RenderResult
Render directive/shortcode content to HTML.
Parameters 1
content |
str |
Markdown content with directive |
Returns
RenderResult with HTML and timing infoRenderResult
—
batch_test
Test multiple shortcodes in batch.
batch_test
def batch_test(self, test_cases: list[dict[str, Any]]) -> list[RenderResult]
Test multiple shortcodes in batch.
Parameters 1
test_cases |
list[dict[str, Any]] |
List of test cases with 'content' and optional 'expected' |
Returns
List of RenderResultslist[RenderResult]
—
list_directives
List all available directives with descriptions.
list_directives
def list_directives(self) -> list[dict[str, str]]
List all available directives with descriptions.
Returns
List of directive info dictslist[dict[str, str]]
—
get_directive_help
Get detailed help for a specific directive.
get_directive_help
def get_directive_help(self, name: str) -> str | None
Get detailed help for a specific directive.
Parameters 1
name |
str |
Directive name |
Returns
Help text or None if not foundstr | None
—
Internal Methods 6
__init__
Initialize sandbox.
__init__
def __init__(self, site: Any = None, mock_context: dict[str, Any] | None = None) -> None
Initialize sandbox.
Parameters 2
site |
Any |
Optional site instance for full context (creates mock if None) |
mock_context |
dict[str, Any] | None |
Optional mock context for variable substitution |
_create_default_context
Create default mock context for rendering.
_create_default_context
def _create_default_context(self) -> dict[str, Any]
Create default mock context for rendering.
Returns
dict[str, Any]
_get_known_directives
Get set of known directive names.
_get_known_directives
def _get_known_directives(self) -> frozenset[str]
Get set of known directive names.
Returns
frozenset[str]
_get_parser
Get or create markdown parser.
_get_parser
def _get_parser(self) -> Any
Get or create markdown parser.
Returns
Any
_find_similar_directives
Find directives with similar names (typo detection).
_find_similar_directives
def _find_similar_directives(self, name: str, known: frozenset[str], max_distance: int = 2) -> list[str]
Find directives with similar names (typo detection).
Parameters 3
name |
str |
|
known |
frozenset[str] |
|
max_distance |
int |
Returns
list[str]
_levenshtein_distance
staticmethod
Calculate Levenshtein distance between two strings.
_levenshtein_distance
staticmethod def _levenshtein_distance(s1: str, s2: str) -> int
Calculate Levenshtein distance between two strings.
Parameters 2
s1 |
str |
|
s2 |
str |
Returns
int