Sha256: 9ae28cd5d61f2d1fcb188acca03e8bc48ac2699ac52520f88b7d69ca4585deac

Contents?: true

Size: 1.11 KB

Versions: 31

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby

# For running when gem not installed
$:.unshift File.dirname(File.dirname(__FILE__)) + "/lib"

require "rubygems"
require "pp"
require "jsduck/json_duck"

def with_each_class(dir)
  Dir[dir+"/*.json"].each do |filename|
    yield JsDuck::JsonDuck.read(filename)
  end
end

def quote(a)
  '"'+a+'"'
end

def arrow(a, b, opts="")
  "  #{quote(a)}->#{quote(b)} #{opts};"
end

input_dir = ARGV[0]

# Build a map that links each classname or alternate classname to its
# canonical form
$canonical_map = {}
with_each_class(input_dir) do |cls|
  $canonical_map[cls["name"]] = cls["name"]
  cls["alternateClassNames"].each do |name|
    $canonical_map[name] = cls["name"]
  end
end

def canonical(name)
  $canonical_map[name] || name
end

# Print out the graph description
puts 'digraph G {'
puts 'rankdir=LR;'
with_each_class(input_dir) do |cls|
  if cls["extends"] && cls["extends"] != "Object"
    puts arrow(canonical(cls["extends"]), cls['name'], '[style=bold,weight=10]')
  end
  if cls["mixins"]
    cls["mixins"].each {|mx| puts arrow(canonical(mx), cls['name'], '[weight=1,style=dashed]') }
  end
end
puts '}'

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
jsduck-5.0.0 bin/graph
jsduck-5.0.0.beta5 bin/graph
jsduck-5.0.0.beta4 bin/graph
jsduck-4.10.4 bin/graph
jsduck-5.0.0.beta3 bin/graph
jsduck-4.10.3 bin/graph
jsduck-4.10.2 bin/graph
jsduck-4.10.1 bin/graph
jsduck-4.10.0 bin/graph
jsduck-4.9.0 bin/graph
jsduck-4.8.0 bin/graph
jsduck-5.0.0.beta2 bin/graph
jsduck-4.7.1 bin/graph
jsduck-4.7.0 bin/graph
jsduck-5.0.0.beta01 bin/graph
jsduck-4.6.2 bin/graph
jsduck-4.6.1 bin/graph
jsduck-4.6.0 bin/graph
jsduck-4.5.1 bin/graph
jsduck-4.5.0 bin/graph