noteref 0.2.0

Noteref helps you make notes in your codebase and maintain references to them.
noteref-0.2.0 is not a library.

Noteref

Noteref helps you make notes in your codebase and maintain references to them. This is particularly useful for documenting preconditions, postconditions, invariants, and other kinds of assumptions that aren't enforced by your tooling. For example, you might have a note like this:

# [note:wibble_nonempty]
# ----------------------
# This method always returns a non-empty list.
def wibble(x)
  ...
end

Elsewhere, suppose you're writing some code that depends on that postcondition. You can make this clear by referencing the note:

flobs = wibble(wobble)

return flobs[0] # This is safe due to [ref:wibble_nonempty].

Noteref ensures such references stay up-to-date. For example, if someone changes the behavior of wibble and deletes the note, Noteref will complain because there is some code that references it.

More generally, Noteref recursively scans a directory and checks the following:

  1. References actually point to notes. A note cannot be deleted without updating the references that point to it.
  2. Note labels are distinct. There is never any ambiguity about which note is being referenced.

The syntax is [note:label] for notes and [ref:label] for references. Noteref works with any programming language, and it respects your .gitignore file as well as other common filter files. It is highly recommended to set up Noteref as an automated continuous integration check. Noteref is fast and probably won't be the bottleneck in your CI.

Usage

The easiest way to use Noteref is to run the noteref command with no arguments. It will scan the working directory and check the two conditions described above. Here are the supported command-line options:

USAGE:
    noteref [FLAGS] [OPTIONS]

FLAGS:
    -h, --help          Prints help information
    -n, --list-notes    List all the notes.
    -r, --list-refs     List all the refs.
    -V, --version       Prints version information

OPTIONS:
    -p, --path <PATH>    Set the path of the directory to scan.

Acknowledgements

The idea for Noteref was inspired by the GHC notes convention. GHC is one of the most maintainable codebases for its size. This article has more insights into how the GHC developers manage that codebase.