From: Nikolai Lugovoi Date: 2009-09-13T06:47:00+09:00 Subject: Re: Ruby 1.9 rdoc never ends (Re: rdoc) On Sat, Sep 12, 2009 at 7:08 PM, James Britt wrote: > I've been running rdoc over the 1.9 source tree, and if I omit the lib and > ext dirs it runs very quickly, but if I try to rdoc everything it just eats > memory, and after an hour or 2 I just kill it. > > >> My RDoc version is 2.3.0 and I'm using the hanna template. By the way, I >> did this with the 1.9 RDoc gem. >> > > I'm trying to use the rdoc the ships with 1.9, which (presumably) should > work fine. > > ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin9.7.0] > Hi, I see same problem using rdoc from ruby 1.9.2dev (2009-09-13 trunk 24877) -- memory got about 2 gigs after 25 or so minutes, so i killed process. And then, just of curiosity, I tried to reduce some sort operations, and as result I got it well running, I think: with patch: about ~120Mb memory used Generating HTML... Files: 522 Classes: 1370 Modules: 575 Methods: 7896 Elapsed: 357.5s diff --git a/lib/rdoc/generator.rb b/lib/rdoc/generator.rb index 86196b4..ca4144a 100644 --- a/lib/rdoc/generator.rb +++ b/lib/rdoc/generator.rb @@ -203,7 +203,7 @@ module RDoc::Generator @methods = list.collect do |m| RDoc::Generator::Method.new m, self, @options - end + end.sort end ## @@ -212,7 +212,7 @@ module RDoc::Generator def build_method_summary_list(path_prefix = "") collect_methods unless @methods - @methods.sort.map do |meth| + @methods.map do |meth| { "name" => CGI.escapeHTML(meth.name), "aref" => "##{meth.aref}" @@ -320,7 +320,7 @@ module RDoc::Generator def build_method_detail_list(section) outer = [] - methods = @methods.sort.select do |m| + methods = @methods.select do |m| m.document_self and m.section == section end @@ -543,6 +543,9 @@ module RDoc::Generator @template::METHOD_LIST) template.write_html_on(f, @values) + @values['file_list'] = nil + @values['class_list'] = nil + @values['method_list'] = nil end def value_hash @@ -785,6 +788,10 @@ module RDoc::Generator @template::METHOD_LIST) template.write_html_on(f, @values) + + @values['file_list'] = nil + @values['class_list'] = nil + @values['method_list'] = nil end def file_attribute_values diff --git a/lib/rdoc/generator/html.rb b/lib/rdoc/generator/html.rb index 60e0c17..0d7b49d 100644 --- a/lib/rdoc/generator/html.rb +++ b/lib/rdoc/generator/html.rb @@ -212,17 +212,20 @@ class RDoc::Generator::HTML class_list = {} method_list = {} prev_op_dir = nil + sf = @files.sort + sc = @classes.sort + sm = RDoc::Generator::Method.all_methods.sort - list.each do |item| + list.sort.each do |item| next unless item.document_self op_file = item.path op_dir = File.dirname(op_file) if(op_dir != prev_op_dir) - file_list = index_to_links op_file, @files - class_list = index_to_links op_file, @classes - method_list = index_to_links op_file, RDoc::Generator::Method.all_methods + file_list = index_to_links op_file, sf, true + class_list = index_to_links op_file, sc, true + method_list = index_to_links op_file, sm, true end prev_op_dir = op_dir @@ -323,8 +326,8 @@ class RDoc::Generator::HTML end end - def index_to_links(output_path, collection) - collection.sort.map do |f| + def index_to_links(output_path, collection, sorted = false) + (sorted ? collection : collection.sort).map do |f| next unless f.document_self { "href" => RDoc::Markup::ToHtml.gen_relative_url(output_path, f.path), "name" => f.index_name }