Sha256: a517d011421ac3e2876ddf1a8756e9b6c92c450115a0b747d1576a2c94832a54

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

include Helpers::FilterHelper

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, [T('class')]]
    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

  legitimate_objects = index_objects(@objects).reject {|o| o.root? }
  @topics = {}

  legitimate_objects.each do |object|
    object.tags('topic').each { |topic| (@topics[topic.text] ||= []) << object }
  end

  @resources = legitimate_objects.sort_by {|o| o.tags('url').first.text }

  @overall_objects = @objects.find_all {|o| o.has_tag?('overall')}.sort_by {|o| o.tag('overall').text}

  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

3 entries across 3 versions & 2 rubygems

Version Path
yard-rest-plugin-0.2.5 templates/rest/layout/html/setup.rb
yard-rest-plugin-0.2.4 templates/rest/layout/html/setup.rb
yard-web-plugin-0.1.2 templates/rest/layout/html/setup.rb