Module | YARD::Templates::Helpers::BaseHelper
In: | lib/yard/templates/helpers/base_helper.rb

The base helper module included in all templates.

### Methods

format_object_title format_object_type format_source format_types globals h link_file link_include_file link_include_object link_object link_url linkify run_verifier

### Attributes

object | [RW] |
serializer | [RW] |

### Public Instance methods

format_object_title(object)

@example

      s = format_object_title ModuleObject.new(:root, :MyModuleName)
      s # => "Module: MyModuleName"

@param [CodeObjects::Base] object the object to retrieve a title for @return [String] the page title name for a given object

format_object_type(object)

@example Formatted type of an exception class

      o = ClassObject.new(:root, :MyError)
      o.superclass = P('RuntimeError')
      format_object_type(o) # => "Exception"

@example Formatted type of a method

      o = MethodObject.new(:root, :to_s)
      format_object_type(o) # => "Method"

@param [CodeObjects::Base] object the object to retrieve the type for @return [String] the human-readable formatted {CodeObjects::Base#type type}

      for the object

format_source(value)

Indents and formats source code

@param [String] value the input source code @return [String] formatted source code

format_types(list, brackets = true)

Formats a list of return types for output and links each type.

@example Formatting types

      format_types(['String', 'Array']) #=> "(String, Array)"

@example Formatting types without surrounding brackets

      format_types(['String', 'Array'], false) #=> "String, Array"

@param [Array<String>] list a list of types @param [Boolean] brackets whether to surround the types in brackets @return [String] the formatted list of Ruby types

globals()

An object that keeps track of global state throughout the entire template rendering process (including any sub-templates).

@return [OpenStruct] a struct object that stores state @since 0.6.0

h(text)

Escapes text. This is used a lot by the HtmlHelper and there should be some helper to "clean up" text for whatever, this is it.

link_file(filename, title = nil, anchor = nil)

Links to an extra file

@param [String] filename the filename to link to @param [String] title the title of the link @param [String] anchor optional anchor @return [String] the link to the file @since 0.5.5

link_include_file(file)

Include a file as a docstring in output @since 0.7.0 @param [String] file the filename to include @return [String] the file‘s contents

link_include_object(object)

Includes an object‘s docstring into output. @since 0.6.0 @param [CodeObjects::Base] object the object to include @return [String] the object‘s docstring (no tags)

link_object(object, title = nil)

Links to an object with an optional title

@param [CodeObjects::Base] object the object to link to @param [String] title the title to use for the link @return [String] the linked object

link_url(url, title = nil, params = nil)

Links to a URL

@param [String] url the URL to link to @param [String] title the optional title to display the link as @param [Hash] params optional parameters for the link @return [String] the linked URL

linkify(*args)

Links objects or URLs. This method will delegate to the correct `link_` method depending on the arguments passed in.

@example Linking a URL

      linkify('http://example.com')

@example Including docstring contents of an object

      linkify('include:YARD::Docstring')

@example Linking to an extra file

      linkify('file:README')

@example Linking an object by path

      linkify('YARD::Docstring')

run_verifier(list)

Runs a list of objects against the {Verifier} object passed into the template and returns the subset of verified objects.

@param [Array<CodeObjects::Base>] list a list of code objects @return [Array<CodeObjects::Base>] a list of code objects that match

      the verifier. If no verifier is supplied, all objects are returned.

[Validate]