Classes
FixSafety
Safety level for auto-fixes.
FixSafety
Safety level for auto-fixes.
Enum
FixAction
dataclass
Represents a single fix action.
FixAction
dataclass Represents a single fix action.
Attributes
| Name | Type | Description |
|---|---|---|
description |
str |
Human-readable description of what will be fixed |
file_path |
Path |
Path to file that needs fixing |
line_number |
int | None |
Line number (if applicable) |
fix_type |
str |
Type of fix (e.g., "directive_fence", "link_update") |
safety |
FixSafety |
Safety level (SAFE, CONFIRM, UNSAFE) |
apply |
Any |
Function to apply the fix (returns True if successful) |
check_result |
CheckResult | None |
Original CheckResult that triggered this fix |
Methods 1
can_apply
Check if this fix can be applied automatically.
can_apply
def can_apply(self) -> bool
Check if this fix can be applied automatically.
Returns
bool
AutoFixer
Auto-fix framework for health check issues.
Analyzes health check reports and suggests fixes for c…
AutoFixer
Auto-fix framework for health check issues.
Analyzes health check reports and suggests fixes for common errors. Provides safe fixes that can be applied automatically.
Methods 3
suggest_fixes
Analyze report and suggest fixes for all issues.
suggest_fixes
def suggest_fixes(self) -> list[FixAction]
Analyze report and suggest fixes for all issues.
Returns
List of FixAction objects representing possible fixeslist[FixAction]
—
apply_fixes
Apply fixes to files.
apply_fixes
def apply_fixes(self, fixes: list[FixAction] | None = None) -> dict[str, Any]
Apply fixes to files.
Parameters 1
fixes |
list[FixAction] | None |
List of fixes to apply (if None, uses self.fixes) |
Returns
Dictionary with results: {"applied": N, "failed": M, "skipped": K}dict[str, Any]
—
apply_safe_fixes
Apply only safe fixes automatically.
apply_safe_fixes
def apply_safe_fixes(self) -> dict[str, Any]
Apply only safe fixes automatically.
Returns
Dictionary with resultsdict[str, Any]
—
Internal Methods 9
__init__
Initialize auto-fixer.
__init__
def __init__(self, report: HealthReport, site_root: Path)
Initialize auto-fixer.
Parameters 2
report |
HealthReport |
Health report to analyze for fixes |
site_root |
Path |
Root path of the site (required, must be absolute) |
_suggest_directive_fixes
Suggest fixes for directive validation errors and warnings.
_suggest_directive_fixes
def _suggest_directive_fixes(self, validator_report: Any) -> list[FixAction]
Suggest fixes for directive validation errors and warnings.
Parameters 1
validator_report |
Any |
Returns
list[FixAction]
_create_file_fix
Create a fix function that fixes all directives in a file.
This ensures we fix…
_create_file_fix
def _create_file_fix(self, file_path: Path, line_numbers: list[int]) -> Any
Create a fix function that fixes all directives in a file.
This ensures we fix the entire hierarchy in one pass, including all nested children and grandchildren.
Parameters 2
file_path |
Path |
|
line_numbers |
list[int] |
Returns
Any
_is_descendant
Check if directive is a descendant of ancestor.
_is_descendant
def _is_descendant(self, directive: dict[str, Any], ancestor: dict[str, Any], all_directives: list[dict[str, Any]]) -> bool
Check if directive is a descendant of ancestor.
Parameters 3
directive |
dict[str, Any] |
|
ancestor |
dict[str, Any] |
|
all_directives |
list[dict[str, Any]] |
Returns
bool
_get_depth
Get nesting depth of directive (0 = root, 1 = child, etc.).
_get_depth
def _get_depth(self, directive: dict[str, Any], all_directives: list[dict[str, Any]]) -> int
Get nesting depth of directive (0 = root, 1 = child, etc.).
Parameters 2
directive |
dict[str, Any] |
|
all_directives |
list[dict[str, Any]] |
Returns
int
_create_fence_fix
Create a fix function for fence nesting issues.
Implements hierarchical fix: i…
_create_fence_fix
def _create_fence_fix(self, file_path: Path, line_number: int) -> Any
Create a fix function for fence nesting issues.
Implements hierarchical fix: increments all parents +1 based on deepest nested directive. Example: tab-set (grandparent) > tab-item (parent) > note (child, baseline 3) Result: grandparent=5, parent=4, child=3
The fix analyzes the entire file to understand directive hierarchy and fixes from bottom-up (deepest first, then parents).
Parameters 2
file_path |
Path |
|
line_number |
int |
Returns
Any
_parse_directive_hierarchy
Parse directive hierarchy from file lines.
Returns list of directives with par…
_parse_directive_hierarchy
def _parse_directive_hierarchy(self, lines: list[str]) -> list[dict[str, Any]]
Parse directive hierarchy from file lines.
Returns list of directives with parent relationships.
Parameters 1
lines |
list[str] |
Returns
list[dict[str, Any]]
_apply_single_fix
Apply fix to a single directive (increase fence depth).
_apply_single_fix
def _apply_single_fix(self, lines: list[str], directive: dict[str, Any]) -> None
Apply fix to a single directive (increase fence depth).
Parameters 2
lines |
list[str] |
|
directive |
dict[str, Any] |
_suggest_link_fixes
Suggest fixes for link validation errors.
_suggest_link_fixes
def _suggest_link_fixes(self, validator_report: Any) -> list[FixAction]
Suggest fixes for link validation errors.
Parameters 1
validator_report |
Any |
Returns
list[FixAction]