module Origen::Generator::Compiler::DocHelpers::SearchableHelpers

Helpers for the searchable doc layout

Public Instance Methods

_doc_root_dir(options) click to toggle source
# File lib/origen_doc_helpers/helpers.rb, line 255
def _doc_root_dir(options)
  f = options[:root]
  @_doc_root_dirs ||= {}
  return @_doc_root_dirs[f] if @_doc_root_dirs[f]
  unless File.exist?(f)
    if File.exist?("#{Origen.root}/app/")
      f = Pathname.new("#{Origen.root}/app/templates/web/#{f}")
    else
      f = Pathname.new("#{Origen.root}/templates/web/#{f}")
    end
    unless f.exist?
      fail "#{options[:root]} does not exist!"
    end
  end
  f = Pathname.new(f) if f.is_a?(String)
  @_doc_root_dirs[options[:root]] = f
end
_resolve_tab(options) click to toggle source
# File lib/origen_doc_helpers/helpers.rb, line 273
def _resolve_tab(options)
  tab = tab.to_s.downcase
  active = false
  if options[:tab]
    options[:tab]
  else
    rel = begin
        options[:top_level_file].relative_path_from(_doc_root_dir(options)).sub_ext('').sub_ext('').to_s
      rescue
        '..'
      end
    # If the file lives outside of the current app (e.g. it comes from a plugin), then the above approach
    # doesn't work, so let's just take the last dirname and the filename
    if rel =~ /\.\./
      dir = options[:top_level_file].dirname.basename
      file = options[:top_level_file].basename('.*').basename('.*')  # twice to allow for my_file.md.erb
      rel = "#{dir}_#{file}"
    end
    rel.gsub(/(\/|\\)/, '_').downcase.to_sym
  end
end
_root_path(options) click to toggle source
# File lib/origen_doc_helpers/helpers.rb, line 295
def _root_path(options)
  if File.exist?("#{Origen.root}/app/templates/web")
    root = Pathname.new("#{Origen.root}/app/templates/web")
  else
    root = Pathname.new("#{Origen.root}/templates/web")
  end
  _doc_root_dir(options).relative_path_from(root)
end