Codebase to DOCX
Convert your entire codebase to a Word document with ease! This Python package scans your project directory and creates a well-formatted Word document containing all your code files.
Features
- 📁 Automatic file discovery - Recursively scans your codebase
- 📝 File path inclusion - Optional display of full file paths
- 📑 Table of contents - Easy navigation through your codebase
- 🚫 Smart filtering - Automatically ignores common directories (node_modules, .git, etc.)
- 🎨 Clean formatting - Code presented in monospace font with clear headings
- ⚙️ Customizable - Configure which files and directories to include
Installation
pip install vinzy_codebase_to_docx
Usage
Basic Usage
from vinzy_codebase_to_docx import convert_codebase
# Convert entire codebase
convert_codebase(
codebase_path="/path/to/your/project",
output_path="my_codebase.docx"
)
Advanced Usage
from vinzy_codebase_to_docx import CodebaseConverter
converter = CodebaseConverter(
codebase_path="/path/to/your/project",
output_path="my_codebase.docx",
include_file_paths=True, # Show file locations
include_toc=True, # Include table of contents
ignore_dirs={'tests', 'docs'}, # Additional dirs to ignore
include_extensions={'.py', '.js'} # Only include these files
)
# Convert with progress tracking
def progress(current, total, filename):
print(f"Processing {current}/{total}: {filename}")
converter.convert(progress_callback=progress)
Command Line Usage
python codebase_to_docx.py /path/to/codebase output.docx
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
codebase_path |
str | Required | Path to your codebase directory |
output_path |
str | 'codebase.docx' |
Output Word document path |
include_file_paths |
bool | True |
Show full file paths in document |
include_toc |
bool | True |
Include table of contents |
ignore_dirs |
Set[str] | See below | Directories to skip |
include_extensions |
Set[str] | See below | File extensions to include |
Default Ignored Directories
{
'__pycache__', 'node_modules', '.git', '.venv', 'venv',
'env', 'build', 'dist', '.idea', '.vscode', 'target',
'.gradle', 'bin', 'obj', 'coverage'
}
Default Included Extensions
{
'.py', '.js', '.jsx', '.ts', '.tsx', '.java', '.cpp', '.c', '.h',
'.cs', '.rb', '.go', '.rs', '.php', '.swift', '.kt', '.scala',
'.html', '.css', '.scss', '.sass', '.less', '.xml', '.json',
'.yaml', '.yml', '.md', '.txt', '.sh', '.bash', '.sql', '.r'
}
Examples
Example 1: Convert Python Project Only
from codebase_to_docx import convert_codebase
convert_codebase(
codebase_path="/path/to/project",
output_path="python_code.docx",
include_extensions={'.py'}
)
Example 2: Include Tests but Ignore Documentation
from codebase_to_docx import CodebaseConverter
converter = CodebaseConverter(
codebase_path="/path/to/project",
output_path="codebase_with_tests.docx",
ignore_dirs={'docs', 'documentation'}
)
converter.convert()
Example 3: Custom Extensions for Web Project
convert_codebase(
codebase_path="/path/to/web/project",
output_path="web_project.docx",
include_extensions={'.html', '.css', '.js', '.jsx', '.tsx'}
)
Use Cases
- 📚 Documentation - Create comprehensive code documentation
- 🔍 Code Review - Share entire codebase for review
- 📦 Archival - Archive project snapshots
- 🎓 Education - Share code examples with students
- 💼 Presentations - Include code in professional documents
Requirements
- Python 3.7+
- python-docx>=0.8.11
License
MIT License
Tips
- Large Codebases: For very large projects, consider filtering by specific directories or file types
- Binary Files: The converter automatically skips binary files and handles encoding errors
- Performance: Processing time depends on codebase size; expect ~100-500 files per minute
- File Size: Large codebases may result in large Word documents; consider splitting if needed
Troubleshooting
Issue: Out of memory error
- Solution: Process smaller portions of your codebase or increase available memory
Issue: Some files not appearing
- Solution: Check if they're in ignored directories or have unsupported extensions
Issue: Encoding errors
- Solution: The converter uses
errors='ignore'to handle encoding issues automatically
Metadata
Release files for vinzy-codebase-to-docx 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| vinzy_codebase_to_docx-0.1.0.tar.gz | 6.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vinzy_codebase_to_docx-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / vinzy_codebase_to_docx-0.1.0.tar.gz
| Download URL | vinzy_codebase_to_docx-0.1.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e7a083b863cd2fcc6a29f58f3e5cfa8928dc10e017d4bc55ba6872a64c0188c
|
|
BLAKE2b-256 checksum How to use checksums |
f46f4cc1e3b36c96c5dca596518037172b41c5ef399fb70414e231fa9df36eee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Release files / vinzy_codebase_to_docx-0.1.0-py3-none-any.whl
| Download URL | vinzy_codebase_to_docx-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5dcf8226508e8966918d59986c64931fcd6758fc1bf9d904b7709df342a21a94
|
|
BLAKE2b-256 checksum How to use checksums |
4d66c71446780bb20fb2ff5754f486c95bab0712fe3b08c1e4cd773393004ef4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.5
|
Security for vinzy-codebase-to-docx 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.