-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgenerator_interface.py
More file actions
44 lines (33 loc) · 1.44 KB
/
generator_interface.py
File metadata and controls
44 lines (33 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
from abc import ABC, abstractmethod
from typing import Any, Dict, List
from sync_ai_rules.core.rule_metadata import RuleMetadata
class OutputGenerator(ABC):
"""Abstract base class for all output generators."""
@property
@abstractmethod
def name(self) -> str:
"""Unique name for this generator."""
@property
@abstractmethod
def default_filenames(self) -> List[str]:
"""Default output filenames or directories."""
@abstractmethod
def generate(self, rules: Dict[str, List[RuleMetadata]], config: Dict[str, Any]) -> str:
"""Generate output content from grouped rules."""
@abstractmethod
def get_section_markers(self) -> tuple[str, str]:
"""Return start and end markers for auto-generated section."""
@property
def gitattributes_patterns(self) -> List[str]:
"""Glob patterns (repo-root-relative) to mark as linguist-generated in .gitattributes."""
return []
@property
def is_multi_file(self) -> bool:
"""Whether this generator creates files directly via generate_files()."""
return False
def generate_files(self, rules: Dict[str, List[RuleMetadata]], project_root: str) -> None:
"""Generate multiple files directly. Only called when is_multi_file is True."""
raise NotImplementedError(
f"{type(self).__name__} sets is_multi_file=True but does not implement generate_files()"
)