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
|
# File 'lib/tomdoc/generators/console.rb', line 28
def ()
= .to_s
.gsub!(/^# ?/, '')
.gsub!(/(\s*Examples\s*(.+?)\s*Returns)/m) do
$1.sub($2, highlight($2))
end
.gsub!(/^(\s*(\w+) +- )/) do
param = $2
$1.sub(param, param.green)
end
.gsub!(/(true|false|nil)/, '\1'.magenta)
.gsub!(/('.+?')/, '\1'.yellow)
.gsub!(/(".+?")/, '\1'.yellow)
.gsub!(/(\s+:\w+)/, '\1'.red)
.gsub!(/(([A-Z]\w+(::)?)+)/) do
if constant?($1.strip)
$1.split('::').map { |part| part.cyan }.join('::')
else
$1
end
end
end
|