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

Methods

Public Class methods

[Source]

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

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]