Class: Generators::HTMLGeneratorInOne

Inherits:
HTMLGenerator show all
Defined in:
lib/rdoc/generators/html_generator.rb

Instance Method Summary collapse

Methods inherited from HTMLGenerator

for, gen_url

Methods included from MarkUp

#cvs_url, #markup, #style_url

Constructor Details

#initialize(*args) ⇒ HTMLGeneratorInOne

Returns a new instance of HTMLGeneratorInOne.



1400
1401
1402
# File 'lib/rdoc/generators/html_generator.rb', line 1400

def initialize(*args)
  super
end

Instance Method Details

#build_class_list(from, html_file, class_dir) ⇒ Object



1440
1441
1442
1443
1444
1445
# File 'lib/rdoc/generators/html_generator.rb', line 1440

def build_class_list(from, html_file, class_dir)
  @classes << HtmlClass.new(from, html_file, class_dir, @options)
  from.each_classmodule do |mod|
    build_class_list(mod, html_file, class_dir)
  end
end

#build_indicesObject

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)



1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
# File 'lib/rdoc/generators/html_generator.rb', line 1429

def build_indices

  @toplevels.each do |toplevel|
    @files << HtmlFile.new(toplevel, @options, FILE_DIR)
  end

  RDoc::TopLevel.all_classes_and_modules.each do |cls|
    build_class_list(cls, @files[0], CLASS_DIR)
  end
end

#gen_an_index(collection, title) ⇒ Object



1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
# File 'lib/rdoc/generators/html_generator.rb', line 1493

def gen_an_index(collection, title)
  res = []
  collection.sort.each do |f|
    if f.document_self
      res << { "href" => f.path, "name" => f.index_name }
    end
  end

  return {
    "entries" => res,
    'list_title' => title,
    'index_url'  => main_url,
  }
end

#gen_class_indexObject



1484
1485
1486
# File 'lib/rdoc/generators/html_generator.rb', line 1484

def gen_class_index
  gen_an_index(@classes, 'Classes')
end

#gen_file_indexObject



1480
1481
1482
# File 'lib/rdoc/generators/html_generator.rb', line 1480

def gen_file_index
  gen_an_index(@files, 'Files')
end

#gen_into(list) ⇒ Object



1472
1473
1474
1475
1476
1477
1478
# File 'lib/rdoc/generators/html_generator.rb', line 1472

def gen_into(list)
  res = []
  list.each do |item|
    res << item.value_hash
  end
  res
end

#gen_method_indexObject



1488
1489
1490
# File 'lib/rdoc/generators/html_generator.rb', line 1488

def gen_method_index
  gen_an_index(HtmlMethod.all_methods, 'Methods')
end

#generate(info) ⇒ Object

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



1409
1410
1411
1412
1413
1414
1415
1416
1417
# File 'lib/rdoc/generators/html_generator.rb', line 1409

def generate(info)
  @toplevels  = info
  @files      = []
  @classes    = []
  @hyperlinks = {}

  build_indices
  generate_xml
end

#generate_xmlObject

Generate all the HTML. For the one-file case, we generate all the information in to one big hash



1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
# File 'lib/rdoc/generators/html_generator.rb', line 1451

def generate_xml
  values = { 
    'charset' => @options.charset,
    'files'   => gen_into(@files),
    'classes' => gen_into(@classes),
    'title'        => CGI.escapeHTML(@options.title),
  }
  
  # this method is defined in the template file
  write_extra_pages if defined? write_extra_pages

  template = TemplatePage.new(RDoc::Page::ONE_PAGE)

  if @options.op_name
    opfile = File.open(@options.op_name, "w")
  else
    opfile = $stdout
  end
  template.write_html_on(opfile, values)
end