Class: RDocF95::Generator::RI

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RI

Set up a new RDocF95::Generator::RI.



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

def initialize(options) #:not-new:
  @options   = options
  @ri_writer = RDocF95::RI::Writer.new "."
  @markup    = RDocF95::Markup.new
  @to_flow   = RDocF95::Markup::ToFlow.new

  @generated = {}
end

Class Method Details

.for(options) ⇒ Object

Generator may need to return specific subclasses depending on the options they are passed. Because of this we create them using a factory



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

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

Instance Method Details

#generate(toplevels) ⇒ Object

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



39
40
41
42
43
# File 'lib/rdoc-f95/generator/ri.rb', line 39

def generate(toplevels)
  RDocF95::TopLevel.all_classes_and_modules.each do |cls|
    process_class cls
  end
end

#generate_class_info(cls) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/rdoc-f95/generator/ri.rb', line 54

def generate_class_info(cls)
  if cls === RDocF95::NormalModule
    cls_desc = RDocF95::RI::ModuleDescription.new
  else
    cls_desc = RDocF95::RI::ClassDescription.new
    cls_desc.superclass  = cls.superclass
  end

  cls_desc.name        = cls.name
  cls_desc.full_name   = cls.full_name
  cls_desc.comment     = markup(cls.comment)

  cls_desc.attributes = cls.attributes.sort.map do |a|
    RDocF95::RI::Attribute.new(a.name, a.rw, markup(a.comment))
  end

  cls_desc.constants = cls.constants.map do |c|
    RDocF95::RI::Constant.new(c.name, c.value, markup(c.comment))
  end

  cls_desc.includes = cls.includes.map do |i|
    RDocF95::RI::IncludedModule.new(i.name)
  end

  class_methods, instance_methods = method_list(cls)

  cls_desc.class_methods = class_methods.map do |m|
    RDocF95::RI::MethodSummary.new(m.name)
  end

  cls_desc.instance_methods = instance_methods.map do |m|
    RDocF95::RI::MethodSummary.new(m.name)
  end

  update_or_replace(cls_desc)

  class_methods.each do |m|
    generate_method_info(cls_desc, m)
  end

  instance_methods.each do |m|
    generate_method_info(cls_desc, m)
  end
end

#generate_method_info(cls_desc, method) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/rdoc-f95/generator/ri.rb', line 99

def generate_method_info(cls_desc, method)
  meth_desc = RDocF95::RI::MethodDescription.new
  meth_desc.name = method.name
  meth_desc.full_name = cls_desc.full_name
  if method.singleton
    meth_desc.full_name += "::"
  else
    meth_desc.full_name += "#"
  end
  meth_desc.full_name << method.name

  meth_desc.comment = markup(method.comment)
  meth_desc.params = params_of(method)
  meth_desc.visibility = method.visibility.to_s
  meth_desc.is_singleton = method.singleton
  meth_desc.block_params = method.block_params

  meth_desc.aliases = method.aliases.map do |a|
    RDocF95::RI::AliasName.new(a.name)
  end

  @ri_writer.add_method(cls_desc, meth_desc)
end

#process_class(from_class) ⇒ Object



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

def process_class(from_class)
  generate_class_info(from_class)

  # now recure into this classes constituent classess
  from_class.each_classmodule do |mod|
    process_class(mod)
  end
end