A CLI utility to generate markdown files from source code using glob patterns
Project description
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
-
Create a configuration file:
srcs2md --init -
Edit
srcs2md.yamlto specify your source patterns -
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file srcs2md-0.1.0.tar.gz.
File metadata
- Download URL: srcs2md-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be999a5815993eb97b31a30c3c0de1bab33f50dc459099a171e26867fc37bd2d
|
|
| MD5 |
c4fd1b33f8a2b6a838e04ddb05cd4bed
|
|
| BLAKE2b-256 |
faeb067f611f20aef7a22b30e7b409b1cfe4a7ed5e3cceb2908ccf0abb3568bd
|
File details
Details for the file srcs2md-0.1.0-py3-none-any.whl.
File metadata
- Download URL: srcs2md-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
423ad5196cfc674b6491407358cb0dfee6f17f60c0c52db93d4d786511802de4
|
|
| MD5 |
fecc47ac1f559725e4d7b3f5d5e9399b
|
|
| BLAKE2b-256 |
14f24489be3b0ee77b3fa9e487d2d6255cdbed5e3880d443c65e2e1aad7cc44b
|