Class | Generators::RIGenerator |
In: |
generators/ri_generator.rb
|
Parent: | Object |
Generators may need to return specific subclasses depending on the options they are passed. Because of this we create them using a factory
# File generators/ri_generator.rb, line 59 59: def RIGenerator.for(options) 60: new(options) 61: end
Set up a new HTML generator. Basically all we do here is load up the correct output temlate
# File generators/ri_generator.rb, line 70 70: def initialize(options) #:not-new: 71: @options = options 72: @ri_writer = RI::RiWriter.new(options.op_dir) 73: @markup = SM::SimpleMarkup.new 74: @to_flow = SM::ToFlow.new 75: end
# File generators/ri_generator.rb, line 98 98: def generate_class_info(cls) 99: if cls === RDoc::NormalModule 100: cls_desc = RI::ModuleDescription.new 101: else 102: cls_desc = RI::ClassDescription.new 103: cls_desc.superclass = cls.superclass 104: end 105: cls_desc.name = cls.name 106: cls_desc.full_name = cls.full_name 107: cls_desc.comment = markup(cls.comment) 108: 109: cls_desc.attributes =cls.attributes.sort.map do |a| 110: RI::Attribute.new(a.name, a.rw, markup(a.comment)) 111: end 112: 113: cls_desc.constants = cls.constants.map do |c| 114: RI::Constant.new(c.name, c.value, markup(c.comment)) 115: end 116: 117: cls_desc.includes = cls.includes.map do |i| 118: RI::IncludedModule.new(i.name) 119: end 120: 121: class_methods, instance_methods = method_list(cls) 122: 123: cls_desc.class_methods = class_methods.map do |m| 124: RI::MethodSummary.new(m.name) 125: end 126: cls_desc.instance_methods = instance_methods.map do |m| 127: RI::MethodSummary.new(m.name) 128: end 129: 130: update_or_replace(cls_desc) 131: 132: class_methods.each do |m| 133: generate_method_info(cls_desc, m) 134: end 135: 136: instance_methods.each do |m| 137: generate_method_info(cls_desc, m) 138: end 139: end
# File generators/ri_generator.rb, line 142 142: def generate_method_info(cls_desc, method) 143: meth_desc = RI::MethodDescription.new 144: meth_desc.name = method.name 145: meth_desc.full_name = cls_desc.full_name 146: if method.singleton 147: meth_desc.full_name += "::" 148: else 149: meth_desc.full_name += "#" 150: end 151: meth_desc.full_name << method.name 152: 153: meth_desc.comment = markup(method.comment) 154: meth_desc.params = params_of(method) 155: meth_desc.visibility = method.visibility.to_s 156: meth_desc.is_singleton = method.singleton 157: meth_desc.block_params = method.block_params 158: 159: meth_desc.aliases = method.aliases.map do |a| 160: RI::AliasName.new(a.name) 161: end 162: 163: @ri_writer.add_method(cls_desc, meth_desc) 164: end