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
|
# File 'lib/abidoc/generate.rb', line 5
def generate_doc( title: 'Contract ABI',
natspec: nil )
buf = ''
buf << "# #{title}\n\n"
if natspec && natspec.head.size > 0
natspec.head.each do |line|
buf << (line.empty? ? "\n" : "#{line}\n")
end
end
buf << "\n\n"
if events.size > 0
buf << "\n"
buf << "**#{events.size} Event Log Type(s)**\n\n"
events.each do |event|
buf << "- #{event.doc}\n"
end
end
if @ctor
buf << "\n"
buf << "**Constructor**\n\n"
buf << "- #{@ctor.doc}\n"
end
if payable_functions.size > 0
buf << "\n"
buf << "**#{payable_functions.size} Payable Function(s)**\n\n"
payable_functions.each do |func|
buf << "- #{func.doc} _payable_\n"
end
end
if transact_functions.size > 0
buf << "\n"
buf << "**#{transact_functions.size} Transact Functions(s)**\n\n"
transact_functions.each do |func|
buf << "- #{func.doc}\n"
end
end
if query_functions.size > 0
buf << "\n"
buf << "**#{query_functions.size} Query Functions(s)**\n\n"
query_functions.each do |func|
if natspec && (natspec.storage[ func.name] || natspec.functions[ func.name ])
sect = natspec.storage[ func.name ] || natspec.functions[ func.name ]
buf << "- #{sect[0]}"
sect[1].each do |line|
buf << (line.empty? ? " <br>" : " <br> #{line}")
end
buf << "\n"
else
buf << "- #{func.doc} _readonly_\n"
end
end
end
if helper_functions.size > 0
buf << "\n"
buf << "**#{helper_functions.size} Helper Functions(s)**\n\n"
helper_functions.each do |func|
buf << "- #{func.doc}\n"
end
end
buf
end
|