1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
require 'yaml'
require 'rdoc/markup/simple_markup/fragments'
# Descriptions are created by RDoc (in ri_generator) and
# written out in serialized form into the documentation
# tree. ri then reads these to generate the documentation
module RI
class NamedThing
attr_reader :name
def initialize(name)
@name = name
end
def <=>(other)
@name <=> other.name
end
def hash
@name.hash
end
def eql?(other)
@name.eql?(other)
end
end
# Alias = Struct.new(:old_name, :new_name)
class AliasName < NamedThing
end
class Attribute < NamedThing
attr_reader :rw, :comment
def initialize(name, rw, comment)
super(name)
@rw = rw
@comment = comment
end
end
class Constant < NamedThing
attr_reader :value, :comment
def initialize(name, value, comment)
super(name)
@value = value
@comment = comment
end
end
class IncludedModule < NamedThing
end
class MethodSummary < NamedThing
def initialize(name="")
super
end
end
class Description
attr_accessor :name
attr_accessor :full_name
attr_accessor :comment
def serialize
self.to_yaml
end
def Description.deserialize(from)
YAML.load(from)
end
def <=>(other)
@name <=> other.name
end
end
class ModuleDescription < Description
attr_accessor :class_methods
attr_accessor :instance_methods
attr_accessor :attributes
attr_accessor :constants
attr_accessor :includes
# merge in another class desscription into this one
def merge_in(old)
merge(@class_methods, old.class_methods)
merge(@instance_methods, old.instance_methods)
merge(@attributes, old.attributes)
merge(@constants, old.constants)
merge(@includes, old.includes)
if @comment.nil? || @comment.empty?
@comment = old.comment
else
unless old.comment.nil? or old.comment.empty? then
@comment << SM::Flow::RULE.new
@comment.concat old.comment
end
end
end
def display_name
"Module"
end
# the 'ClassDescription' subclass overrides this
# to format up the name of a parent
def superclass_string
nil
end
private
def merge(into, from)
names = {}
into.each {|i| names[i.name] = i }
from.each {|i| names[i.name] = i }
into.replace(names.keys.sort.map {|n| names[n]})
end
end
class ClassDescription < ModuleDescription
attr_accessor :superclass
def display_name
"Class"
end
def superclass_string
if @superclass && @superclass != "Object"
@superclass
else
nil
end
end
end
class MethodDescription < Description
attr_accessor :is_class_method
attr_accessor :visibility
attr_accessor :block_params
attr_accessor :is_singleton
attr_accessor :aliases
attr_accessor :is_alias_for
attr_accessor :params
end
end
|