Sha256: d11fbdf567bff788043a2e40fd3237e319601419ef2be09a8531151a977204a3

Contents?: true

Size: 1.85 KB

Versions: 62

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true
include T('default/fulldoc/html')

module OverrideFileLinks
  def resolve_links(text)
    result = ''
    log.enter_level(Logger::ERROR) { result = super }
    result
  end

  def url_for(object, *args)
    if CodeObjects::ExtraFileObject === object && object == options.readme
      'index.html'
    else
      super
    end
  end
end

Template.extra_includes << OverrideFileLinks

def init
  class << options.serializer
    define_method(:serialized_path) do |object|
      if CodeObjects::ExtraFileObject === object
        super(object).sub(/^file\./, '').downcase
      else
        super(object)
      end
    end
  end if options.serializer

  return serialize_onefile if options.onefile

  generate_assets
  options.delete(:objects)
  options.files.each {|file| serialize_file(file) }
  serialize_file(options.readme) if options.readme
end

def generate_assets
  %w(js/jquery.js js/app.js css/style.css css/common.css).each do |file|
    asset(file, file(file, true))
  end
end

def serialize_file(file)
  index = options.files.index(file)
  outfile = file.name.downcase + '.html'
  options.file = file
  if file.attributes[:namespace]
    options.object = Registry.at(file.attributes[:namespace])
  end
  options.object ||= Registry.root

  if file == options.readme
    serialize_index(options)
  else
    serialize_index(options) if !options.readme && index == 0
    Templates::Engine.with_serializer(outfile, options.serializer) do
      T('layout').run(options)
    end
  end
  options.delete(:file)
end

def serialize_onefile
  layout = Object.new.extend(T('layout'))
  options.css_data = layout.stylesheets.map {|sheet| file(sheet, true) }.join("\n")
  options.js_data = layout.javascripts.map {|script| file(script, true) }.join("")
  Templates::Engine.with_serializer('onefile.html', options.serializer) do
    T('onefile').run(options)
  end
end

Version data entries

62 entries across 61 versions & 9 rubygems

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