Skip to main content

Convert code directory structure and contents to markdown

Project description

code2md

Convert code directory structure and contents to markdown format.

Installation

pip install .

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:

  1. A tree-style directory structure
  2. Contents of each file in code blocks (unless --tree-only is used)

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

code2md-0.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

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

code2md-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code2md-0.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for code2md-0.1.0.tar.gz
Algorithm Hash digest
SHA256 881861598c1b5439213aef5ccd5a5154dacf269450ce52819e5066b6e53eeb01
MD5 1ed223733abebb416782f01e6624fb93
BLAKE2b-256 6b3e9a58e780c7bc6b4ba8704e28edf38b9f8b19902aa6a372e718e995dc6ee2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: code2md-0.1.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.11.13

File hashes

Hashes for code2md-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 618ba9753162952ba95a830fd96071a6434ae743afe0198e017604c36a92c3f3
MD5 b2645ec485bfab623b19014e19cd71da
BLAKE2b-256 7165c81a66cff44599e673751a87170f154a9f24c2145f501a5a013b04265ecb

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