Class: YARD::CLI::Display
- Inherits:
-
Yardoc
- Object
- Command
- YardoptsCommand
- Yardoc
- YARD::CLI::Display
- Defined in:
- lib/yard/cli/display.rb
Overview
Display one object
Constant Summary
Instance Attribute Summary collapse
-
#apis ⇒ Array<String>
inherited
from Yardoc
Keep track of which APIs are to be shown.
-
#assets ⇒ Array<String>
inherited
from Yardoc
A list of assets to copy after generation.
-
#excluded ⇒ Array<String>
inherited
from Yardoc
List of excluded paths (regexp matches).
-
#files ⇒ Array<String>
inherited
from Yardoc
List of Ruby source files to process.
-
#generate ⇒ Boolean
inherited
from Yardoc
Whether to generate output.
-
#has_markup ⇒ Boolean
inherited
from Yardoc
Whether markup option was specified.
-
#hidden_apis ⇒ Array<String>
inherited
from Yardoc
Keep track of which APIs are to be hidden.
-
#hidden_tags ⇒ Array<Symbol>
inherited
from Yardoc
A list of tags to hide from templates.
-
#list ⇒ Boolean
inherited
from Yardoc
Whether to print a list of objects.
-
#options ⇒ Hash
inherited
from Yardoc
readonly
The hash of options passed to the template.
-
#options_file ⇒ String
inherited
from YardoptsCommand
The options file name (defaults to YardoptsCommand::DEFAULT_YARDOPTS_FILE).
-
#save_yardoc ⇒ Boolean
inherited
from Yardoc
Whether objects should be serialized to .yardoc db.
-
#statistics ⇒ Boolean
inherited
from Yardoc
Whether to print statistics after parsing.
-
#use_cache ⇒ Boolean
inherited
from Yardoc
Whether to use the existing yardoc db if the .yardoc already exists.
-
#use_document_file ⇒ Boolean
inherited
from YardoptsCommand
Whether to parse options from .document.
-
#use_yardopts_file ⇒ Boolean
inherited
from YardoptsCommand
Whether to parse options from .yardopts.
-
#visibilities ⇒ Array<Symbol>
inherited
from Yardoc
Keep track of which visibilities are to be shown.
Instance Method Summary collapse
- #description ⇒ Object
-
#format_objects ⇒ String
The output data for all formatted objects.
-
#initialize(*args) ⇒ Display
constructor
A new instance of Display.
- #output_options(opts) ⇒ Object
-
#parse_arguments(*args) ⇒ Object
Parses commandline options.
-
#run(*args) ⇒ void
Runs the commandline utility, parsing arguments and displaying an object from the Registry.
- #wrap_layout(contents) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Display
Returns a new instance of Display
8 9 10 11 12 13 |
# File 'lib/yard/cli/display.rb', line 8 def initialize(*args) super .format = :text # default for this command @layout = nil @objects = [] end |
Instance Attribute Details
#assets ⇒ Array<String> Originally defined in class Yardoc
Returns a list of assets to copy after generation
#excluded ⇒ Array<String> Originally defined in class Yardoc
Returns list of excluded paths (regexp matches)
#files ⇒ Array<String> Originally defined in class Yardoc
Returns list of Ruby source files to process
#generate ⇒ Boolean Originally defined in class Yardoc
Returns whether to generate output
#has_markup ⇒ Boolean Originally defined in class Yardoc
Returns whether markup option was specified
#hidden_apis ⇒ Array<String> Originally defined in class Yardoc
Keep track of which APIs are to be hidden
#hidden_tags ⇒ Array<Symbol> Originally defined in class Yardoc
Returns a list of tags to hide from templates
#list ⇒ Boolean Originally defined in class Yardoc
Returns whether to print a list of objects
#options ⇒ Hash (readonly) Originally defined in class Yardoc
Returns the hash of options passed to the template.
#options_file ⇒ String Originally defined in class YardoptsCommand
The options file name (defaults to DEFAULT_YARDOPTS_FILE)
#save_yardoc ⇒ Boolean Originally defined in class Yardoc
Returns whether objects should be serialized to .yardoc db
#statistics ⇒ Boolean Originally defined in class Yardoc
Returns whether to print statistics after parsing
#use_cache ⇒ Boolean Originally defined in class Yardoc
Returns whether to use the existing yardoc db if the .yardoc already exists. Also makes use of file checksums to parse only changed files.
#use_document_file ⇒ Boolean Originally defined in class YardoptsCommand
Returns whether to parse options from .document
#use_yardopts_file ⇒ Boolean Originally defined in class YardoptsCommand
Returns whether to parse options from .yardopts
Instance Method Details
#description ⇒ Object
6 |
# File 'lib/yard/cli/display.rb', line 6 def description; 'Displays a formatted object' end |
#format_objects ⇒ String
Returns the output data for all formatted objects
26 27 28 29 30 |
# File 'lib/yard/cli/display.rb', line 26 def format_objects @objects.inject([]) do |arr, obj| arr.push obj.format() end.join("\n") end |
#output_options(opts) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/yard/cli/display.rb', line 60 def (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) ⇒ Object
Parses commandline options.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/yard/cli/display.rb', line 45 def parse_arguments(*args) opts = OptionParser.new opts. = "Usage: yard display [options] OBJECT [OTHER OBJECTS]" (opts) (opts) (opts, args) Registry.load @objects = args.map {|o| Registry.at(o) } # validation return false if @objects.any? {|o| o.nil? } end |
#run(*args) ⇒ void
This method returns an undefined value.
Runs the commandline utility, parsing arguments and displaying an object from the Registry.
20 21 22 23 |
# File 'lib/yard/cli/display.rb', line 20 def run(*args) return unless parse_arguments(*args) log.puts wrap_layout(format_objects) end |
#wrap_layout(contents) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yard/cli/display.rb', line 32 def wrap_layout(contents) return contents unless @layout opts = .merge( :contents => contents, :object => @objects.first, :objects => @objects ) args = [.template, @layout, .format] Templates::Engine.template(*args).run(opts) end |