Sha256: 982468608f5683ceb4c2e401b0402e7dcc09e9ab12b343a01067c814a133ca9a

Contents?: true

Size: 1.75 KB

Versions: 7

Compression:

Stored size: 1.75 KB

Contents

include Helpers::FilterHelper

def init
  @page_title = options[:title]

  if options[:inline_file]
    @contents = File.read(options[:file])
    sections :diskfile
  elsif @file
    sections :layout, [:diskfile]
  elsif options[:all_resources]
    sections :layout, [T('topic'), T('appendix')]
  elsif options[:controllers]
    sections :layout, [T('topic'), T('appendix')]
  else
    sections :layout, [:contents]
  end
end

def stylesheets
  %w[
    css/common.css
    css/highlight.css
  ]
end

def inline_stylesheets
  [ '_dynamic_styles' ]
end

def javascripts
  %w[
    js/jquery-1.11.1.min.js
    js/highlight/highlight.pack.js
  ]
end

def inline_javascripts
  []
end

def contents
  @contents
end

def index
  legitimate_objects = @objects.reject {|o| o.root? || !is_class?(o) || !o.meths.find { |m| !m.tags('API').empty? } }

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

  erb(:index)
end

def diskfile(filename=@file)
  if filename.is_a?(String)
    @contents = File.read(filename)
    filename = File.basename(filename)
  elsif filename.is_a?(File)
    @contents = filename.contents
    filename = File.basename(filename.path)
  end

  extension = (File.extname(filename)[1..-1] || '').downcase

  content = "<div id='filecontents'>" +
  case extension
  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>"
  options.delete(:no_highlight)
  content
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

7 entries across 7 versions & 1 rubygems

Version Path
yard-api-0.2.2 templates/api/layout/html/setup.rb
yard-api-0.2.1 templates/api/layout/html/setup.rb
yard-api-0.1.10 templates/api/layout/html/setup.rb
yard-api-0.1.8 templates/api/layout/html/setup.rb
yard-api-0.1.7 templates/api/layout/html/setup.rb
yard-api-0.1.6 templates/api/layout/html/setup.rb
yard-api-0.1.5 templates/api/layout/html/setup.rb