Class: RDoc::Generator::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/generator/darkfish.rb

Overview

Monkeypatch RDoc::Generator::Method so it works with line numbers turned on and $DEBUG = true. Also make it use a conditional instead of a side-effect to get the initial blank line.

Instance Method Summary collapse

Instance Method Details

#add_line_numbers(src) ⇒ Object

:nodoc:



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/rdoc/generator/darkfish.rb', line 457

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

		line = first
		src.gsub!(/^/) do
			if line == first
				res = " " * ( size + 2 )
			else
				res = sprintf( "%#{size}d: ", line )
			end

			line += 1
			res
		end
	end
end