Class Generators::HTMLGeneratorInOne
In: generators/html_generator.rb
Parent: HTMLGenerator

Methods

Public Class methods

[Source]

      # File generators/html_generator.rb, line 1453
1453:     def initialize(*args)
1454:       super
1455:     end

Public Instance methods

[Source]

      # File generators/html_generator.rb, line 1493
1493:     def build_class_list(from, html_file, class_dir)
1494:       @classes << HtmlClass.new(from, html_file, class_dir, @options)
1495:       from.each_classmodule do |mod|
1496:         build_class_list(mod, html_file, class_dir)
1497:       end
1498:     end

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)

[Source]

      # File generators/html_generator.rb, line 1482
1482:     def build_indices
1483: 
1484:       @toplevels.each do |toplevel|
1485:         @files << HtmlFile.new(toplevel, @options, FILE_DIR)
1486:       end
1487: 
1488:       RDoc::TopLevel.all_classes_and_modules.each do |cls|
1489:         build_class_list(cls, @files[0], CLASS_DIR)
1490:       end
1491:     end

[Source]

      # File generators/html_generator.rb, line 1546
1546:     def gen_an_index(collection, title)
1547:       res = []
1548:       collection.sort.each do |f|
1549:         if f.document_self
1550:           res << { "href" => f.path, "name" => f.index_name }
1551:         end
1552:       end
1553: 
1554:       return {
1555:         "entries" => res,
1556:         'list_title' => title,
1557:         'index_url'  => main_url,
1558:       }
1559:     end

[Source]

      # File generators/html_generator.rb, line 1537
1537:     def gen_class_index
1538:       gen_an_index(@classes, 'Classes')
1539:     end

[Source]

      # File generators/html_generator.rb, line 1533
1533:     def gen_file_index
1534:       gen_an_index(@files, 'Files')
1535:     end

[Source]

      # File generators/html_generator.rb, line 1525
1525:     def gen_into(list)
1526:       res = []
1527:       list.each do |item|
1528:         res << item.value_hash
1529:       end
1530:       res
1531:     end

[Source]

      # File generators/html_generator.rb, line 1541
1541:     def gen_method_index
1542:       gen_an_index(HtmlMethod.all_methods, 'Methods')
1543:     end

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

[Source]

      # File generators/html_generator.rb, line 1462
1462:     def generate(info)
1463:       @toplevels  = info
1464:       @files      = []
1465:       @classes    = []
1466:       @hyperlinks = {}
1467: 
1468:       build_indices
1469:       generate_xml
1470:     end

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

[Source]

      # File generators/html_generator.rb, line 1504
1504:     def generate_xml
1505:       values = { 
1506:         'charset' => @options.charset,
1507:         'files'   => gen_into(@files),
1508:         'classes' => gen_into(@classes),
1509:         'title'        => CGI.escapeHTML(@options.title),
1510:       }
1511:       
1512:       # this method is defined in the template file
1513:       write_extra_pages if defined? write_extra_pages
1514: 
1515:       template = TemplatePage.new(RDoc::Page::ONE_PAGE)
1516: 
1517:       if @options.op_name
1518:         opfile = File.open(@options.op_name, "w")
1519:       else
1520:         opfile = $stdout
1521:       end
1522:       template.write_html_on(opfile, values)
1523:     end

[Validate]