class Vocco::Generator::SourceFile
Constants
- HTML_TEMPLATE
- NOTE_FORMATS
Attributes
file[R]
Public Class Methods
new(file, generator)
click to toggle source
# File lib/vocco/generator/source_file.rb, line 9 def initialize(file, generator) @file = file @gen = generator end
Public Instance Methods
basename()
click to toggle source
# File lib/vocco/generator/source_file.rb, line 21 def basename File.basename(@file) end
dirname()
click to toggle source
full dirname
# File lib/vocco/generator/source_file.rb, line 17 def dirname File.dirname(@file) end
doc_basename()
click to toggle source
corresponding doc file basename
# File lib/vocco/generator/source_file.rb, line 36 def doc_basename doc_scope + basename + '.html' end
doc_link()
click to toggle source
relative link to doc
# File lib/vocco/generator/source_file.rb, line 46 def doc_link './' + doc_basename end
doc_path()
click to toggle source
corresponding doc file path
# File lib/vocco/generator/source_file.rb, line 41 def doc_path File.join(@gen.out, doc_basename) end
notes()
click to toggle source
# File lib/vocco/generator/source_file.rb, line 50 def notes @notes ||= Dir[note_glob].map do |path| Tilt.new(path).render end end
short_dirname()
click to toggle source
dirname of the above
# File lib/vocco/generator/source_file.rb, line 31 def short_dirname File.dirname(short_path).sub(/^\.\//, '') end
short_path()
click to toggle source
file path with glob dir scope trimmed off
# File lib/vocco/generator/source_file.rb, line 26 def short_path @short_path ||= @file.sub(@gen.glob_regex, '') end
Private Instance Methods
doc_scope()
click to toggle source
doc filename prefix based on source file folder
# File lib/vocco/generator/source_file.rb, line 65 def doc_scope short_dirname == '.' ? '' : short_dirname.gsub('/', '-') + '-' end
note_dirs()
click to toggle source
the dirs in which to look for notes concerning this file.
# File lib/vocco/generator/source_file.rb, line 70 def note_dirs @gen.notes.inject([dirname]) do |dirs, dir| dirs << File.join(dir, short_dirname) end end
note_glob()
click to toggle source
glob matching notes concerning this file
# File lib/vocco/generator/source_file.rb, line 77 def note_glob '{' + note_dirs.join(',') + '}/' + basename + NOTE_FORMATS end