Class: YARD::CLI::Graph

Inherits:
YardoptsCommand show all
Defined in:
lib/yard/cli/graph.rb

Overview

A command-line utility to generate Graphviz graphs from a set of objects

See Also:

Since:

  • 0.6.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGraph

Creates a new instance of the command-line utility

Since:

  • 0.6.0



33
34
35
36
37
38
39
# File 'lib/yard/cli/graph.rb', line 33

def initialize
  super
  @use_document_file = false
  @options = GraphOptions.new
  options.reset_defaults
  options.serializer = YARD::Serializers::StdoutSerializer.new
end

Instance Attribute Details

#objectsObject (readonly)

The set of objects to include in the graph.

Since:

  • 0.6.0



30
31
32
# File 'lib/yard/cli/graph.rb', line 30

def objects
  @objects
end

#optionsObject (readonly)

The options parsed out of the commandline. Default options are:

:format => :dot

Since:

  • 0.6.0



27
28
29
# File 'lib/yard/cli/graph.rb', line 27

def options
  @options
end

Instance Method Details

#descriptionObject

Since:

  • 0.6.0



41
42
43
# File 'lib/yard/cli/graph.rb', line 41

def description
  "Graphs class diagram using Graphviz"
end

#run(*args) ⇒ Object

Runs the command-line utility.

Examples:

grapher = Graph.new
grapher.run('--private')

Parameters:

Since:

  • 0.6.0



51
52
53
54
55
56
57
58
59
60
# File 'lib/yard/cli/graph.rb', line 51

def run(*args)
  parse_arguments(*args)

  contents = objects.map do |o|
    o.format(options.merge(:serialize => false))
  end.join("\n")
  opts = {:type => :layout, :contents => contents}
  options.update(opts)
  Templates::Engine.render(options)
end