123456789_123456789_123456789_123456789_123456789_

Class: YARD::CLI::YardoptsCommand Abstract

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Command
Instance Chain:
self, Command
Inherits: YARD::CLI::Command
Defined in: lib/yard/cli/yardopts_command.rb

Overview

This class is abstract.

Abstract base class for command that reads .yardopts file

Since:

  • 0.8.3

Constant Summary

Class Method Summary

Command - Inherited

.run

Helper method to run the utility on an instance.

Instance Attribute Summary

Instance Method Summary

Command - Inherited

Constructor Details

.newYardoptsCommand

Creates a new command that reads .yardopts

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 25

def initialize
  super
  @options_file = DEFAULT_YARDOPTS_FILE
  @use_yardopts_file = true
  @use_document_file = true
end

Instance Attribute Details

#options_fileString (rw)

The options file name (defaults to DEFAULT_YARDOPTS_FILE)

Returns:

  • (String)

    the filename to load extra options from

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 22

attr_accessor :options_file

#use_document_fileBoolean (rw)

Returns:

  • (Boolean)

    whether to parse options from .document

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 18

attr_accessor :use_document_file

#use_yardopts_fileBoolean (rw)

Returns:

  • (Boolean)

    whether to parse options from .yardopts

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 15

attr_accessor :use_yardopts_file

Instance Method Details

#parse_arguments(*args) ⇒ Boolean

Parses commandline arguments

Parameters:

Returns:

  • (Boolean)

    whether or not arguments are valid

Since:

  • 0.5.6

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 36

def parse_arguments(*args)
  parse_yardopts_options(*args)

  # Parse files and then command line arguments
  parse_rdoc_document_file
  parse_yardopts
  optparse(*args)
end

#parse_rdoc_document_file(file = '.document') (private)

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 92

def parse_rdoc_document_file(file = '.document')
  optparse(*support_rdoc_document_file!(file)) if use_document_file
end

#parse_yardopts(file = options_file) (private)

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 96

def parse_yardopts(file = options_file)
  optparse(*yardopts(file)) if use_yardopts_file
end

#parse_yardopts_options(*args) (private)

Parses out the yardopts/document options

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 78

def parse_yardopts_options(*args)
  opts = OptionParser.new
  opts.base.long.clear # HACK: why are --help and --version defined?
  yardopts_options(opts)
  begin
    opts.parse(args)
  rescue OptionParser::ParseError => err
    idx = args.index(err.args.first)
    args = args[(idx + 1)..-1]
    args.shift while args.first && args.first[0, 1] != '-'
    retry
  end
end

#support_rdoc_document_file!(file = '.document') ⇒ Array<String> (private)

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

Returns:

  • (Array<String>)

    an array of files parsed from .document

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 102

def support_rdoc_document_file!(file = '.document')
  return [] unless use_document_file
  File.read(file).gsub(/^[ \t]*#.+/m, '').split(/\s+/)
rescue Errno::ENOENT
  []
end

#yardopts(file = options_file) ⇒ Array<String> (private)

Parses the .yardopts file for default yard options

Returns:

  • (Array<String>)

    an array of options parsed from .yardopts

Since:

  • 0.8.3

[ GitHub ]

  
# File 'lib/yard/cli/yardopts_command.rb', line 70

def yardopts(file = options_file)
  return [] unless use_yardopts_file
  File.read_binary(file).shell_split
rescue Errno::ENOENT
  []
end