Code Monkey home page Code Monkey logo

tagref's Introduction

Tagref

Build status

Tagref helps you refer to other locations in your codebase. For example, you might create a tag like this:

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

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

flobs = wibble(wobble)

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

Tagref ensures such references remain valid. If someone tries to delete or rename the tag (e.g., because they want to change what wibble does), Tagref will complain. More precisely, it checks the following:

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

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

Installation

Easy installation

If you are running macOS or a GNU-based Linux on an x86-64 CPU, you can install Tagref with this command:

curl https://raw.githubusercontent.com/stepchowfun/tagref/master/install.sh -LSfs | sh

The same command can be used again to update Tagref to the latest version.

NOTE: Piping curl to sh is dangerous since the server might be compromised. If you're concerned about this, you can download and inspect the installation script or choose one of the other installation methods.

Customizing the installation

The installation script supports the following environment variables:

  • VERSION=x.y.z (defaults to the latest version)
  • PREFIX=/path/to/install (defaults to /usr/local/bin)

For example, the following will install Tagref into the working directory:

curl https://raw.githubusercontent.com/stepchowfun/tagref/master/install.sh -LSfs | PREFIX=. sh

Manual installation

The releases page has precompiled binaries for macOS or Linux systems running on an x86-64 CPU. You can download one of them and place it in a directory listed in your PATH.

Installation with Cargo

If you have Cargo, you can install Tagref as follows:

cargo install tagref

You can run that command with --force to update an existing installation.

Usage

The easiest way to use Tagref is to run the tagref 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:
    tagref [SUBCOMMAND]

OPTIONS:
    -h, --help                       Prints help information
    -p, --path <PATH>...             Adds the path of a directory to scan [default: .]
    -r, --ref-prefix <REF_PREFIX>    Sets the prefix used for locating references [default: ref]
    -t, --tag-prefix <TAG_PREFIX>    Sets the prefix used for locating tags [default: tag]
    -v, --version                    Prints version information

SUBCOMMANDS:
    check          Check all the tags and references (default)
    help           Prints this message or the help of the given subcommand(s)
    list-refs      List all the references
    list-tags      List all the tags
    list-unused    List the unreferenced tags

Acknowledgements

The idea for Tagref was inspired by the GHC notes convention. This article has more insights into how the GHC developers manage their codebase.

tagref's People

Contributors

stepchowfun avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.