Module: YARD::Templates::Template::ClassMethods
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
| |
Defined in: | lib/yard/templates/template.rb |
Instance Attribute Summary
- #full_path rw
- #path rw
Instance Method Summary
-
#find_file(basename) ⇒ String
Searches for a file identified by
basename
in the template's path as well as any mixed in template paths. -
#find_nth_file(basename, index = 1) ⇒ String
Searches for the nth file (where n =
index
) identified by basename in the template's path and any mixed in template paths. - #full_paths ⇒ Array<String>
- #initialize(path, full_paths)
- #is_a?(klass) ⇒ Boolean
-
#new(*args)
Creates a new template object to be rendered with #run
-
#reset_full_paths
Resets cache for #full_paths
- #run(*args)
-
S(*args)
Alias for creating a
::YARD::Templates::Section
with arguments. -
T(*path)
Alias for creating Engine.template.
- #include_inherited(full_paths) private
- #include_parent private
- #load_setup_rb private
Instance Attribute Details
#full_path (rw)
[ GitHub ]# File 'lib/yard/templates/template.rb', line 60
attr_accessor :path, :full_path
#path (rw)
[ GitHub ]# File 'lib/yard/templates/template.rb', line 60
attr_accessor :path, :full_path
Instance Method Details
#find_file(basename) ⇒ String
Searches for a file identified by basename
in the template's
path as well as any mixed in template paths. Equivalent to calling
#find_nth_file with index of 1.
# File 'lib/yard/templates/template.rb', line 98
def find_file(basename) find_nth_file(basename) end
#find_nth_file(basename, index = 1) ⇒ String
Searches for the nth file (where n = index
) identified
by basename in the template's path and any mixed in template paths.
#full_paths ⇒ Array<String>
This method caches path results. Paths should not be modified after this method is called; call #reset_full_paths to reset cache.
# File 'lib/yard/templates/template.rb', line 65
def full_paths reset_full_paths unless defined? @cached_included_modules return @full_paths if included_modules == @cached_included_modules @cached_included_modules = included_modules @full_paths = included_modules.inject([full_path]) do |paths, mod| paths |= mod.full_paths if mod.respond_to?(:full_paths) paths end end
#include_inherited(full_paths) (private)
[ GitHub ]# File 'lib/yard/templates/template.rb', line 170
def include_inherited(full_paths) full_paths.reverse.each do |full_path| include Engine.template!(path, full_path) end end
#include_parent (private)
[ GitHub ]#initialize(path, full_paths)
[ GitHub ]# File 'lib/yard/templates/template.rb', line 81
def initialize(path, full_paths) full_path = full_paths.shift self.path = path self.full_path = full_path include_inherited(full_paths) include_parent load_setup_rb end
#is_a?(klass) ⇒ Boolean
# File 'lib/yard/templates/template.rb', line 122
def is_a?(klass) return true if klass == Template super(klass) end
#load_setup_rb (private)
[ GitHub ]#new(*args)
Creates a new template object to be rendered with YARD::Templates::Template#run
# File 'lib/yard/templates/template.rb', line 128
def new(*args) obj = Object.new.extend(self) obj.class = self obj.send(:initialize, *args) obj end
#reset_full_paths
Resets cache for #full_paths
# File 'lib/yard/templates/template.rb', line 77
def reset_full_paths @cached_included_modules = nil end
#run(*args)
[ GitHub ]# File 'lib/yard/templates/template.rb', line 135
def run(*args) new(*args).run end
S(*args)
Alias for creating a ::YARD::Templates::Section
with arguments
T(*path)
Alias for creating Engine.template.