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

Methods

Public Class methods

[Source]

      # File generators/html_generator.rb, line 1456
1456:     def initialize(*args)
1457:       super
1458:     end

Public Instance methods

[Source]

      # File generators/html_generator.rb, line 1496
1496:     def build_class_list(from, html_file, class_dir)
1497:       @classes << HtmlClass.new(from, html_file, class_dir, @options)
1498:       from.each_classmodule do |mod|
1499:         build_class_list(mod, html_file, class_dir)
1500:       end
1501:     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 1485
1485:     def build_indices
1486: 
1487:       @toplevels.each do |toplevel|
1488:         @files << HtmlFile.new(toplevel, @options, FILE_DIR)
1489:       end
1490: 
1491:       RDoc::TopLevel.all_classes_and_modules.each do |cls|
1492:         build_class_list(cls, @files[0], CLASS_DIR)
1493:       end
1494:     end

[Source]

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

[Source]

      # File generators/html_generator.rb, line 1540
1540:     def gen_class_index
1541:       gen_an_index(@classes, 'Classes')
1542:     end

[Source]

      # File generators/html_generator.rb, line 1536
1536:     def gen_file_index
1537:       gen_an_index(@files, 'Files')
1538:     end

[Source]

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

[Source]

      # File generators/html_generator.rb, line 1544
1544:     def gen_method_index
1545:       gen_an_index(HtmlMethod.all_methods, 'Methods')
1546:     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 1465
1465:     def generate(info)
1466:       @toplevels  = info
1467:       @files      = []
1468:       @classes    = []
1469:       @hyperlinks = {}
1470: 
1471:       build_indices
1472:       generate_xml
1473:     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 1507
1507:     def generate_xml
1508:       values = { 
1509:         'charset' => @options.charset,
1510:         'files'   => gen_into(@files),
1511:         'classes' => gen_into(@classes),
1512:         'title'        => CGI.escapeHTML(@options.title),
1513:       }
1514:       
1515:       # this method is defined in the template file
1516:       write_extra_pages if defined? write_extra_pages
1517: 
1518:       template = TemplatePage.new(RDoc::Page::ONE_PAGE)
1519: 
1520:       if @options.op_name
1521:         opfile = File.open(@options.op_name, "w")
1522:       else
1523:         opfile = $stdout
1524:       end
1525:       template.write_html_on(opfile, values)
1526:     end

[Validate]