Parent

Included Modules

Generators::MERBGenerator

Public Class Methods

for(options) click to toggle source

Generators may need to return specific subclasses depending on the options they are passed. Because of this we create them using a factory

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1137
1137:         def MERBGenerator.for(options)
1138:             AllReferences::reset
1139:             HtmlMethod::reset
1140: 
1141:             MERBGenerator.new(options)
1142: 
1143:         end
for(options) click to toggle source

Generators may need to return specific subclasses depending on the options they are passed. Because of this we create them using a factory

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1137
1137:         def MERBGenerator.for(options)
1138:             AllReferences::reset
1139:             HtmlMethod::reset
1140: 
1141:             MERBGenerator.new(options)
1142: 
1143:         end
new(options) click to toggle source

Set up a new HTML generator. Basically all we do here is load up the correct output temlate

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1152
1152:         def initialize(options) #:not-new:
1153:             @options    = options
1154:             load_html_template
1155:         end

Protected Class Methods

new(options) click to toggle source

Set up a new HTML generator. Basically all we do here is load up the correct output temlate

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1152
1152:         def initialize(options) #:not-new:
1153:             @options    = options
1154:             load_html_template
1155:         end

Public Instance Methods

generate(toplevels) click to toggle source

Build the initial indices and output objects based on an array of TopLevel objects containing the extracted information.

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1163
1163:         def generate(toplevels)
1164:             @toplevels  = toplevels
1165:             @files      = []
1166:             @classes    = []
1167: 
1168:             write_style_sheet
1169:             write_javascript
1170:             gen_sub_directories()
1171:             build_indices
1172:             generate_html
1173:         end
generate(toplevels) click to toggle source

Build the initial indices and output objects based on an array of TopLevel objects containing the extracted information.

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1163
1163:         def generate(toplevels)
1164:             @toplevels  = toplevels
1165:             @files      = []
1166:             @classes    = []
1167: 
1168:             write_style_sheet
1169:             write_javascript
1170:             gen_sub_directories()
1171:             build_indices
1172:             generate_html
1173:         end

Private Instance Methods

build_class_list(from, html_file, class_dir) click to toggle source
      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1254
1254:         def build_class_list(from, html_file, class_dir)
1255:             @classes << HtmlClass.new(from, html_file, class_dir, @options)
1256:             from.each_classmodule do |mod|
1257:                 build_class_list(mod, html_file, class_dir)
1258:             end
1259:         end
build_class_list(from, html_file, class_dir) click to toggle source
      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1254
1254:         def build_class_list(from, html_file, class_dir)
1255:             @classes << HtmlClass.new(from, html_file, class_dir, @options)
1256:             from.each_classmodule do |mod|
1257:                 build_class_list(mod, html_file, class_dir)
1258:             end
1259:         end
build_indices() click to toggle source

Generate:

  • a list of HtmlFile objects for each TopLevel object.

  • a list of HtmlClass objects for each first level class or module in the TopLevel objects

  • a complete list of all hyperlinkable terms (file, class, module, and method names)

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1243
1243:         def build_indices
1244: 
1245:             @toplevels.each do |toplevel|
1246:                 @files << HtmlFile.new(toplevel, @options, FILE_DIR)
1247:             end
1248: 
1249:             RDoc::TopLevel.all_classes_and_modules.each do |cls|
1250:                 build_class_list(cls, @files[0], CLASS_DIR)
1251:             end
1252:         end
build_indices() click to toggle source

Generate:

  • a list of HtmlFile objects for each TopLevel object.

  • a list of HtmlClass objects for each first level class or module in the TopLevel objects

  • a complete list of all hyperlinkable terms (file, class, module, and method names)

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1243
1243:         def build_indices
1244: 
1245:             @toplevels.each do |toplevel|
1246:                 @files << HtmlFile.new(toplevel, @options, FILE_DIR)
1247:             end
1248: 
1249:             RDoc::TopLevel.all_classes_and_modules.each do |cls|
1250:                 build_class_list(cls, @files[0], CLASS_DIR)
1251:             end
1252:         end
gen_an_index(collection, title, template, filename) click to toggle source
      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1308
1308:         def gen_an_index(collection, title, template, filename)
1309:             template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
1310:             res = []
1311:             collection.sort.each do |f|
1312:                 if f.document_self
1313:                     res << { "href" => f.path, "name" => f.name, "scope" => f.scope, "seq_id" => f.seq }
1314:                 end
1315:             end
1316: 
1317:             values = {
1318:                 "entries"    => res,
1319:                 'list_title' => CGI.escapeHTML(title),
1320:                 'index_url'  => main_url,
1321:                 'charset'    => @options.charset,
1322:                 'style_url'  => style_url('', @options.css),
1323:             }
1324: 
1325:             File.open(filename, "w") do |f|
1326:                 template.write_html_on(f, values)
1327:             end
1328:         end
gen_an_index(collection, title, template, filename) click to toggle source
      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1308
1308:         def gen_an_index(collection, title, template, filename)
1309:             template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
1310:             res = []
1311:             collection.sort.each do |f|
1312:                 if f.document_self
1313:                     res << { "href" => f.path, "name" => f.name, "scope" => f.scope, "seq_id" => f.seq }
1314:                 end
1315:             end
1316: 
1317:             values = {
1318:                 "entries"    => res,
1319:                 'list_title' => CGI.escapeHTML(title),
1320:                 'index_url'  => main_url,
1321:                 'charset'    => @options.charset,
1322:                 'style_url'  => style_url('', @options.css),
1323:             }
1324: 
1325:             File.open(filename, "w") do |f|
1326:                 template.write_html_on(f, values)
1327:             end
1328:         end
gen_class_index() click to toggle source
      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1295
1295:         def gen_class_index
1296:             gen_an_index(@classes, 'Classes',
1297:             RDoc::Page::CLASS_INDEX,
1298:             "fr_class_index.html")
1299:         end
gen_class_index() click to toggle source
      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1295
1295:         def gen_class_index
1296:             gen_an_index(@classes, 'Classes',
1297:             RDoc::Page::CLASS_INDEX,
1298:             "fr_class_index.html")
1299:         end
gen_file_index() click to toggle source
      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1289
1289:         def gen_file_index
1290:             gen_an_index(@files, 'Files', 
1291:             RDoc::Page::FILE_INDEX, 
1292:             "fr_file_index.html")
1293:         end
gen_file_index() click to toggle source
      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1289
1289:         def gen_file_index
1290:             gen_an_index(@files, 'Files', 
1291:             RDoc::Page::FILE_INDEX, 
1292:             "fr_file_index.html")
1293:         end
gen_into(list) click to toggle source
      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1278
1278:         def gen_into(list)
1279:             list.each do |item|
1280:                 if item.document_self
1281:                     op_file = item.path
1282:                     File.makedirs(File.dirname(op_file))
1283:                     File.open(op_file, "w") { |file| item.write_on(file) }
1284:                 end
1285:             end
1286: 
1287:         end
gen_into(list) click to toggle source
      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1278
1278:         def gen_into(list)
1279:             list.each do |item|
1280:                 if item.document_self
1281:                     op_file = item.path
1282:                     File.makedirs(File.dirname(op_file))
1283:                     File.open(op_file, "w") { |file| item.write_on(file) }
1284:                 end
1285:             end
1286: 
1287:         end
gen_main_index() click to toggle source

The main index page is mostly a template frameset, but includes the initial page. If the --main option was given, we use this as our main page, otherwise we use the first file specified on the command line.

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1335
1335:         def gen_main_index
1336:             template = TemplatePage.new(RDoc::Page::INDEX)
1337:             File.open("index.html", "w") do |f|
1338:                 tStr = ""
1339:                 #File.open(main_url, 'r') do |g|
1340:                 #    tStr = markup(g)
1341:                 #end
1342:                 values = {
1343:                     "initial_page" => tStr,
1344:                     'title'        => CGI.escapeHTML(@options.title),
1345:                     'charset'      => @options.charset,
1346:                     'content'      => File.read('files/README.html')
1347:                 }
1348:             
1349:                 values['inline_source'] = true
1350:                 template.write_html_on(f, values)
1351:             end
1352:         end
gen_main_index() click to toggle source

The main index page is mostly a template frameset, but includes the initial page. If the --main option was given, we use this as our main page, otherwise we use the first file specified on the command line.

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1335
1335:         def gen_main_index
1336:             template = TemplatePage.new(RDoc::Page::INDEX)
1337:             File.open("index.html", "w") do |f|
1338:                 tStr = ""
1339:                 #File.open(main_url, 'r') do |g|
1340:                 #    tStr = markup(g)
1341:                 #end
1342:                 values = {
1343:                     "initial_page" => tStr,
1344:                     'title'        => CGI.escapeHTML(@options.title),
1345:                     'charset'      => @options.charset,
1346:                     'content'      => File.read('files/README.html')
1347:                 }
1348:             
1349:                 values['inline_source'] = true
1350:                 template.write_html_on(f, values)
1351:             end
1352:         end
gen_method_index() click to toggle source
      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1301
1301:         def gen_method_index
1302:             gen_an_index(HtmlMethod.all_methods, 'Methods', 
1303:             RDoc::Page::METHOD_INDEX,
1304:             "fr_method_index.html")
1305:         end
gen_method_index() click to toggle source
      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1301
1301:         def gen_method_index
1302:             gen_an_index(HtmlMethod.all_methods, 'Methods', 
1303:             RDoc::Page::METHOD_INDEX,
1304:             "fr_method_index.html")
1305:         end
gen_sub_directories() click to toggle source

See the comments at the top for a description of the directory structure

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1227
1227:         def gen_sub_directories
1228:             File.makedirs(FILE_DIR, CLASS_DIR)
1229:         rescue 
1230:             $stderr.puts $!.message
1231:             exit 1
1232:         end
gen_sub_directories() click to toggle source

See the comments at the top for a description of the directory structure

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1227
1227:         def gen_sub_directories
1228:             File.makedirs(FILE_DIR, CLASS_DIR)
1229:         rescue 
1230:             $stderr.puts $!.message
1231:             exit 1
1232:         end
generate_html() click to toggle source

Generate all the HTML

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1264
1264:         def generate_html
1265:             # the individual descriptions for files and classes
1266:             gen_into(@files)
1267:             gen_into(@classes)
1268:             # and the index files
1269:             gen_file_index
1270:             gen_class_index
1271:             gen_method_index
1272:             gen_main_index
1273: 
1274:             # this method is defined in the template file
1275:             write_extra_pages if defined? write_extra_pages
1276:         end
generate_html() click to toggle source

Generate all the HTML

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1264
1264:         def generate_html
1265:             # the individual descriptions for files and classes
1266:             gen_into(@files)
1267:             gen_into(@classes)
1268:             # and the index files
1269:             gen_file_index
1270:             gen_class_index
1271:             gen_method_index
1272:             gen_main_index
1273: 
1274:             # this method is defined in the template file
1275:             write_extra_pages if defined? write_extra_pages
1276:         end
load_html_template() click to toggle source

Load up the AJAX HTML template specified in the options. If the template name contains a slash, use it literally

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1181
1181:         def load_html_template
1182:             template = @options.template
1183:             unless template =~ %{/|\\}
1184:                 template = File.join("rdoc/generators/template", @options.generator.key, template)
1185:             end
1186:             require template
1187:             extend RDoc::Page
1188:         rescue LoadError
1189:             $stderr.puts "Could not find AJAX template '#{template}'"
1190:             exit 99
1191:         end
load_html_template() click to toggle source

Load up the AJAX HTML template specified in the options. If the template name contains a slash, use it literally

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1181
1181:         def load_html_template
1182:             template = @options.template
1183:             unless template =~ %{/|\\}
1184:                 template = File.join("rdoc/generators/template", @options.generator.key, template)
1185:             end
1186:             require template
1187:             extend RDoc::Page
1188:         rescue LoadError
1189:             $stderr.puts "Could not find AJAX template '#{template}'"
1190:             exit 99
1191:         end
main_url() click to toggle source

return the url of the main page

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1355
1355:         def main_url
1356:             "files/README.html"
1357:         end
main_url() click to toggle source

return the url of the main page

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1355
1355:         def main_url
1356:             "files/README.html"
1357:         end
write_javascript() click to toggle source
      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1205
1205:         def write_javascript
1206:             #Argh... I couldn't figure out how to copy these from the template dir so they were copied into
1207:             # the template file "ajax.rb" and processed similarlly to the style sheets. Not exactly a good thing to do with
1208:             # external library code. Not very DRY.
1209:                 
1210:             File.open("api_grease.js", "w") do |f|
1211:                 f << RDoc::Page::API_GREASE_JS
1212:             end
1213:             
1214:             File.open("prototype.js", "w") do |f|
1215:                 f << RDoc::Page::PROTOTYPE_JS
1216:             end
1217:             
1218:         rescue LoadError
1219:             $stderr.puts "Could not find AJAX template"
1220:             exit 99
1221:         end
write_javascript() click to toggle source
      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1205
1205:         def write_javascript
1206:             #Argh... I couldn't figure out how to copy these from the template dir so they were copied into
1207:             # the template file "ajax.rb" and processed similarlly to the style sheets. Not exactly a good thing to do with
1208:             # external library code. Not very DRY.
1209:                 
1210:             File.open("api_grease.js", "w") do |f|
1211:                 f << RDoc::Page::API_GREASE_JS
1212:             end
1213:             
1214:             File.open("prototype.js", "w") do |f|
1215:                 f << RDoc::Page::PROTOTYPE_JS
1216:             end
1217:             
1218:         rescue LoadError
1219:             $stderr.puts "Could not find AJAX template"
1220:             exit 99
1221:         end
write_style_sheet() click to toggle source

Write out the style sheet used by the main frames

      # File lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb, line 1197
1197:         def write_style_sheet
1198:             template = TemplatePage.new(RDoc::Page::STYLE)
1199:             File.open(CSS_NAME, "w") do |f|
1200:                 values = { "font" => "helvetica"} #this is not used anywhere but the template function demands a hash of values
1201:                 template.write_html_on(f, values)
1202:             end
1203:         end
write_style_sheet() click to toggle source

Write out the style sheet used by the main frames

      # File lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb, line 1197
1197:         def write_style_sheet
1198:             template = TemplatePage.new(RDoc::Page::STYLE)
1199:             File.open(CSS_NAME, "w") do |f|
1200:                 values = { "font" => "helvetica"} #this is not used anywhere but the template function demands a hash of values
1201:                 template.write_html_on(f, values)
1202:             end
1203:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.