state

State tracking for incremental documentation builds. Stores per-file hashes so only changed / new / deleted files trigger re-generation. State is persisted as a JSON file in the output directory.

📄 /home/runner/work/autoredocs/autoredocs/src/autoredocs/state.py

Classes

class
class BuildState
Tracks file hashes for incremental builds.
📍 Line 20

Methods

def
def __init__(self, state_path: Path)
Initialize the state object. Args: state_path: The path to the state file. Raises: FileNotFoundError: If the state file does not exist. OSError: If an error occurs while loading the state file.
def
def _load(self) -> None
Load previous state from disk.
def
def save(self) -> None
Persist current state to disk.
def
@staticmethod
def _hash_file(filepath: Path) -> str
Compute SHA-256 hash of a file's contents.
def
def has_changed(self, filepath: Path) -> bool
Check if a file has changed since the last build.
def
def update(self, filepath: Path) -> None
Record the current hash of a file.
def
def remove(self, filepath: Path) -> None
Remove a file's hash from state (file was deleted).
def
def known_files(self) -> set[str]
Return the set of file paths tracked in state.
def
def compute_diff(self, current_files: list[Path]) -> tuple[list[Path], list[Path], list[Path]]
Compare current files against stored state. Returns: Tuple of (added_or_modified, unchanged, deleted) file lists.