Skip to main content

Module file_refs

Module file_refs 

Source
Expand description

Scan source files for textual references to document ids.

A document id like FEAT-0123 is often mentioned in code — in comments, string literals, identifiers. The project config ([file_refs]) declares the textual formats an id may take ({id}, {prefix}{num}, {prefix_lower}_{num}, …); this module renders each format for a set of ids, scans the configured roots, and reports every hit with enough context to display it or to build a sed fix command.

This is deliberately separate from crate::refs (the references relation maps between documents) — here the target is arbitrary source code.

Structs§

FileRef
One occurrence of a document id in a source file.

Functions§

render
Render a [RefFormat] template for id, or None if id is malformed. Placeholders: {id}, {prefix}, {prefix_lower}, {num}, {padded}.
scan
Scan the configured roots for textual references to any of ids. Returns hits sorted by (path, line, id). Each id is matched in every effective format.
sed_fix
A sed -i command that rewrites every occurrence of one id’s rendered form to the new id’s rendered form in path. word mirrors the format so the substitution matches exactly what the scan found.