Skip to main content

CLI utility for automatic documentation generation from source code and GitHub Issues using AI

Project description

CodeNarrator

Python License Docs 🇷🇺 Русский гайд

CLI utility for automatic documentation generation from source code and GitHub Issues using AI.

CodeNarrator transforms your codebase and issue history into clear, up-to-date, and multilingual documentation. It uses AI to analyze code structure, extract meaningful descriptions, and generate comprehensive documentation.

Features

  • Code Analysis: Parse Python and JavaScript/TypeScript code using Tree-sitter
  • README Generation: Automatically generate comprehensive README files
  • API Documentation: Create detailed API docs with function signatures and descriptions
  • Architecture Diagrams: Generate Mermaid diagrams showing module dependencies
  • FAQ Generation: Cluster GitHub Issues and generate FAQ entries
  • Multilingual Support: Translate documentation to multiple languages (RU, ZH, ES, etc.)
  • Multiple AI Providers: Support for OpenAI, Anthropic Claude, Ollama, and Z.AI (GLM models)
  • Incremental Updates: Only regenerate changed files to save tokens

Installation

pip install codenarrator

Or using Poetry:

poetry add codenarrator

Quick Start

1. Initialize documentation

cd your-project
codenarrator init

This will:

  • Scan your project structure
  • Analyze entry points and dependencies
  • Generate README.md, API docs, and architecture diagrams

2. Update documentation

codenarrator update

Only updates documentation for files that have changed.

3. Generate FAQ from GitHub Issues

codenarrator faq-sync --repo owner/repo

Fetches closed issues, clusters similar problems, and generates FAQ entries.

Configuration

Create a .narrator.yaml file in your project root:

version: 1

project:
  name: null # Auto-detected
  entry_points:
    - main.py
    - src/**/__init__.py

provider:
  type: openai # openai | anthropic | ollama
  model: gpt-4o

analysis:
  languages:
    - python
    - javascript
  ignore:
    - node_modules/**
    - .venv/**

faq:
  github_repo: owner/repo
  labels:
    - bug
    - question
  days_back: 30

localization:
  enabled: true
  languages:
    - ru
    - zh
    - es

output:
  docs_dir: docs

CLI Commands

codenarrator init

Initialize documentation for a project.

codenarrator init [PATH] [OPTIONS]

Options:
  -p, --provider TEXT  AI provider (openai, anthropic, ollama)
  -m, --model TEXT     Model to use for analysis
  -o, --output PATH    Output directory for documentation
  -l, --languages TEXT Target languages for localization

codenarrator update

Update documentation incrementally.

codenarrator update [PATH] [OPTIONS]

Options:
  --incremental  Update only changed files (default)
  --full         Regenerate all documentation

codenarrator faq-sync

Sync FAQ from GitHub Issues.

codenarrator faq-sync [PATH] [OPTIONS]

Options:
  -r, --repo TEXT    GitHub repository (owner/repo)
  -d, --days INTEGER Days to look back
  --labels TEXT      Issue labels to filter

codenarrator config

Manage configuration.

codenarrator config [PATH] [OPTIONS]

Options:
  -s, --show  Show current configuration

Environment Variables

  • OPENAI_API_KEY: OpenAI API key
  • ZAI_API_KEY: Z.AI API key (alternative to OPENAI_API_KEY)
  • ANTHROPIC_API_KEY: Anthropic API key
  • GITHUB_TOKEN: GitHub personal access token (for FAQ generation)
  • OLLAMA_BASE_URL: Ollama API URL (default: http://localhost:11434)

AI Providers

OpenAI

codenarrator init --provider openai --model gpt-4o

Anthropic Claude

codenarrator init --provider anthropic --model claude-3-opus-20240229

Ollama (Local)

codenarrator init --provider ollama --model llama2

Z.AI GLM Models

codenarrator init --provider openai --model GLM-4.7

# Or use config file (.narrator.yaml):
provider:
  type: openai
  model: GLM-4.7
  base_url: https://api.z.ai/api/coding/paas/v4

See .narrator.zai.example.yaml for full Z.AI configuration example or ZAI_SETUP.md for detailed setup guide.

Supported Languages

Code Analysis

  • Python
  • JavaScript
  • TypeScript

Documentation Translation

  • English (base)
  • Russian (ru)
  • Chinese Simplified (zh)
  • Spanish (es)
  • French (fr)
  • German (de)
  • Japanese (ja)
  • Korean (ko)
  • Portuguese (pt)
  • Italian (it)

Project Structure

your-project/
├── .narrator.yaml       # Configuration
├── .narrator/
│   └── cache.json       # Cache for incremental updates
├── docs/
│   ├── README.md        # Main documentation
│   ├── api/             # API documentation
│   ├── architecture.md  # Architecture diagrams
│   └── FAQ.md          # Generated FAQ
└── README.ru.md         # Localized versions

Development

Setup

git clone https://github.com/codenarrator/codenarrator
cd codenarrator
poetry install

Testing

poetry run pytest

Type Checking

poetry run mypy src/codenarrator

Linting

poetry run ruff check src/

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codenarrator-0.1.0.tar.gz (40.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codenarrator-0.1.0-py3-none-any.whl (50.7 kB view details)

Uploaded Python 3

File details

Details for the file codenarrator-0.1.0.tar.gz.

File metadata

  • Download URL: codenarrator-0.1.0.tar.gz
  • Upload date:
  • Size: 40.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for codenarrator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 325efd3887943980cae872a2ca8bee8103dd952e93f4a41134fcaa448663cf3f
MD5 19793b501c9ba3f62740e27209fa4965
BLAKE2b-256 23fa5fd13f92f86728a2ffd24ca106ff8275a35bd6482170e73f11ac2d39a40f

See more details on using hashes here.

File details

Details for the file codenarrator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: codenarrator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for codenarrator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6187dfef6e10c8dea41e0daccc3c7b5363f96a4cba66d10df37526b7ef04cde0
MD5 5b71c0398b1031d7f10c81934169efe2
BLAKE2b-256 4e0b273ee36c829b61054280b82dc4237fec9e025168d27f6cbea6d5b9bcdfc7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page