feat: add semantic document validator for x-markitect extensions
Implements semantic validation to complement existing structural validation:
Phase 1 & 2 Complete:
- SemanticValidator: Main validator orchestrating sub-validators
- SectionValidator: Enforces section classifications (required, recommended,
optional, discouraged, improper) from x-markitect-sections
- ContentValidator: Validates content patterns, forbidden patterns, and
quality metrics (word counts, sentence counts) from x-markitect-content-control
Features:
- Pattern matching with regex for required/forbidden/discouraged patterns
- Word count and sentence count validation
- Detailed error reporting with severity levels (ERROR, WARNING)
- Support for section alternatives (e.g., FLAGS vs OPTIONS)
- Comprehensive test coverage (16 tests, 100% passing)
Architecture:
- Complements existing SchemaValidator (structural AST validation)
- Clean separation: validators/ package for modular validators
- Semantic validation focuses on x-markitect-* extensions
- LinkValidator planned for Phase 3 (optional --check-links)
Next: Phase 4 - CLI integration to enhance 'markitect validate' command
Workplan: roadmap/20260106-semantic-document-validation/WORKPLAN.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 03:24:32 +01:00
|
|
|
"""
|
|
|
|
|
Validators package for semantic document validation.
|
|
|
|
|
|
|
|
|
|
This package contains validators that check markdown documents against
|
|
|
|
|
x-markitect schema extensions (sections, content-control, link validation).
|
|
|
|
|
|
|
|
|
|
Validators:
|
|
|
|
|
- SectionValidator: Validates section presence based on classifications
|
|
|
|
|
- ContentValidator: Validates content patterns and quality metrics
|
|
|
|
|
- LinkValidator: Validates internal and external links
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from markitect.validators.section_validator import (
|
|
|
|
|
SectionValidator,
|
|
|
|
|
SectionValidationResult,
|
|
|
|
|
SectionIssue,
|
|
|
|
|
SectionMissing,
|
|
|
|
|
SectionImproper,
|
|
|
|
|
SectionDiscouraged,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
from markitect.validators.content_validator import (
|
|
|
|
|
ContentValidator,
|
|
|
|
|
ContentValidationResult,
|
|
|
|
|
ContentIssue,
|
|
|
|
|
PatternMissing,
|
|
|
|
|
ForbiddenPattern,
|
|
|
|
|
DiscouragedPattern,
|
|
|
|
|
ContentTooShort,
|
|
|
|
|
ContentTooLong,
|
|
|
|
|
)
|
|
|
|
|
|
feat: add LinkValidator for semantic link validation (Phase 3)
Implement comprehensive link validation as part of semantic validation:
Core Features:
- Link classification: internal, external, fragment, email
- Internal link validation: fragment anchors and file paths
- External link validation: HTTP/HTTPS with configurable timeout
- Email validation: mailto: link format checking
- Fragment policy enforcement: allow/disallow fragment identifiers
Link Validator:
- markitect/validators/link_validator.py - Full link validation implementation
- Supports x-markitect-content-control.link_validation configuration
- Default: check internal links, skip external (fast)
- Opt-in external checking with --check-links flag
Integration:
- Updated SemanticValidator to include link_result in reports
- CLI already supports --check-links flag (line 1629 in cli.py)
- Link validation runs by default for internal links (fast)
- External link checking requires explicit --check-links flag
Test Coverage:
- Added 9 comprehensive tests for LinkValidator
- Tests cover: classification, broken links, fragments, email, statistics
- All 25 semantic validator tests passing (100%)
Documentation:
- Updated SCHEMA_MANAGEMENT_GUIDE.md with link validation section
- Added examples for broken links and external link checking
- Documented link types, validation rules, and configuration
Statistics Tracking:
- Links checked, internal/external/fragment/email counts
- Detailed error/warning reporting with line numbers
- Integration with existing semantic validation reporting
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 03:41:03 +01:00
|
|
|
from markitect.validators.link_validator import (
|
|
|
|
|
LinkValidator,
|
|
|
|
|
LinkValidationResult,
|
|
|
|
|
LinkIssue,
|
|
|
|
|
BrokenInternalLink,
|
|
|
|
|
BrokenExternalLink,
|
|
|
|
|
FragmentNotAllowed,
|
|
|
|
|
InvalidEmail,
|
|
|
|
|
)
|
|
|
|
|
|
feat: add semantic document validator for x-markitect extensions
Implements semantic validation to complement existing structural validation:
Phase 1 & 2 Complete:
- SemanticValidator: Main validator orchestrating sub-validators
- SectionValidator: Enforces section classifications (required, recommended,
optional, discouraged, improper) from x-markitect-sections
- ContentValidator: Validates content patterns, forbidden patterns, and
quality metrics (word counts, sentence counts) from x-markitect-content-control
Features:
- Pattern matching with regex for required/forbidden/discouraged patterns
- Word count and sentence count validation
- Detailed error reporting with severity levels (ERROR, WARNING)
- Support for section alternatives (e.g., FLAGS vs OPTIONS)
- Comprehensive test coverage (16 tests, 100% passing)
Architecture:
- Complements existing SchemaValidator (structural AST validation)
- Clean separation: validators/ package for modular validators
- Semantic validation focuses on x-markitect-* extensions
- LinkValidator planned for Phase 3 (optional --check-links)
Next: Phase 4 - CLI integration to enhance 'markitect validate' command
Workplan: roadmap/20260106-semantic-document-validation/WORKPLAN.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 03:24:32 +01:00
|
|
|
__all__ = [
|
|
|
|
|
# Section validator
|
|
|
|
|
'SectionValidator',
|
|
|
|
|
'SectionValidationResult',
|
|
|
|
|
'SectionIssue',
|
|
|
|
|
'SectionMissing',
|
|
|
|
|
'SectionImproper',
|
|
|
|
|
'SectionDiscouraged',
|
|
|
|
|
# Content validator
|
|
|
|
|
'ContentValidator',
|
|
|
|
|
'ContentValidationResult',
|
|
|
|
|
'ContentIssue',
|
|
|
|
|
'PatternMissing',
|
|
|
|
|
'ForbiddenPattern',
|
|
|
|
|
'DiscouragedPattern',
|
|
|
|
|
'ContentTooShort',
|
|
|
|
|
'ContentTooLong',
|
feat: add LinkValidator for semantic link validation (Phase 3)
Implement comprehensive link validation as part of semantic validation:
Core Features:
- Link classification: internal, external, fragment, email
- Internal link validation: fragment anchors and file paths
- External link validation: HTTP/HTTPS with configurable timeout
- Email validation: mailto: link format checking
- Fragment policy enforcement: allow/disallow fragment identifiers
Link Validator:
- markitect/validators/link_validator.py - Full link validation implementation
- Supports x-markitect-content-control.link_validation configuration
- Default: check internal links, skip external (fast)
- Opt-in external checking with --check-links flag
Integration:
- Updated SemanticValidator to include link_result in reports
- CLI already supports --check-links flag (line 1629 in cli.py)
- Link validation runs by default for internal links (fast)
- External link checking requires explicit --check-links flag
Test Coverage:
- Added 9 comprehensive tests for LinkValidator
- Tests cover: classification, broken links, fragments, email, statistics
- All 25 semantic validator tests passing (100%)
Documentation:
- Updated SCHEMA_MANAGEMENT_GUIDE.md with link validation section
- Added examples for broken links and external link checking
- Documented link types, validation rules, and configuration
Statistics Tracking:
- Links checked, internal/external/fragment/email counts
- Detailed error/warning reporting with line numbers
- Integration with existing semantic validation reporting
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 03:41:03 +01:00
|
|
|
# Link validator
|
|
|
|
|
'LinkValidator',
|
|
|
|
|
'LinkValidationResult',
|
|
|
|
|
'LinkIssue',
|
|
|
|
|
'BrokenInternalLink',
|
|
|
|
|
'BrokenExternalLink',
|
|
|
|
|
'FragmentNotAllowed',
|
|
|
|
|
'InvalidEmail',
|
feat: add semantic document validator for x-markitect extensions
Implements semantic validation to complement existing structural validation:
Phase 1 & 2 Complete:
- SemanticValidator: Main validator orchestrating sub-validators
- SectionValidator: Enforces section classifications (required, recommended,
optional, discouraged, improper) from x-markitect-sections
- ContentValidator: Validates content patterns, forbidden patterns, and
quality metrics (word counts, sentence counts) from x-markitect-content-control
Features:
- Pattern matching with regex for required/forbidden/discouraged patterns
- Word count and sentence count validation
- Detailed error reporting with severity levels (ERROR, WARNING)
- Support for section alternatives (e.g., FLAGS vs OPTIONS)
- Comprehensive test coverage (16 tests, 100% passing)
Architecture:
- Complements existing SchemaValidator (structural AST validation)
- Clean separation: validators/ package for modular validators
- Semantic validation focuses on x-markitect-* extensions
- LinkValidator planned for Phase 3 (optional --check-links)
Next: Phase 4 - CLI integration to enhance 'markitect validate' command
Workplan: roadmap/20260106-semantic-document-validation/WORKPLAN.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-06 03:24:32 +01:00
|
|
|
]
|