Options that we don’t handle are yielded. If the
block returns false the directive is restored to the text. If the block
returns nil or no block was given the directive is handled according to the
registered
directives. If a String was returned the
directive is replaced with the string.
If no matching directive was registered the
directive is restored to the text.
If code_object is given and the param is set as metadata on the
code_object. See RDoc::CodeObject#metadata
# File lib/rdoc/markup/preprocess.rb, line 54
def handle text, code_object = nil
text.gsub!(/^([ \t]*#?[ \t]*):(\w+):([ \t]*)(.+)?\n/) do
next $& if $3.empty? and $4 and $4[0, 1] == ':'
prefix = $1
directive = $2.downcase
param = $4
case directive
when 'include' then
filename = param.split[0]
include_file filename, prefix
else
result = yield directive, param if block_given?
case result
when nil then
code_object.metadata[directive] = param if code_object
if RDoc::Markup::PreProcess.registered.include? directive then
handler = RDoc::Markup::PreProcess.registered[directive]
result = handler.call directive, param if handler
else
result = "#{prefix}:#{directive}: #{param}\n"
end
when false then
result = "#{prefix}:#{directive}: #{param}\n"
end
result
end
end
text
end