Skip to main content
Image

Readme Weaver

Seamlessly embed shared markdown into your README files! 🚀

Description • How It Works • Setup - GitHub Action • Setup - Pre-Commit Hook • Examples • Contributing • Development

📚 Description

Readme Weaver is a tool to keep your project documentation in sync with shared markdown snippets. It scans your markdown files for "include" directives, then replaces those blocks with the latest content from external files. This is ideal for organisations that maintain common sections such as sponsorship, contribution guidelines, or security policies across many repositories.

By automating the inclusion of shared markdown, Readme Weaver helps you keep your docs DRY and up‑to‑date without manual copying.

✨ Key Features

  • Embed shared markdown: insert external markdown files into your README between clearly marked start and end tags.
  • Easy integration: use as a GitHub Action, a pre‑commit hook, or run it manually with uv or pip.
  • Idempotent updates: only the region between the include tags is replaced, preserving your surrounding content.

🔍 How It Works

Readme Weaver looks for specially formatted comment blocks in your markdown files:

<!-- md:include start path="partials/sponsorship.md" required=true -->

…something…

<!-- md:include end -->
  • The path attribute is required and specifies the location of the file to embed. Paths can be absolute or relative to the base directory (defaults to the working directory or to README_WEAVER_BASE if set).
  • The optional required attribute (default true) controls behaviour when the file is missing:
    • required=true (or omitted): raises an error if the file is not found.
    • required=false: leaves the block empty if the file is missing.
  • Everything between the start and end markers is replaced with the contents of the referenced file on each run.

🔧 Setup – GitHub Action

Add Readme Weaver as a step in your GitHub Actions workflow to automatically weave partials on each pull request. Here’s a sample workflow:

name: readme weaver

on:
  pull_request:

permissions:
  contents: write

jobs:
  weave-readme:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          ref: ${{ github.head_ref }}

      - name: checkout partials
        uses: actions/checkout@v5
        with:
          repository: devops-roast/.github
          # A hidden directory keeps the partials repository's own markdown
          # out of the scan. The container action can only read files inside
          # the workspace, so the partials cannot live elsewhere.
          path: .partials
          ref: main

      - name: keep partials out of commits
        run: echo "/.partials/" >> .git/info/exclude

      - name: run readme weaver
        uses: devops-roast/readme-weaver@v0.1.2 # x-release-please-version
        env:
          LOG_LEVEL: DEBUG
          # base directory for include files
          README_WEAVER_BASE: ./.partials/common-markdown

      - name: commit changes back
        uses: stefanzweifel/git-auto-commit-action@v6
        with:
          commit_message: "docs: auto-update with readme-weaver"

🔧 Setup – Pre‑Commit Hook

Readme Weaver can run as a pre‑commit hook to ensure your includes are always up‑to‑date before committing. To install via PyPI:

pip install readme-weaver

Then add this to your .pre-commit-config.yaml:

- repo: local
  hooks:
    - id: readme-weaver
      name: readme-weaver
      entry: readme-weaver run
      language: system

If you prefer to reference the repository directly:

- repo: https://github.com/devops-roast/readme-weaver
  rev: v0.1.0
  hooks:
    - id: readme-weaver

🔧 Options

Option Description
--all-files Process all markdown files in the repository rather than only changed files (useful outside pre‑commit).
--base-dir/-b Override the base directory for resolving relative include paths. Defaults to README_WEAVER_BASE or the current directory.
--log-level/-l Set the logging level (DEBUG, INFO, WARNING, or ERROR). Overrides the LOG_LEVEL environment variable.
--help Show the command line help.

💡 Examples

Suppose you keep shared markdown files in a partials directory and want to embed a common sponsorship section into every README.md.

partials/sponsorship.md:

## Sponsor our work

Your support helps us build great software! ✨ Visit [our sponsoring page](https://example.com) to become a sponsor.

README.md:

# My Project

Welcome to my project.

<!-- md:include start path="partials/sponsorship.md" required=true -->
<!-- placeholder content will be replaced -->
<!-- md:include end -->

## Usage

More docs here…

When you run Readme Weaver (manually, as a pre‑commit hook, or via GitHub Actions), the section between the include tags is replaced:

# My Project

Welcome to my project.

<!-- md:include start path="partials/sponsorship.md" required=true -->

<!-- content below is auto-generated; do not edit -->

## Sponsor our work

Your support helps us build great software! ✨ Visit [our sponsoring page](https://example.com) to become a sponsor.

<!-- md:include end -->

## Usage

More docs here…

If partials/sponsorship.md changes, rerunning the tool automatically updates all READMEs that include it.

Optional Includes

If you mark an include as non‑required (required=false) and the file is missing, the block is simply left empty:

<!-- md:include start path="partials/missing.md" required=false -->
<!-- md:include end -->

After running the tool, the section is removed without error.

🤝 Contributing

Contributions are welcome! To suggest an enhancement, report a bug, or submit a pull request:

  • Open a feature request for new functionality.
  • Open a bug report if something isn’t working as expected.
  • Fork the repository, create a feature branch, make your changes and tests, then open a pull request. Please ensure all tests pass and follow the existing code style.

See the Contributing Guide for detailed guidelines.

🛠️ Development

  1. Fork this project
  2. Install mise.
  3. Install the dependencies by using the following command:
    mise trust
    mise install
    uv pip install --system . -r pyproject.toml --all-extras
    
  4. Make changes to the codebase and run the tests to make sure everything works as expected. ✅
    pytest -q
    
  5. Commit your changes, push them to the repository 🚀, and open a new pull request.

Metadata

Release files for readme-weaver 0.1.2

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

Source distribution (sdist)

Source distribution for readme-weaver 0.1.2
File Size Uploaded Provenance Actions
readme_weaver-0.1.2.tar.gz 3.4 MB Without provenance Details for readme_weaver-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for readme-weaver 0.1.2
File Interpreter ABI Platform Actions
readme_weaver-0.1.2-py3-none-any.whl Python 3 none any Details for readme_weaver-0.1.2-py3-none-any.whl

Total release size: 3.4 MB

Release files / readme_weaver-0.1.2.tar.gz

Download URL readme_weaver-0.1.2.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
fcaf1c054da3f36a7dd4e1c058da5155250c4dc113311bffec97e3b27df9087b
BLAKE2b-256 checksum
How to use checksums
46763543cd31c9853766b7bcf1232092f4b77f79b95ed2e31cc20e5d82ac37e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / readme_weaver-0.1.2-py3-none-any.whl

Download URL readme_weaver-0.1.2-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a45dc477250c276c077077eb7c04f398abd021eefe1b69b234f2819b83fcc4c1
BLAKE2b-256 checksum
How to use checksums
2b544772663c71cb5857b1486c6838a057be078bc3c3d58568c47ee1b7c382b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for readme-weaver 0.1.2

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.

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