Skip to main content

✂️ Snipwise

release pytest zensical PyPI Version PyPI - Python Version LGPL-3 License

Snipwise keeps text snippets in sync across files in a project. Provide a single source of truth for a fragment, and Snipwise will copy it into every README, documentation page or configuration file that repeats it, so that no copy has to be updated manually.

It is generally preferable to avoid redundant information, but sometimes it is unavoidable. The same paragraph on supported Python versions may belong in the README and in the documentation, and the same project summary may be required by several metadata formats. Snipwise works with any text format, because you write the markers yourself in the comment syntax of the file at hand. As a pre-commit hook, it keeps every commit consistent instead of leaving stale copies adrift until somebody notices.

Simple Example

Snipwise is configured by a snipwise.md file in the root of your project. This example shows how to define a snippet in snipwise.md and copy it into the README.md and docs/installation.md files.

# Snipwise Configuration

```toml
[[targets]]
patterns = ["README.md", "docs/*.md"]
```

## `python-versions`

```text
Snipwise requires Python 3.11 or later.
It is tested on Python 3.11, 3.12, 3.13 and 3.14.
```

Both README.md and docs/installation.md then contain a pair of markers:

<!-- snipwise.md BEGIN python-versions -->
<!-- snipwise.md END python-versions -->

Running snipwise fix writes the snippet between each pair of markers:

<!-- snipwise.md BEGIN python-versions -->
Snipwise requires Python 3.11 or later.
It is tested on Python 3.11, 3.12, 3.13 and 3.14.
<!-- snipwise.md END python-versions -->

From then on, snipwise reports any file that has drifted away from snipwise.md, and snipwise fix brings it back in line. The snippet is stored in three places, but only the copy in snipwise.md is meant to be edited. The others are verified (and fixed) mechanically.

The basic idea is simple, but Snipwise also packs a number of convenient features for when this simple approach falls short:

  • A snippet may be transformed on its way into a file, so that it can serve different file formats, such as Markdown, LaTeX, plain text or source code.
  • A file that cannot carry a comment can be reached with a regular expression or with a JSON pointer instead of a marker.
  • If a snippet is naturally defined by a specific file, there is no need to copy it into snipwise.md.

Installation

pip install snipwise

Documentation

The documentation lives at https://reproducible-reporting.github.io/snipwise/.

Start with these pages, the first three of which together are the reference for what Snipwise does:

  • The snipwise.md Configuration File defines snippets and says which files receive them, in what shape, and which copy is the original.
  • Snippet Scanners covers the four ways a rule finds the regions of a file that it owns: the whole file, markers, a regular expression, or a JSON pointer.
  • Command-Line Interface covers the subcommands, the options, the exit codes and the pre-commit hook.
  • Snipwise in Practice discusses good practices, starting with which text is worth turning into a snippet.

For the development of Snipwise itself:

Example Repositories

The following repositories use Snipwise to keep various snippets in sync:

  • Snipwise itself uses snipwise.md to synchronize the list of dependencies and several sections shared by the README and the documentation home page.
  • StepUp Core uses snipwise.md to synchronize a tagline, abstract and keywords across several files.

Snipwise only copies text that you maintain by hand, and it never generates anything. That is a deliberate limit, so here is where to look when that limitation gets in the way.

  • To embed the output of a program, Cog runs a piece of Python and writes what it prints back into the file that holds it. embedme pulls the content of a source file into a fenced code block of a Markdown document.
  • To instantiate a project from a template, and to keep it in step with that template later, there are Cookiecutter and Copier. Snipwise has nothing to say about a file until that file carries markers of its own.
  • To include a fragment while a documentation site is built, there are the snippets extension of PyMdown Extensions for MkDocs, and the include and literalinclude directives of Sphinx. What differs is where the text ends up. Those mechanisms resolve during a build, so the text exists only in the generated site, while Snipwise writes it into the file itself, where GitHub, PyPI and a plain text editor all show it.

License

Snipwise is distributed under the terms of the LGPL-3.0-or-later license. Logo based on Google Noto Emoji, licensed under SIL OFL 1.1

Metadata

Release files for snipwise 1.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 snipwise 1.1.0
File Size Uploaded Provenance Actions
snipwise-1.1.0.tar.gz 565.3 kB With provenance Details for snipwise-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 633.1 kB

Release files / snipwise-1.1.0.tar.gz

Download URL snipwise-1.1.0.tar.gz
Size 565.3 kB
Tags Source
SHA-256 checksum
How to use checksums
71141a514c410ef1bd6372c832aefc0b95eee52edeb61a749a406777777b6e0f
BLAKE2b-256 checksum
How to use checksums
254225c5b596de8b67fe1136978dba56fa469328f634ffd13f2a0efff43803d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / snipwise-1.1.0-py3-none-any.whl

Download URL snipwise-1.1.0-py3-none-any.whl
Size 67.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6cca2594d5d6add1cae279a87fc6e1cc1f0aff78e7b36902d617dd4eb5191c35
BLAKE2b-256 checksum
How to use checksums
e9693321f20df04a53c0ff0181de297814908be885dcf8bc67b3aae45f029451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Security for snipwise 1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for snipwise-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

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