def parse_content(content)
content = content.split(/\r?\n/) if content.is_a?(String)
return '' if !content || content.empty?
docstring = ""
indent, last_indent = content.first[/^\s*/].length, 0
orig_indent = 0
directive = false
last_line = ""
tag_name, tag_klass, tag_buf = nil, nil, []
(content+['']).each_with_index do |line, index|
indent = line[/^\s*/].length
empty = (line =~ /^\s*$/ ? true : false)
done = content.size == index
if tag_name && (((indent < orig_indent && !empty) || done ||
(indent == 0 && !empty)) || (indent <= last_indent && line =~ META_MATCH))
buf = tag_buf.join("\n")
if directive || tag_is_directive?(tag_name)
directive = create_directive(tag_name, buf)
if directive
docstring << parse_content(directive.expanded_text).chomp
end
else
create_tag(tag_name, buf)
end
tag_name, tag_buf, directive = nil, [], false
orig_indent = 0
end
if line =~ META_MATCH
directive, tag_name, tag_buf = $1, $2, [($3 || '')]
elsif tag_name && indent >= orig_indent && !empty
orig_indent = indent if orig_indent == 0
last_empty = last_line =~ /^[ \t]*$/ ? true : false
tag_buf << '' if last_empty
tag_buf << line.gsub(/^[ \t]{#{orig_indent}}/, '')
elsif !tag_name
docstring << line << "\n"
end
last_indent = indent
last_line = line
end
docstring
end