diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-10 01:57:22 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-10 01:57:22 +0000 |
commit | 09ac765b2f9e915ab5dead8c3b21aa5eb8748f62 (patch) | |
tree | f4926c381878079aca54585a0a8051ee4a305b42 /lib/rdoc/diagram.rb | |
parent | 40ca06cb4bd5f1a2f411648b6a2b8fc9b80916a5 (diff) |
Merged my changes from HEAD
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/diagram.rb')
-rw-r--r-- | lib/rdoc/diagram.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/rdoc/diagram.rb b/lib/rdoc/diagram.rb index bbaa704365..9fdc49c02e 100644 --- a/lib/rdoc/diagram.rb +++ b/lib/rdoc/diagram.rb @@ -38,6 +38,7 @@ module RDoc @options = options @counter = 0 File.makedirs(DOT_PATH) + @diagram_cache = {} end # Draw the diagrams. We traverse the files, drawing a diagram for @@ -55,7 +56,6 @@ module RDoc @local_names = find_names(i) @global_names = [] @global_graph = graph = DOT::DOTDigraph.new('name' => 'TopLevel', - 'label' => i.file_absolute_name, 'fontname' => FONT, 'fontsize' => '8', 'bgcolor' => 'lightcyan1', @@ -73,7 +73,7 @@ module RDoc end add_classes(i, graph, i.file_relative_name) - i.diagram = convert_to_png("f_#{file_count}", graph, i.name) + i.diagram = convert_to_png("f_#{file_count}", graph) # now go through and document each top level class and # module independently @@ -83,7 +83,6 @@ module RDoc @global_names = [] @global_graph = graph = DOT::DOTDigraph.new('name' => 'TopLevel', - 'label' => i.full_name, 'fontname' => FONT, 'fontsize' => '8', 'bgcolor' => 'lightcyan1', @@ -95,8 +94,7 @@ module RDoc 'fontsize' => 8) draw_module(mod, graph, true) mod.diagram = convert_to_png("m_#{file_count}_#{count}", - graph, - "Module: #{mod.name}") + graph) end end $stderr.puts unless @options.quiet @@ -280,7 +278,9 @@ module RDoc end - def convert_to_png(file_base, graph, name) + def convert_to_png(file_base, graph) + str = graph.to_s + return @diagram_cache[str] if @diagram_cache[str] op_type = Options.instance.image_format dotfile = File.join(DOT_PATH, file_base) src = dotfile + ".dot" @@ -292,7 +292,7 @@ module RDoc end File.open(src, 'w+' ) do |f| - f << graph.to_s << "\n" + f << str << "\n" end system "dot", "-T#{op_type}", src, "-o", dot @@ -300,7 +300,9 @@ module RDoc # Now construct the imagemap wrapper around # that png - return wrap_in_image_map(src, dot, name) + ret = wrap_in_image_map(src, dot) + @diagram_cache[str] = ret + return ret end # Extract the client-side image map from dot, and use it @@ -308,7 +310,7 @@ module RDoc # <map>..<img> combination, suitable for inclusion on # the page - def wrap_in_image_map(src, dot, name) + def wrap_in_image_map(src, dot) res = %{<map id="map" name="map">\n} dot_map = `dot -Tismap #{src}` dot_map.each do |area| @@ -326,7 +328,7 @@ module RDoc res << "</map>\n" # map_file = src.sub(/.dot/, '.map') # system("dot -Timap #{src} -o #{map_file}") - res << %{<img src="#{dot}" usemap="#map" border="0" alt="#{name}" />} + res << %{<img src="#{dot}" usemap="#map" border="0" alt="#{dot}">} return res end end |