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

Methods

Public Class methods

[Source]

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

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Source]

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

[Validate]