Sha256: 108c7dc920b16f3c2429ca75ef8120cdd2f48fd4a2ce1576e52129cf471a21a7

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

def init
  @breadcrumb = []

  @page_title = options[:title]

  if @file
    @contents = File.read_binary(@file)
    @file = File.basename(@file)
    sections :layout, [:diskfile]
  elsif object
    case object
    when '_index.html'
      sections :layout, [:index]
    when CodeObjects::Base
      type = object.root? ? :module : object.type
      sections :layout, [T(type)]
    end
  else
    sections :layout, [:contents]
  end
end

def contents
  @contents
end

def index
  @objects_by_letter = {}
  objects = @objects.reject {|o| o.root? }.sort_by {|o| o.name.to_s }
  objects.each {|o| (@objects_by_letter[o.name.to_s[0,1].upcase] ||= []) << o }
  erb(:index)
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', 'mkd'
    htmlify(@contents, :markdown)
  else
    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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yard-rest-plugin-0.1.4 templates/rest/layout/html/setup.rb
yard-rest-plugin-0.1.3 templates/rest/layout/html/setup.rb
yard-rest-plugin-0.1.2 templates/rest/layout/html/setup.rb
yard-rest-plugin-0.1.1 templates/rest/layout/html/setup.rb
yard-rest-plugin-0.1.0 templates/rest/layout/html/setup.rb