Method: Inventory::Rake::Tasks::YARD#initialize

Defined in:
lib/inventory-rake-tasks-yard-1.0.rb

#initialize(options = {}) {|?| ... } ⇒ YARD

Sets up a YARD task NAME, passing OPTIONS, on the files listed in INVENTORY or FILES, with GLOBALS set, optionally yields the task object for further customization, then #defines NAME.

The default for OPTIONS is:

--no-private --protected --private --query \
  "(!object.docstring.blank?&&object.docstring.line)||object.root?" \
--markup markdown --no-stats

This’ll make YARD output documentation for all public, protected, and private objects not markes as ‘@private` that have documentation that hasn’t been automatically generated or is the top-level namespace using Markdown as the markup format and not outputting any statistics at the end of execution.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :name (Symbol) — default: :html

    The name of the task to define

  • :options (Array<String, Array<String>>) — default:

    The options to pass to YARD; will be passed to ‘Shellwords.shelljoin`

  • :inventory (Inventory) — default: Inventory::Rake::Tasks.inventory

    The inventory to use for FILES default

  • :files (Array<String>) — default: FileList[ENV['FILES']] or inventory.lib_files

    The files to process

  • :globals (Hash) — default: {}

    The globals to pass to YARD

Yields:

  • (?)

Yield Parameters:

  • task (self)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/inventory-rake-tasks-yard-1.0.rb', line 50

def initialize(options = {})
  self.name = options.fetch(:name, :html)
  self.options = options.fetch(:options,
                               ['--no-private',
                                '--protected',
                                '--private',
                                ['--query', %w{'(!object.docstring.blank?&&object.docstring.line)||object.root?'}],
                                ['--markup', 'markdown'],
                                '--no-stats'])
  self.inventory = options.fetch(:inventory, Inventory::Rake::Tasks.inventory)
  self.files = options.fetch(:files){
    ENV.include?('FILES') ?
      FileList[ENV['FILES']] :
      (n = 0; inventory.lib_files.sort_by{ |e| [e.count('/'), n += 1] })
  }
  self.globals = options.fetch(:globals, {})
  yield self if block_given?
  define
end