Skip to main content

A tool to convert source code directories into Markdown documentation.

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 generating project overviews, documentation for large codebases, or providing context to language models.

🚀 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 as documentation or source code using patterns.
  • Ignore Hidden Files and Directories: Automatically excludes hidden files and directories (those starting with .).
  • Leverages .gitignore: Respects your .gitignore settings to exclude unwanted files.
  • 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/yourusername/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 root 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-patterns '*.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-patterns '*.py' '*.js'
    

    To include all files as source code:

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

    Exclude specific files or directories.

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

    Specify a custom ignore file.

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

    Do not use .gitignore for ignoring files.

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

Full Example

src2md ./my_project -o my_project_docs.md \
    --doc-patterns '*.md' '*.rst' '*.lark' \
    --src-patterns '*.py' '*.cpp' '*.js' \
    --ignore-patterns '*.pyc' 'build/' 'dist/'

This command generates my_project_docs.md by including all .md, .rst, and .lark documentation files, embedding .py, .cpp, and .js source files, and excluding any .pyc files and directories named build or dist.

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.1.0.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.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for src2md-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35efbbc5b62f83b5f06c2fe850cf3f138701087912ed93738e6635c8bc02678a
MD5 7284401f9e5fde95fc3d8856b6cc6290
BLAKE2b-256 97ca90ad939a61589717d63e6dbc594d7c438c0ed9e988b16eb1b32a18f9f584

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for src2md-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbffdea591fd55b7f086a016b07ba56e169d454371ba1184dc1e0d07095b7150
MD5 72ceab6178f357394eac2cddf702c582
BLAKE2b-256 8b8b8858838f5de576087b3c2e4277a11b65fb57a40866fa80526647b551bc0e

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