Class: Octopress::Docs::Doc

Inherits:
Object
  • Object
show all
Defined in:
lib/octopress-docs/doc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Doc

Returns a new instance of Doc.



6
7
8
9
10
11
12
13
14
15
# File 'lib/octopress-docs/doc.rb', line 6

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]
  @index           = options[:index]
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



4
5
6
# File 'lib/octopress-docs/doc.rb', line 4

def base_url
  @base_url
end

#filenameObject (readonly)

Returns the value of attribute filename.



4
5
6
# File 'lib/octopress-docs/doc.rb', line 4

def filename
  @filename
end

#plugin_nameObject (readonly)

Returns the value of attribute plugin_name.



4
5
6
# File 'lib/octopress-docs/doc.rb', line 4

def plugin_name
  @plugin_name
end

Instance Method Details

#addObject

Add doc page to Jekyll pages



19
20
21
22
23
# File 'lib/octopress-docs/doc.rb', line 19

def add
  if Octopress.config['docs_mode']
    Octopress.site.pages << page
  end
end

#disabled?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/octopress-docs/doc.rb', line 25

def disabled?
  false
end

#fileObject



29
30
31
# File 'lib/octopress-docs/doc.rb', line 29

def file
  File.basename(@file)
end

#infoObject



33
34
35
# File 'lib/octopress-docs/doc.rb', line 33

def info
  "  - #{permalink.ljust(35)}"
end

#pageObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/octopress-docs/doc.rb', line 37

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['permalink'] = "/" if @index
  @page
end