Skip to content

Instantly share code, notes, and snippets.

@NuckChorris
Forked from chetan/yardoc_cheatsheet.md
Last active September 17, 2017 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NuckChorris/0efcb8094d9a6a4b234dce0fec0327ae to your computer and use it in GitHub Desktop.
Save NuckChorris/0efcb8094d9a6a4b234dce0fec0327ae to your computer and use it in GitHub Desktop.
YARD cheatsheet

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

# Namespace for classes and modules that handle serving documentation over HTTP
# @since 0.6.0

Classes

# Abstract base class for CLI utilities. Provides some helper methods for
# the option parser
# 
# @author Full Name
# @abstract
# @since 0.6.0
# @!attribute [Types] attribute_name a full description of the attribute
# @!attribute name
#   @return [Types] a full description of the attribute
# @!attribute [r] name
#   @return [Types] a read-only attribute
# @deprecated Describe the reason and tell them to use {Another::Klass} instead.

Methods

# An alias to {Parser::SourceParser}'s parsing method
# 
# @author Donovan Bray
#
# @see http://example.com Description of URL
# @see SomeOtherClass#method
#
# @deprecated Use {#my_new_method} instead of this method because
#   it uses a library that is no longer supported in Ruby 1.9. 
#   The new method accepts the same parameters.
#
# @abstract
# @private
#
# @param opts [Hash] opts an options hash
# @option opts [String] :subject The subject
# @option opts [String] :from ('nobody') From address
# @option opts [String] :to Recipient email
# @option opts [String] :body ('') The email's body 
#
# @param (see User#initialize)
# @param opts [OptionParser] the option parser object
# @param args [Array<String>] the arguments passed from input. This
#   array will be modified.
# @param list [Array<String, Symbol>] the list of strings and symbols.
#
# The options parsed out of the commandline.
# Default options are:
#   :format => :dot
#
# @example Reverse a string
#   "mystring.reverse" #=> "gnirtsym"
#
# @example Parse a glob of files
#   YARD.parse('lib/**/*.rb')
#  
# @raise [ExceptionClass] description
#
# @return [optional, types, ...] description
# @return [true] always returns true
# @return [void]
# @return [String, nil] the contents of our object or nil
#   if the object has not been filled with data.
#
# We don't care about the "type" here:
# @return the object
#
# @return [String, #read] a string or object that responds to #read
# @return description here with no types

Anywhere

# @todo Add support for Jabberwocky service
#   There is an open source Jabberwocky library available 
#   at http://somesite.com that can be integrated easily
#   into the project.

Blocks

# for block {|a, b, c| ... }
# @yield [a, b, c] Description of block
#
# @yieldparam [optional, types, ...] argname description
# @yieldreturn [optional, types, ...] description
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment