This method is deprecated or moved on the latest stable version.
The last existing version (v1_9_1_378) is shown here.
add_line_numbers(src)
public
We rely on the fact that the first line of a source code listing has
# File xxxxx, line dddd
# File lib/rdoc/generator.rb, line 1041
def add_line_numbers(src)
if src =~ /\A.*, line (\d+)/
first = $1.to_i - 1
last = first + src.count("\n")
size = last.to_s.length
fmt = "%#{size}d: "
is_first_line = true
line_num = first
src.gsub!(/^/) do
if is_first_line then
is_first_line = false
res = " " * (size+2)
else
res = sprintf(fmt, line_num)
end
line_num += 1
res
end
end
end