Skip to main content

srcs2md

A CLI utility to generate markdown files from source code using glob patterns. Perfect for creating context files for LLM models.

Installation

pip install -e .

Or with development dependencies:

pip install -e ".[dev]"

Usage

Basic Usage

  1. Create a configuration file:

    srcs2md --init
    
  2. Edit srcs2md.yaml to specify your source patterns

  3. Generate markdown:

    srcs2md                    # Output to stdout
    srcs2md -o output.md       # Output to file
    

Configuration File

The default configuration file srcs2md.yaml supports:

  • Header: Include README content or custom text at the top
  • Patterns: Glob patterns with language specification
  • Ignore: Files/patterns to exclude
  • Output: Formatting options

Example configuration:

header:
  include_file: "README.md"
  custom_text: |
    ## Source codes
    
    This section contains source code files.

patterns:
  - pattern: "src/**/*.py"
    language: python
    description: "Python source files"
  
  - pattern: "src/**/*.rs"
    language: rust
    description: "Rust source files"

ignore:
  - "**/__pycache__/**"
  - "**/.git/**"
  - "**/*.pyc"

output:
  include_paths: true
  sort_files: true

Command Line Options

  • -c, --config PATH: Specify configuration file (default: srcs2md.yaml)
  • -o, --output PATH: Output file (default: stdout)
  • -p, --pattern PATTERN: Add file pattern in format 'pattern;language' (can be used multiple times)
  • --no-config: Skip configuration file entirely, use only command-line options
  • --init: Create default configuration file
  • --version: Show version

Pattern Examples

# Use configuration file patterns
srcs2md

# Add additional patterns to default config file (srcs2md.yaml) patterns
srcs2md -p "src/**/*.py;python" -p "*.md;markdown"

# Use only command line patterns (no config file needed)
srcs2md -p "src/**/*.rs;rust" -p "tests/**/*.rs;rust" -o output.md

# Mix config file and command line patterns
srcs2md -c custom.yaml -p "scripts/*.sh;bash"

# Skip config file entirely (even if srcs2md.yaml exists)
srcs2md --no-config -p "*.py;python" -p "*.rs;rust"

Development

Install development dependencies:

pip install -e ".[dev]"

Run linting and type checking:

ruff check .
ruff format .
mypy srcs2md/

License

MIT

Metadata

Release files for srcs2md 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for srcs2md 0.1.0
File Size Uploaded Provenance Actions
srcs2md-0.1.0.tar.gz 6.3 kB Without provenance Details for srcs2md-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for srcs2md 0.1.0
File Interpreter ABI Platform Actions
srcs2md-0.1.0-py3-none-any.whl Python 3 none any Details for srcs2md-0.1.0-py3-none-any.whl

Total release size: 13.3 kB

Release files / srcs2md-0.1.0.tar.gz

Download URL srcs2md-0.1.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
be999a5815993eb97b31a30c3c0de1bab33f50dc459099a171e26867fc37bd2d
BLAKE2b-256 checksum
How to use checksums
faeb067f611f20aef7a22b30e7b409b1cfe4a7ed5e3cceb2908ccf0abb3568bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / srcs2md-0.1.0-py3-none-any.whl

Download URL srcs2md-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
423ad5196cfc674b6491407358cb0dfee6f17f60c0c52db93d4d786511802de4
BLAKE2b-256 checksum
How to use checksums
14f24489be3b0ee77b3fa9e487d2d6255cdbed5e3880d443c65e2e1aad7cc44b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for srcs2md 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page