Sha256: 889cc881e7a29938a7812f691068f989b2840108d5d21e9d2d56e81ba39a2e48

Contents?: true

Size: 1.55 KB

Versions: 45

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true
include T('default/layout/html')
include YARD::Parser::Ruby::Legacy

def init
  override_serializer
  @object = YARD::Registry.root
  @files.shift
  @objects.delete(YARD::Registry.root)
  @objects.unshift(YARD::Registry.root)
  sections :layout, [:readme, :files, :all_objects]
end

def all_objects
  @objects.map {|obj| obj.format(options) }.join("\n")
end

def layout
  layout = Object.new.extend(T('layout'))
  @css_data = layout.stylesheets.map {|sheet| read_asset(sheet) }.join("\n")
  @js_data = layout.javascripts.map {|script| read_asset(script) }.join("")

  erb(:layout)
end

def read_asset(file)
  file = T('fulldoc').find_file(file)
  return unless file
  data = File.read(file)
  superfile = self.class.find_nth_file('fulldoc', 2)
  data.gsub!('{{{__super__}}}', superfile ? IO.read(superfile) : "")
  data
end

private

def parse_top_comments_from_file
  return unless defined?(@readme) && @readme
  return @readme.contents unless @readme.filename =~ /\.rb$/
  data = ""
  tokens = TokenList.new(@readme.contents)
  tokens.each do |token|
    break unless token.is_a?(RubyToken::TkCOMMENT) || token.is_a?(RubyToken::TkNL)
    data += (token.text[/\A#\s{0,1}(.*)/, 1] || "\n")
  end
  YARD::Docstring.new(data)
end

def override_serializer
  return if @serializer.nil?
  class << @serializer
    define_method(:serialize) do |object, data|
      return unless object == 'index.html'
      super(object, data)
    end

    define_method(:serialized_path) do |object|
      return object if object.is_a?(String)
      'index.html'
    end
  end
end

Version data entries

45 entries across 45 versions & 6 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/onefile/html/setup.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/onefile/html/setup.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/onefile/html/setup.rb
yard-0.9.37 templates/default/onefile/html/setup.rb
kinetic_sdk-5.0.27 gems/yard-0.9.36/templates/default/onefile/html/setup.rb
kinetic_sdk-5.0.26 gems/yard-0.9.36/templates/default/onefile/html/setup.rb
kinetic_sdk-5.0.25 gems/yard-0.9.25/templates/default/onefile/html/setup.rb
kinetic_sdk-5.0.24 gems/yard-0.9.25/templates/default/onefile/html/setup.rb
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/onefile/html/setup.rb
yard-0.9.36 templates/default/onefile/html/setup.rb
yard-0.9.35 templates/default/onefile/html/setup.rb
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/onefile/html/setup.rb
kinetic_sdk-5.0.23 gems/yard-0.9.25/templates/default/onefile/html/setup.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/yard-0.9.34/templates/default/onefile/html/setup.rb
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/onefile/html/setup.rb
kinetic_sdk-5.0.22 gems/yard-0.9.25/templates/default/onefile/html/setup.rb
kinetic_sdk-5.0.21 gems/yard-0.9.25/templates/default/onefile/html/setup.rb
yard-0.9.34 templates/default/onefile/html/setup.rb
yard-0.9.33 templates/default/onefile/html/setup.rb
yard-0.9.32 templates/default/onefile/html/setup.rb