123456789_123456789_123456789_123456789_123456789_

Class: YARD::CLI::Display

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: YARD::CLI::Yardoc
Defined in: lib/yard/cli/display.rb

Overview

Display one object

Since:

  • 0.8.6

Constant Summary

YardoptsCommand - Inherited

DEFAULT_YARDOPTS_FILE

Class Method Summary

Yardoc - Inherited

.new

Creates a new instance of the commandline utility.

YardoptsCommand - Inherited

.new

Creates a new command that reads .yardopts.

Command - Inherited

.run

Helper method to run the utility on an instance.

Instance Attribute Summary

Yardoc - Inherited

#apis

Keep track of which APIs are to be shown.

#assets, #excluded, #fail_on_warning, #files, #generate, #has_markup,
#hidden_apis

Keep track of which APIs are to be hidden.

#hidden_tags, #list, #options, #save_yardoc, #statistics, #use_cache,
#visibilities

Keep track of which visibilities are to be shown.

YardoptsCommand - Inherited

#options_file

The options file name (defaults to DEFAULT_YARDOPTS_FILE).

#use_document_file, #use_yardopts_file

Instance Method Summary

Yardoc - Inherited

#all_objects

The list of all objects to process.

#description,
#parse_arguments

Parses commandline arguments.

#run

Runs the commandline utility, parsing arguments and generating output if set.

#add_api_verifier

Adds verifier rule for APIs.

#add_extra_files

Adds a set of extra documentation files to be processed.

#add_tag,
#add_visibility_verifier

Adds verifier rule for visibilities.

#apply_locale

Applies the specified locale to collected objects.

#copy_assets

Copies any assets to the output directory.

#extra_file_valid?,
#general_options

Adds general options.

#optparse

Parses commandline options.

#output_options

Adds output options.

#parse_files

Parses the file arguments into Ruby files and extra files, which are separated by a '-' element.

#print_list

Prints a list of all objects.

#run_generate

Generates output for objects.

#run_verifier

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

#tag_options

Adds tag options.

#verify_markup_options

Verifies that the markup options are valid before parsing any code.

YardoptsCommand - Inherited

#parse_arguments

Parses commandline arguments.

#parse_rdoc_document_file, #parse_yardopts,
#parse_yardopts_options

Parses out the yardopts/document options.

#support_rdoc_document_file!

Reads a .document file in the directory to get source file globs.

#yardopts

Parses the .yardopts file for default yard options.

Command - Inherited

Constructor Details

.new(*args) ⇒ Display

Since:

  • 0.8.6

[ GitHub ]

  
# File 'lib/yard/cli/display.rb', line 9

def initialize(*args)
  super
  options.format = :text # default for this command
  @layout = nil
  @objects = []
end

Instance Method Details

#description

Since:

  • 0.8.6

[ GitHub ]

  
# File 'lib/yard/cli/display.rb', line 7

def description; 'Displays a formatted object' end

#format_objectsString

Returns:

  • (String)

    the output data for all formatted objects

Since:

  • 0.8.6

[ GitHub ]

  
# File 'lib/yard/cli/display.rb', line 27

def format_objects
  @objects.inject([]) do |arr, obj|
    arr.push obj.format(options)
  end.join("\n")
end

#output_options(opts)

Since:

  • 0.8.6

[ GitHub ]

  
# File 'lib/yard/cli/display.rb', line 61

def output_options(opts)
  super(opts)
  opts.on('-l', '--layout [LAYOUT]', 'Wraps output in layout template (good for HTML)') do |layout|
    @layout = layout || 'layout'
  end
end

#parse_arguments(*args)

Parses commandline options.

Parameters:

Since:

  • 0.8.6

[ GitHub ]

  
# File 'lib/yard/cli/display.rb', line 46

def parse_arguments(*args)
  opts = OptionParser.new
  opts.banner = "Usage: yard display [options] OBJECT [OTHER OBJECTS]"
  general_options(opts)
  output_options(opts)
  parse_options(opts, args)

  Registry.load
  @objects = args.map {|o| Registry.at(o) }

  # validation
  return false if @objects.any?(&:nil?)
  verify_markup_options
end

#run(*args) ⇒ void

This method returns an undefined value.

Runs the commandline utility, parsing arguments and displaying an object from the ::YARD::Registry.

Parameters:

Since:

  • 0.8.6

[ GitHub ]

  
# File 'lib/yard/cli/display.rb', line 21

def run(*args)
  return unless parse_arguments(*args)
  log.puts wrap_layout(format_objects)
end

#wrap_layout(contents)

Since:

  • 0.8.6

[ GitHub ]

  
# File 'lib/yard/cli/display.rb', line 33

def wrap_layout(contents)
  return contents unless @layout
  opts = options.merge(
    :contents => contents,
    :object => @objects.first,
    :objects => @objects
  )
  args = [options.template, @layout, options.format]
  Templates::Engine.template(*args).run(opts)
end