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

Methods

Public Class methods

[Source]

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

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]