Reddit - r/programming

Anchor Pointing: a tiny convention for durable code↔doc links, no tooling required

The problem

Doc references to a line number or function name break the moment code gets refactored. You write "see line 142 of foo.py" or "see calculateRefund()" in a design doc, then six months later the line has shifted or the function got renamed, and the reference just quietly points at the wrong thing (or nothing). Nobody notices until someone follows it and lands in the wrong place.

The fix

Anchor Pointing is a tiny text convention that swaps the location for a fixed ID. You drop an ID at the destination you want to be a durable reference target:

ap.<21-char-base62-id>.E

And reference it from anywhere else - docs, other code, tickets - with:

ap.ref.<21-char-base62-id>.E

Both are just literal strings, so resolving a reference is a plain text search: grep, ripgrep, GitHub code search, Sourcegraph, your IDE, whatever you already use. The ap.ref. prefix exists specifically so a search for the anchor itself never also matches its own references.

Rules

  • One anchor per ID (a single, unambiguous destination)
  • Unlimited references pointing at that ID
  • ID is 21-char base62, making collisions a non-issue with no central coordination

Spec

https://github.com/nickolay-kondratyev/anchor-points/blob/main/ANCHOR_POINTS_SPEC.md

Feedback welcome, especially if this already exists under another name and I've reinvented something.

Comments

No comments yet. Start the discussion.