templates/default/layout/html/setup.rb in yard-0.5.2 vs templates/default/layout/html/setup.rb in yard-0.5.3
- old
+ new
@@ -1,10 +1,10 @@
def init
@breadcrumb = []
if @file
- @contents = IO.read(@file)
+ @contents = File.read_binary(@file)
@file = File.basename(@file)
@fname = @file.gsub(/\.[^.]+$/, '')
@breadcrumb_title = "File: " + @fname
@page_title ||= @breadcrumb_title
sections :layout, [:diskfile]
@@ -43,16 +43,27 @@
end
def diskfile
"<div id='filecontents'>" +
case (File.extname(@file)[1..-1] || '').downcase
+ when 'htm', 'html'
+ @contents
when 'txt'
"<pre>#{@contents}</pre>"
when 'textile', 'txtile'
htmlify(@contents, :textile)
when 'markdown', 'md', 'mdown'
htmlify(@contents, :markdown)
else
- htmlify(@contents, :rdoc)
+ htmlify(@contents, diskfile_shebang_or_default)
end +
"</div>"
+end
+
+def diskfile_shebang_or_default
+ if @contents =~ /\A#!(\S+)\s*$/ # Shebang support
+ @contents = $'
+ $1.to_sym
+ else
+ options[:markup]
+ end
end
\ No newline at end of file