Method: YARD::Docstring#to_raw
- Defined in:
- lib/yard/docstring.rb
#to_raw ⇒ String
TODO:
Add Tags::Tag#to_raw and refactor
Reformats and returns a raw representation of the tag data using the current tag and docstring data, not the original text.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/yard/docstring.rb', line 134 def to_raw tag_data = .sort_by {|t| t.tag_name }.map do |tag| case tag when Tags::OverloadTag tag_text = "@#{tag.tag_name} #{tag.signature}\n" unless tag.docstring.blank? tag_text += "\n" + tag.docstring.all.gsub(/\r?\n/, "\n ") end else tag_text = '@' + tag.tag_name tag_text += ' [' + tag.types.join(', ') + ']' if tag.types tag_text += ' ' + tag.name.to_s if tag.name tag_text += "\n " if tag.name && tag.text tag_text += ' ' + tag.text.strip.gsub(/\n/, "\n ") if tag.text end tag_text end [strip, tag_data.join("\n")].reject {|l| l.empty? }.compact.join("\n") end |