Class: RDocF95::Generator::HTMLInOne

Inherits:
RDocF95::Generator::HTML
  • Object
show all
Defined in:
lib/rdoc-f95/generator/html.rb

Direct Known Subclasses

XHTMLInOne

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ HTMLInOne

Returns a new instance of HTMLInOne.


277
278
279
# File 'lib/rdoc-f95/generator/html.rb', line 277

def initialize(*args)
  super
end

Instance Method Details

#build_indicesObject

Generate:

  • a list of RDocF95::Generator::File objects for each TopLevel object.

  • a list of RDocF95::Generator::Class 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)


303
304
305
306
# File 'lib/rdoc-f95/generator/html.rb', line 303

def build_indices
  @files, @classes = RDocF95::Generator::Context.build_indices(@toplevels,
                                                            @options)
end

#gen_an_index(collection, title) ⇒ Object


353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/rdoc-f95/generator/html.rb', line 353

def gen_an_index(collection, title)
  res = []
  collection.sort.each do |f|
    if f.document_self
      res << { "href" => f.path, "name" => f.index_name }
    end
  end

  return {
    "entries" => res,
    'list_title' => title,
    'index_url'  => main_url,
  }
end

#gen_class_indexObject


345
346
347
# File 'lib/rdoc-f95/generator/html.rb', line 345

def gen_class_index
  gen_an_index(@classes, 'Classes')
end

#gen_file_indexObject


341
342
343
# File 'lib/rdoc-f95/generator/html.rb', line 341

def gen_file_index
  gen_an_index(@files, 'Files')
end

#gen_into(list) ⇒ Object


333
334
335
336
337
338
339
# File 'lib/rdoc-f95/generator/html.rb', line 333

def gen_into(list)
  res = []
  list.each do |item|
    res << item.value_hash
  end
  res
end

#gen_method_indexObject


349
350
351
# File 'lib/rdoc-f95/generator/html.rb', line 349

def gen_method_index
  gen_an_index(RDocF95::Generator::Method.all_methods, 'Methods')
end

#generate(info) ⇒ Object

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


286
287
288
289
290
291
292
# File 'lib/rdoc-f95/generator/html.rb', line 286

def generate(info)
  @toplevels  = info
  @hyperlinks = {}

  build_indices
  generate_xml
end

#generate_xmlObject

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


312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/rdoc-f95/generator/html.rb', line 312

def generate_xml
  values = {
    'charset' => @options.charset,
    'files'   => gen_into(@files),
    'classes' => gen_into(@classes),
    'title'        => CGI.escapeHTML(@options.title),
  }

  # this method is defined in the template file
  write_extra_pages if defined? write_extra_pages

  template = RDocF95::TemplatePage.new @template::ONE_PAGE

  if @options.op_name
    opfile = open @options.op_name, 'w'
  else
    opfile = $stdout
  end
  template.write_html_on(opfile, values)
end