Git Product home page Git Product logo

yardstick's Introduction

yardstick

Gem Version Build status Dependency Status Code Climate Coverage Status

Yardstick is a tool that verifies documentation coverage of Ruby code. It will measure the source and provide feedback on what is missing from the documentation and what can be improved.

Usage

Yardstick may be used three ways:

1. Command-line Tool

This is the simplest way to run yardstick. Provide it a list of files and it will measure all of them and output suggestions for improvement, eg:

$ yardstick 'lib/**/*.rb' 'app/**/*.rb' ...etc...

2. Rake task

Yardstick may be integrated with existing Rakefile and build processes, and is especially useful when used with a continuous integration system. You can set thresholds, as well as check that the threshold matches the actual coverage, forcing you to bump it up if the actual coverage has increased. It uses a simple DSL to configure the task eg:

# measure coverage

require 'yardstick/rake/measurement'

Yardstick::Rake::Measurement.new(:yardstick_measure) do |measurement|
  measurement.output = 'measurement/report.txt'
end


# verify coverage

require 'yardstick/rake/verify'

Yardstick::Rake::Verify.new do |verify|
  verify.threshold = 100
end

3. Libraries

Yardstick comes with several libraries that will allow you to process lists of files, or String code fragments, eg:

require 'yardstick'

# measure a list of file paths
measurements = Yardstick.measure(paths)

# measure a code fragment
measurements = Yardstick.measure_string <<-RUBY
  # Displays the message provided to stdout
  #
  # @param [#to_str] message
  #   the message to display
  #
  # @return [undefined]
  #
  # @api public
  def display(message)
    puts message.to_str
  end
RUBY

4. Configuration

Every rule in Yardstick can be turned off globally and locally. All rules are enabled and threshold is set to maximum by default (100%). If your documentation coverage is below or above this threshold then yardstick will exit with a nonzero status and print that fact.

Default configuration:

---
threshold: 100
rules:
  ApiTag::Presence:
    enabled: true
    exclude: []
  ApiTag::Inclusion:
    enabled: true
    exclude: []
  ApiTag::ProtectedMethod:
    enabled: true
    exclude: []
  ApiTag::PrivateMethod:
    enabled: true
    exclude: []
  ExampleTag:
    enabled: true
    exclude: []
  ReturnTag:
    enabled: true
    exclude: []
  Summary::Presence:
    enabled: true
    exclude: []
  Summary::Length:
    enabled: true
    exclude: []
  Summary::Delimiter:
    enabled: true
    exclude: []
  Summary::SingleLine:
    enabled: true
    exclude: []

To disable a rule for some part of the code use:

rules:
  ApiTag::Presence:
    enabled: true
    exclude:
      - Foo::Bar  # class or module
      - Foo#bar   # instance method
      - Foo.bar   # class method

Rake tasks take these options as a second argument:

options = YAML.load_file('config/yardstick.yml')

Yardstick::Rake::Verify.new(:verify_measurements, options)

Contributing

See CONTRIBUTING.md for details.

Copyright

Copyright (c) 2009-2013 Dan Kubb. See LICENSE for details.

yardstick's People

Contributors

abinoam avatar backus avatar dkubb avatar indrekj avatar mbj avatar plexus avatar postmodern avatar sferik avatar snusnu avatar trans 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.