class YARD::CLI::Graph
@since 0.6.0
@see Graph#run
a set of objects
A command-line utility to generate Graphviz graphs from
def description
def description "Graphs class diagram using Graphviz" end
def initialize
def initialize super @use_document_file = false @options = GraphOptions.new options.reset_defaults options.serializer = YARD::Serializers::StdoutSerializer.new end
def optparse(*args)
-
args
(Array
) -- each tokenized argument
def optparse(*args) visibilities = [:public] opts = OptionParser.new opts.separator "" opts.separator "General Options:" opts.on('-b', '--db FILE', 'Use a specified .yardoc db to load from or save to. (defaults to .yardoc)') do |yfile| YARD::Registry.yardoc_file = yfile end opts.on('--full', 'Full class diagrams (show methods and attributes).') do options[:full] = true end opts.on('-d', '--dependencies', 'Show mixins in dependency graph.') do options[:dependencies] = true end opts.on('--no-public', "Don't show public methods. (default shows public)") do visibilities.delete(:public) end opts.on('--protected', "Show or don't show protected methods. (default hides protected)") do visibilities.push(:protected) end opts.on('--private', "Show or don't show private methods. (default hides private)") do visibilities.push(:private) end opts.separator "" opts.separator "Output options:" opts.on('--dot [OPTIONS]', 'Send the results directly to `dot` with optional arguments.') do |dotopts| options.serializer = Serializers::ProcessSerializer.new('dot ' + dotopts.to_s) end opts.on('-f', '--file [FILE]', 'Writes output to a file instead of stdout.') do |file| options.serializer = Serializers::FileSystemSerializer.new(:basepath => '.', :extension => nil) options.serializer.instance_eval "def serialized_path(object) #{file.inspect} end" end common_options(opts) parse_options(opts, args) Registry.load expression = "#{visibilities.uniq.inspect}.include?(object.visibility)" options.verifier = Verifier.new(expression) @objects = args.first ? args.map {|o| Registry.at(o) }.compact : [Registry.root] end
def run(*args)
-
args
(Array
) -- each tokenized argument
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
def unrecognized_option(err) end
def unrecognized_option(err) end