Convert code directory structure and contents to markdown
Project description
code2md
Convert code directory structure and contents to markdown format.
Installation
pip install code2md
Or for development:
pre-commit install
pip install -e ".[dev]"
Usage
After installation, you can use code2md from the command line:
# Process current directory
code2md
# Process specific directory
code2md /path/to/project
# Generate only directory tree (no file contents)
code2md --tree-only
# Use YAML config file
code2md --config config.yaml
# Include only specific files
code2md --include-files "main.py,utils.py"
# Exclude specific files
code2md --exclude-files "config.py,secrets.txt"
# Exclude directories
code2md --exclude-dirs "__pycache__,.git,node_modules"
# Exclude file patterns
code2md --exclude-patterns "*.log,*_test_*,*.pyc"
# Custom output filename
code2md --output my_project.md
# Combine multiple options
code2md /path/to/project --exclude-dirs ".git,__pycache__" --exclude-patterns "*.log" --output project_overview.md
# Generate tree-only overview of a large project
code2md /path/to/large/project --tree-only --output project_structure.md
# Config file with command line overrides
code2md --config myproject.yaml --output different_name.md
Configuration File
You can use a YAML configuration file to specify all options.
Create a config.yaml file:
# Directory to process (optional, defaults to current directory)
directory: "/path/to/my/project"
# Generate only tree structure without file contents (optional, defaults to false)
tree_only: true
# Files to include (optional, list or comma-separated string)
# If specified, only these files will be included
include_files:
- "main.py"
- "utils.py"
- "config.py"
# Files to exclude (optional, list or comma-separated string)
exclude_files:
- "secrets.txt"
- "local_config.py"
# Directories to exclude (optional, list or comma-separated string)
exclude_dirs:
- "__pycache__"
- ".git"
- "node_modules"
- ".venv"
# File patterns to exclude (optional, list or comma-separated string)
exclude_patterns:
- "*.log"
- "*.tmp"
- "*_test_*"
- "*.pyc"
# Output filename (optional, defaults to code2md_output.md)
output: "output.md"
Alternative format using comma-separated strings:
directory: "/path/to/my/project"
tree_only: false
include_files: "main.py,utils.py,config.py"
exclude_files: "secrets.txt,local_config.py"
exclude_dirs: "__pycache__,.git,node_modules,.venv"
exclude_patterns: "*.log,*.tmp,*_test_*,*.pyc"
output: "my_project_documentation.md"
Then run:
code2md --config config.yaml
Configuration Priority
Command line arguments override config file settings:
# Use config file but override output filename
code2md --config config.yaml --output different_name.md
# Use config file but generate tree-only instead of full content
code2md --config config.yaml --tree-only
# Use config file but add additional exclusions
code2md --config config.yaml --exclude-patterns "*.backup"
Output Format
code2md generates a markdown file with:
- A tree-style directory structure
- Contents of each file in code blocks (unless
--tree-onlyis used)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code2md-1.0.0.tar.gz.
File metadata
- Download URL: code2md-1.0.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d00911030b2aa4aaf4d1c9325a111783fb772f9bd96fd837305e67f5956861ce
|
|
| MD5 |
b133185a92df867dfbba940ca135b8f3
|
|
| BLAKE2b-256 |
3733690270aba3e8b8894f86fd931ccc369aeb0904f7b2daf385628629c4995b
|
File details
Details for the file code2md-1.0.0-py3-none-any.whl.
File metadata
- Download URL: code2md-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6b21bf7cba5bbeca93582deae8ac6e8f804caebabcad2ef8398864b038868b6
|
|
| MD5 |
55abe87f47b1fd393fef47c0e9a54416
|
|
| BLAKE2b-256 |
009fe468d76b31e36660da084479821898fb0320cf6ad3f74b628637d7e6f231
|