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

Uploaded Python 3

File details

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

File metadata

  • Download URL: src2md-0.8.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.8.0.tar.gz
Algorithm Hash digest
SHA256 f25bcf6b2e99954e30f377cd1ef3a129101f7b0c3bad15105e857e514ca2b89d
MD5 1a66eeec20354588777677750078b5fa
BLAKE2b-256 7f40465798688c6a9d992e4fc4e0cf01799883883edfb14f60dd0261d5601d23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: src2md-0.8.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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63c36f30205ba8369ca25f9dfbc80d62984d7cfb45fbcf59b474aa9bc971086f
MD5 4057c94f072626ae6ba1f50bc472ee22
BLAKE2b-256 efbc3a8a4c18d55e81beade2893a12608557c3915968ecdbeaa169d29b80631f

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