Skip to main content

Module marker

Module marker 

Source
Expand description

Marker-delimited managed block: string surgery over a host file.

The canon owns exactly one region of a consumer’s .pre-commit-config.yaml — the lines between its BEGIN and END markers — and everything here is a pure function over the host text: validate the markers, strip the region, splice a new one into the repos: sequence, and hash what is present. Every line outside the markers passes through byte-identical. What the block contains is the hook renderer’s business, and reading or writing the file is the installer’s.

Enums§

MarkerError
A host file whose markers cannot be trusted, or that cannot host a block.

Constants§

BEGIN
The line that opens the managed region.
END
The line that closes the managed region.

Functions§

block_hash
The hash the manifest records for a host file’s managed region.
block_region
The managed region — BEGIN through END inclusive — as present in a host text, or None when no complete region exists.
splice
Splice a rendered block (BEGIN through END, newline-terminated) into the repos: sequence of a marker-free base, returning the new host text and the indentation the block’s entries should have used.
splice_indent
The indentation a spliced block’s sequence items should carry, measured from the base the block will join.
split_block
Split a host text into its lines outside the managed region and the region itself, validating the markers first.