Method: YARD::Templates::Helpers::MarkupHelper#markup_for_file
- Defined in:
- lib/yard/templates/helpers/markup_helper.rb
#markup_for_file(contents, filename) ⇒ Symbol
Checks for a shebang or looks at the file extension to determine the markup type for the file contents. File extensions are registered for a markup type in MARKUP_EXTENSIONS.
A shebang should be on the first line of a file and be in the form:
#!markup_type
Standard markup types are text, html, rdoc, markdown, textile
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/yard/templates/helpers/markup_helper.rb', line 122 def markup_for_file(contents, filename) if contents && contents =~ MARKUP_FILE_SHEBANG # Shebang support return $1.to_sym end ext = (File.extname(filename)[1..-1] || '').downcase MARKUP_EXTENSIONS.each do |type, exts| return type if exts.include?(ext) end .markup end |