Class: RDocF95::Generator::XML

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

Overview

Generate XML output as one big file

Defined Under Namespace

Modules: RDF, XML

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ XML

Returns a new instance of XML.



15
16
17
# File 'lib/rdoc-f95/generator/xml.rb', line 15

def initialize(*args)
  super
end

Class Method Details

.for(options) ⇒ Object

Standard generator factory



11
12
13
# File 'lib/rdoc-f95/generator/xml.rb', line 11

def self.for(options)
  new(options)
end

Instance Method Details

#build_class_list(from, html_file, class_dir) ⇒ Object



53
54
55
56
57
58
# File 'lib/rdoc-f95/generator/xml.rb', line 53

def build_class_list(from, html_file, class_dir)
  @classes << RDocF95::Generator::HtmlClass.new(from, html_file, class_dir, @options)
  from.each_classmodule do |mod|
    build_class_list(mod, html_file, class_dir)
  end
end

#build_indicesObject

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)



43
44
45
46
47
48
49
50
51
# File 'lib/rdoc-f95/generator/xml.rb', line 43

def build_indices
  @info.each do |toplevel|
    @files << RDocF95::Generator::HtmlFile.new(toplevel, @options, RDocF95::Generator::FILE_DIR)
  end

  RDocF95::TopLevel.all_classes_and_modules.each do |cls|
    build_class_list(cls, @files[0], RDocF95::Generator::CLASS_DIR)
  end
end

#gen_an_index(collection, title) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/rdoc-f95/generator/xml.rb', line 104

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



96
97
98
# File 'lib/rdoc-f95/generator/xml.rb', line 96

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

#gen_file_indexObject



92
93
94
# File 'lib/rdoc-f95/generator/xml.rb', line 92

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

#gen_into(list) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/rdoc-f95/generator/xml.rb', line 84

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

#gen_method_indexObject



100
101
102
# File 'lib/rdoc-f95/generator/xml.rb', line 100

def gen_method_index
  gen_an_index(RDocF95::Generator::HtmlMethod.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.



24
25
26
27
28
29
30
31
32
# File 'lib/rdoc-f95/generator/xml.rb', line 24

def generate(info)
  @info       = info
  @files      = []
  @classes    = []
  @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



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rdoc-f95/generator/xml.rb', line 64

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

  # 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 = File.open(@options.op_name, "w")
  else
    opfile = $stdout
  end
  template.write_html_on(opfile, values)
end