Add initial project structure and core functionality for ArchDoc
- Created `.gitignore` files for various directories to exclude unnecessary files. - Added `PLAN.md` to outline the project goals and architecture documentation generation. - Implemented the `archdoc-cli` with a command-line interface for initializing and generating documentation. - Developed the `archdoc-core` library for analyzing Python projects and generating architecture documentation. - Included caching mechanisms to optimize repeated analysis. - Established a comprehensive test suite to ensure functionality and error handling. - Updated `README.md` to provide an overview and installation instructions for ArchDoc.
This commit is contained in:
26
test-project/src/utils.py
Normal file
26
test-project/src/utils.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Utility functions for the test project."""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
def load_config(config_path: str) -> dict:
|
||||
"""Load configuration from a JSON file."""
|
||||
with open(config_path, 'r') as f:
|
||||
return json.load(f)
|
||||
|
||||
def save_config(config: dict, config_path: str):
|
||||
"""Save configuration to a JSON file."""
|
||||
with open(config_path, 'w') as f:
|
||||
json.dump(config, f, indent=2)
|
||||
|
||||
def get_file_size(filepath: str) -> int:
|
||||
"""Get the size of a file in bytes."""
|
||||
return os.path.getsize(filepath)
|
||||
|
||||
def format_bytes(size: int) -> str:
|
||||
"""Format bytes into a human-readable string."""
|
||||
for unit in ['B', 'KB', 'MB', 'GB']:
|
||||
if size < 1024.0:
|
||||
return f"{size:.1f} {unit}"
|
||||
size /= 1024.0
|
||||
return f"{size:.1f} TB"
|
||||
Reference in New Issue
Block a user