# We're responsible for generating all the HTML files # from the object tree defined in code_objects.rb. We # generate: # # [files] an html file for each input file given. These # input files appear as objects of class # TopLevel # # [classes] an html file for each class or module encountered. # These classes are not grouped by file: if a file # contains four classes, we'll generate an html # file for the file itself, and four html files # for the individual classes. # # [indices] we generate three indices for files, classes, # and methods. These are displayed in a browser # like window with three index panes across the # top and the selected description below # # Method descriptions appear in whatever entity (file, class, # or module) that contains them. # # We generate files in a structure below a specified subdirectory, # normally +doc+. # # opdir # | # |___ files # | |__ per file summaries # | # |___ classes # |__ per class/module descriptions # # HTML is generated using the Template class. # require 'ftools' require 'rdoc/options' require 'rdoc/template' require 'rdoc/markup/simple_markup' require 'rdoc/markup/simple_markup/to_flow' require 'cgi' require 'rdoc/ri/ri_cache' require 'rdoc/ri/ri_reader' require 'rdoc/ri/ri_writer' require 'rdoc/ri/ri_descriptions' module Generators class RIGenerator # Generators may need to return specific subclasses depending # on the options they are passed. Because of this # we create them using a factory def RIGenerator.for(options) new(options) end class <\s*)[^\#]/ content = comment else content = comment.gsub(/^\s*(#+)/) { $1.tr('#',' ') } end @markup.convert(content, @to_flow) end # By default we replace existing classes with the # same name. If the --merge option was given, we instead # merge this definition into an existing class. We add # our methods, aliases, etc to that class, but do not # change the class's description. def update_or_replace(cls_desc) old_cls = nil if @options.merge rdr = RI::RiReader.new(RI::RiCache.new(@options.op_dir)) namespace = rdr.top_level_namespace namespace = rdr.lookup_namespace_in(cls_desc.name, namespace) if namespace.empty? raise RiError.new("Nothing known about #{arg}") else old_cls = namespace[0] end end if old_cls.nil? # no merge: simply overwrite @ri_writer.remove_class(cls_desc) @ri_writer.add_class(cls_desc) else # existing class: merge in old_desc = rdr.get_class(old_cls) old_desc.merge_in(cls_desc) @ri_writer.add_class(old_desc) end end end end