#!/usr/bin/env python3 """Documentation generator - creates documentation from code and knowledge.""" import sys import json from pathlib import Path from datetime import datetime def generate_readme(project_path): """Generate README from project structure.""" package_json = project_path / 'package.json' name = project_path.name description = "Project description" if package_json.exists(): with open(package_json) as f: data = json.load(f) name = data.get('name', name) description = data.get('description', description) readme = f"""# {name} {description} ## Installation \`\`\`bash npm install \`\`\` ## Usage \`\`\`typescript // Add usage examples here \`\`\` ## Documentation - [API Documentation](./docs/api/) - [Architecture Decision Records](./docs/adr/) - [Contributing Guidelines](./CONTRIBUTING.md) ## License See LICENSE file. --- *Generated by Documentation Wizard on {datetime.now().strftime('%Y-%m-%d')}* """ output = project_path / 'README.md' with open(output, 'w') as f: f.write(readme) print(f"[OK] Generated: {output}") def main(): project = Path(sys.argv[1] if len(sys.argv) > 1 else '.').resolve() print(f"[NOTE] Generating documentation for: {project}\n") generate_readme(project) print("\n[OK] Documentation generated!") if __name__ == '__main__': main()