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
|
class MRBDoc
DOC_DIR = 'language'
def write_documentation dir, &block
block.call "MRBDOC\tStart Building Documentation to #{doc_dir(dir)}"
write(dir) do |progress|
block.call progress
end
block.call "MRBDOC\tFinish Building Documentation"
end
private
def write dir
# io = STDOUT
File.open(File.expand_path('Core_Classes.md', dir), 'w+') do |io|
print_core_classes(io)
print_core_modules(io)
end
end
def get_core_list id
core_list = {}
each_file do |file_path, mrb_file|
mrb_file.send(id) do |name, cls_hsh|
core_list[name] = {:data => cls_hsh, :methods => {}, :class_methods => {}}
mrb_file.each_method name do |met_name, met_hsh|
core_list[name][:methods][met_name] = met_hsh
end
mrb_file.each_class_method name do |met_name, met_hsh|
core_list[name][:class_methods][met_name] = met_hsh
end
end
end
core_list
end
def print_core_classes(io)
core_list = get_core_list :each_class
io.puts "# Core Classes\n\n"
core_list.sort.each do |name, hsh|
file = find_c_file_by_class(name)
file = file.split("#{@dir}/")[1]
iso = hsh[:data][:iso]
iso = 'n/a' if iso.nil?
io.puts <<CLASS
## #{name}
ISO Code | Mixins | Source File
--- | --- | ---
#{hsh[:data][:iso]} | n/a | #{file}
CLASS
print_class_methods(io, hsh)
print_methods(io, hsh)
end
end
def print_core_modules(io)
core_list = get_core_list :each_module
io.puts "# Core Modules\n\n"
core_list.sort.each do |name, hsh|
file = find_c_file_by_module(name)
file = file.split("#{@dir}/")[1]
iso = hsh[:iso]
iso = 'n/a' if iso.nil?
io.puts <<CLASS
## #{name}
ISO Code | Source File
--- | ---
#{iso} | #{file}
CLASS
print_class_methods(io, hsh)
print_methods(io, hsh)
end
end
def print_methods(io, hsh)
return unless hsh[:methods].size > 0
io.puts "### Methods\n\n"
hsh[:methods].sort.each do |met_name, met_hsh|
print_method(io, met_name, met_hsh)
end
end
def print_class_methods(io, hsh)
return unless hsh[:class_methods].size > 0
io.puts "### Class Methods\n\n"
hsh[:class_methods].sort.each do |met_name, met_hsh|
print_method(io, met_name, met_hsh)
end
end
def print_method(io, met_name, met_hsh)
line_no = find_c_func(met_hsh[:c_func])[:line_no]
file = find_c_file(met_hsh[:rb_class], met_hsh[:c_func])
file = file.split("#{@dir}/")[1]
io.puts <<METHOD
#### #{met_name}
ISO Code | Source File | C Function | Line
--- | --- | ---
#{met_hsh[:iso]} | #{file} | #{met_hsh[:c_func]} | #{line_no}
METHOD
end
def doc_dir dir; File.expand_path DOC_DIR, dir; end
end
|