Skip to main content

A tool to convert source code directories into a single Markdown file.

Project description

src2md

License PyPI Python Versions

src2md is a versatile tool that converts source code directories into comprehensive Markdown documentation. It scans your project structure, includes documentation files like README.md or README.rst, and embeds source code snippets with proper syntax highlighting. Ideal for providing context to LLMs or sharing project details with collaborators.

🚀 Features

  • Automatic Documentation Aggregation: Collects and prioritizes documentation files (e.g., README.md, README.rst).
  • Syntax-Highlighted Source Code: Embeds source code files with appropriate language identifiers for Markdown.
  • Flexible File Patterns: Customize which files to include (whitelist patterns) or exclude (blacklist patterns).
  • Leverages .src2mdignore: Works like .gitignore, you can even use that file directly.
  • Simple CLI Interface: Easy-to-use command-line interface for generating documentation.

📦 Installation

You can install src2md via PyPI using pip:

pip install src2md

Alternatively, install it directly from the source:

git clone https://github.com/queelius/src2md.git
cd src2md
pip install .

🛠️ Usage

Once installed, you can use src2md from the command line to generate Markdown documentation for your project.

Basic Command

src2md path/to/source -o output.md
  • path/to/source: Path to your project's roo directory.
  • -o output.md: (Optional) Specifies the output Markdown file name. Defaults to project_documentation.md.

Advanced Options

  • Specify Documentation Patterns

    Include additional documentation file types.

    src2md path/to/source -o output.md --doc-pat '*.md' '*.rst' '*.lark'
    
  • Specify Source Code Patterns

    Customize which source files to include. Use '*' to include all files.

    src2md path/to/source -o output.md --src-pat '*.py' '*.js'
    

    To include all files as source code:

    src2md path/to/source -o output.md --src-pat '*'
    
  • Add Additional Ignore Patterns

    Exclude specific files or directories.

    src2md path/to/source -o output.md --ignore-pat '*.pyc' 'build/' 'dist/'
    
  • Use a Custom Ignore File

    Specify a custom ignore file. If .src2mdignore is present in the source directory, it will be used by default. Here we show how to point to a different file, the .gitignore file.

    src2md path/to/source -o output.md --ignore-file .gitignore
    
  • Disable .gitignore Usage

    Do not use .gitignore for ignoring files.

    src2md path/to/source -o output.md --no-use-gitignore
    

Full Example

src2md proj --doc-pat '*.md' '*.lark' --src-pat '*.py' --ignore-pat '*.pyc' 'build/' 'dist/' '.*'

This command generates project.md by including all .md, and .lark documentation files, embedding .py, source files, and excluding any .pyc files, excluding directories named build or dist, and ignoring all hidden files and directories (start with .).

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

src2md-0.9.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

src2md-0.9.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file src2md-0.9.1.tar.gz.

File metadata

  • Download URL: src2md-0.9.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for src2md-0.9.1.tar.gz
Algorithm Hash digest
SHA256 cfc8cfcb404b4217cfafb411636c2ee560f59fa3bb86ca2ec230033c57364339
MD5 0dd63e21b17c1230fb0d91958c18192e
BLAKE2b-256 e975447528ce959edd35f013eaa8bd03b3b12e939eab65f320bb96569f89c4e9

See more details on using hashes here.

File details

Details for the file src2md-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: src2md-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for src2md-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 757fcde97a7a78eb61645ca5d7c68411ec2ccdb94e2ca74bac23ad9c179b2b6b
MD5 ca8a157f57061b49f44bc93bb4c954f6
BLAKE2b-256 c7f3b82d1df54788ea1b698caf720f0f66d3d4b997ba0c806c8a675555e4d393

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