Module: YARD::Templates::Template::ClassMethods
- Included in:
- YARD::Templates::Template
- Defined in:
- lib/yard/templates/template.rb
Instance Attribute Summary (collapse)
-
- (Object) full_path
Returns the value of attribute full_path.
-
- (Object) path
Returns the value of attribute path.
Instance Method Summary (collapse)
-
- (String) find_file(basename)
Searches for a file identified by basename in the template's path as well as any mixed in template paths.
-
- (String) find_nth_file(basename, index = 1)
Searches for the nth file (where n = index) identified by basename in the template's path and any mixed in template paths.
-
- (Array<String>) full_paths
A list of full paths.
- - (Object) initialize(path, full_paths)
- - (Boolean) is_a?(klass)
-
- (Object) new(*args)
Creates a new template object to be rendered with #run.
-
- (Object) reset_full_paths
Resets cache for #full_paths.
- - (Object) run(*args)
-
- (Object) S(*args)
Alias for creating a Section with arguments.
- - (Object) T(*path)
Instance Attribute Details
- (Object) full_path
Returns the value of attribute full_path
59 60 61 |
# File 'lib/yard/templates/template.rb', line 59 def full_path @full_path end |
- (Object) path
Returns the value of attribute path
59 60 61 |
# File 'lib/yard/templates/template.rb', line 59 def path @path end |
Instance Method Details
- (String) find_file(basename)
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.
97 98 99 |
# File 'lib/yard/templates/template.rb', line 97 def find_file(basename) find_nth_file(basename) end |
- (String) find_nth_file(basename, index = 1)
Searches for the nth file (where n = index) identified by basename in the template's path and any mixed in template paths.
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/yard/templates/template.rb', line 108 def find_nth_file(basename, index = 1) n = 1 full_paths.each do |path| file = File.join(path, basename) if File.file?(file) return file if index == n n += 1 end end nil end |
- (Array<String>) full_paths
This method caches path results. Paths should not be modified after this method is called; call #reset_full_paths to reset cache.
Returns a list of full paths
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/yard/templates/template.rb', line 64 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 |
- (Object) initialize(path, full_paths)
80 81 82 83 84 85 86 87 |
# File 'lib/yard/templates/template.rb', line 80 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 |
- (Boolean) is_a?(klass)
121 122 123 124 |
# File 'lib/yard/templates/template.rb', line 121 def is_a?(klass) return true if klass == Template super(klass) end |
- (Object) new(*args)
Creates a new template object to be rendered with YARD::Templates::Template#run
127 128 129 130 131 132 |
# File 'lib/yard/templates/template.rb', line 127 def new(*args) obj = Object.new.extend(self) obj.class = self obj.send(:initialize, *args) obj end |
- (Object) reset_full_paths
Resets cache for #full_paths
76 77 78 |
# File 'lib/yard/templates/template.rb', line 76 def reset_full_paths @cached_included_modules = nil end |
- (Object) run(*args)
134 135 136 |
# File 'lib/yard/templates/template.rb', line 134 def run(*args) new(*args).run end |
- (Object) S(*args)
Alias for creating a Section with arguments
145 146 147 |
# File 'lib/yard/templates/template.rb', line 145 def S(*args) Section.new(*args) end |
- (Object) T(*path)
138 139 140 |
# File 'lib/yard/templates/template.rb', line 138 def T(*path) Engine.template(*path) end |