Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # Output a DOT file of the include structure of a project
- #
- # Usage:
- # cd <the include path of the project>
- # <path of this script>/make-include-graph.rb > includes.dot
- require 'find'
- def output_edges(path)
- File.open(path) do |f|
- f.each_line do |line|
- match = line.match(/^\s*#\s*include\s*[<"](.*)[">]/)
- if match
- puts "\t\"#{path}\" -> \"#{match[1]}\";"
- end
- end
- end
- end
- puts 'digraph includes {'
- Find.find('.') do |path|
- unless FileTest.directory?(path)
- path = path[2..-1]
- output_edges(path)
- end
- end
- puts '}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement