require 'pp'
require_relative 'docparser'

$classes = parse_any_path 'src'

def prefix lines
	if lines.empty?
		''
	else
		lines.gsub(/^/, '- ')
	end
end

def find_class klass_name
	$classes.find{|c| c[:name] == klass_name }
end

def describe klass_name
	out = []
	out << klass_name
	klass = find_class klass_name
	if klass
		if klass[:parent]
			out.push prefix describe klass[:parent]
		end
		if klass[:mixins]
			klass[:mixins].each do |mixin|
				out.push prefix describe mixin
			end
		end
	end
	out.select{|a| !a.empty? }.join "\n"
end

$classes.sort_by!{|klass|
	# sort by "type" first (widget/layout/element/etc.), then by name
	klass[:name].split(/(?=Layout|Widget|Element|Dialog|Tool|Theme)/).reverse
}

$classes.each{|klass|
	puts describe klass[:name]
}

Add a script to print the dependency tree of everything
Add a script to print the dependency tree of everything

The usefullness of this is limited, since it only takes into account
the documented inheritance and mixins, but not currently undocumented
composition (e.g. DropdownInputWidget using DropdownWidget).

Change-Id: I1f002ba37cb6abd388622638eeccc5aaf9a782a4
