class Bake::Recipe
def read_comments
def read_comments unless source_location = self.method&.source_location # Bail early if we don't have a source location (there are some inconsequential cases on JRuby): return [] end file, line_number = source_location lines = File.readlines(file) line_index = line_number - 1 description = [] line_index -= 1 # Extract comment preceeding method: while line = lines[line_index] # \Z matches a trailing newline: if match = line.match(COMMENT) description.unshift(match[1]) else break end line_index -= 1 end return description end