Sha256: 61a0689bb4ddc463eb2d5de9b0abe47a97967a0a064a14b6ef9c8c4aa4120ab9
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
module Octopress module Docs class Doc attr_reader :filename, :plugin_name, :base_url def initialize(options={}) @file = options[:file] @dir = options[:dir] ||= '.' @file_dir = File.dirname(@file) @plugin_name = options[:name] @plugin_slug = options[:slug] @plugin_type = options[:type] @base_url = options[:base_url] @data = options[:data] || {} end # Add doc page to Jekyll pages # def add if Octopress.config['docs_mode'] Octopress.site.pages << page end end def disabled? false end def file File.basename(@file) end def info " - #{permalink.ljust(35)}" end def page return @page if @page @page = Octopress::Docs::Page.new(Octopress.site, @dir, page_dir, file, {'path'=>@base_url}) @page.data['layout'] = 'docs' @page.data['plugin'] = { 'name' => @plugin_name, 'slug' => plugin_slug, 'docs_base_url' => @base_url } @page.data['dir'] = doc_dir @page.data = @data.merge(@page.data) @page end private def permalink File.basename(file, ".*") end def read File.open(File.join(@dir, @file)).read end def plugin_slug Jekyll::Utils.slugify(@plugin_type == 'theme' ? 'theme' : @plugin_slug) end def page_dir @file_dir == '.' ? '' : @file_dir end def doc_dir File.join(@dir, page_dir, File.dirname(@file)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
octopress-docs-0.0.9 | lib/octopress-docs/doc.rb |