Install
consolepip install docanchor
Use
pythonfrom docanchor import check_files
for problem in check_files(["README.md", "docs/install.md"]):
print(problem) # README.md:42: docs/install.md#quick-start is not ...
Or check a string against a resolver you control:
pythonfrom docanchor import check
docs = {"install.md": "## Quick start\n"}
problems = check(
"See [install](install.md#quick-start).",
resolve=docs.get, # None means "cannot read"
source="README.md",
)
What counts as an anchor
- ATX headings
## Quick start→quick-start - setext headings (
Titleover=====) →title - duplicates get
-1,-2, as GitHub does, so both#notesand#notes-1work - explicit
<a name="custom">and any HTMLid="custom" - headings inside fenced code blocks are ignored, as are links there
- matching is case-insensitive
Slugs follow GitHub's rules: lowercase, inline code removed, punctuation dropped, spaces turned into hyphens. Emoji and other symbols disappear the same way they do on GitHub, so an emoji-only heading gets a stable (if empty) slug.
What is skipped
- external links (
https:,mailto:, …) — this is not a crawler - links without a
#anchor - images (
) - reference-style links and HTML
hrefs
Those are the cases where a full link checker (or the site build) already helps.
Development
consolepython -m venv .venv
.venv/bin/pip install -e ".[test]"
.venv/bin/pytest
The suite covers every line of the package (pytest --cov --cov-branch), and the examples in the docstrings run as tests through --doctest-modules.
License
MIT.
Other libraries here
One problem each, standard library only, no runtime dependencies.
- argrepair — turn a bad tool call into a message the model can act on
- backoff-headers — turn a rate-limit header into the exact time to wait
- columncheck — find the CSV defect before the pipeline does
- dir-digest — one hash for a directory tree, identical on every OS
- envfile-diff — diff two .env files without printing the secrets
- fsync-replace — replace a file so a crash cannot leave it half-written
- header-date — HTTP dates parsed strictly, formatted correctly
- junit-merge — merge JUnit XML from every job into one honest report
- npm-semver — npm semver ranges, parsed the way npm parses them
- outputcap — keep a huge tool result out of the context window
- parse-size — byte sizes in and out, MB and MiB never confused
- path-containment — keep untrusted paths inside their directory
- redactscope — stop secrets in tool results before they reach the model
- runbudget — a per-run cost cap that warns before it stops
- testflakes — rank your flaky tests from the history you already have
- tool-loop-guard — catch an agent repeating itself while it is still cheap
- toolcall-ledger — a hash-chained record of every tool call
- toolcircuit — stop retrying a tool that is down
- toolquota — client-side rate limits your agent loop can wait on
- wheeldeps — read a wheel's dependencies offline, markers included
- zip-deterministic — byte-identical archives, build after build