27 lines
750 B
Python
27 lines
750 B
Python
|
|
"""
|
||
|
|
Frontmatter statistics data structures.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from dataclasses import dataclass
|
||
|
|
from typing import Dict, Any, Optional
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class FrontmatterStats:
|
||
|
|
"""Statistics about frontmatter in a markdown document."""
|
||
|
|
|
||
|
|
has_frontmatter: bool
|
||
|
|
total_fields: int
|
||
|
|
nested_fields: int
|
||
|
|
format: Optional[str] # "yaml", "json", "toml", None
|
||
|
|
field_types: Dict[str, int] # Count of each data type
|
||
|
|
|
||
|
|
def to_dict(self) -> Dict[str, Any]:
|
||
|
|
"""Convert stats to dictionary."""
|
||
|
|
return {
|
||
|
|
"has_frontmatter": self.has_frontmatter,
|
||
|
|
"total_fields": self.total_fields,
|
||
|
|
"nested_fields": self.nested_fields,
|
||
|
|
"format": self.format,
|
||
|
|
"field_types": self.field_types
|
||
|
|
}
|