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
16
17
# File 'lib/octopress-docs/doc.rb', line 6

def initialize(options={})
  @file            = options[:file]
  @path            = options[:path] ||= '.'
  @file_dir        = File.dirname(@file)
  @plugin_name     = options[:name]
  @plugin_slug     = options[:slug]
  @plugin_type     = options[:type]
  @base_url        = options[:base_url]
  @source_url      = options[:source_url]
  @description     = options[:description]
  @data            = options[:data] || {}
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

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
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

#plugin_typeObject (readonly)

Returns the value of attribute plugin_type.



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

def plugin_type
  @plugin_type
end

#source_urlObject (readonly)

Returns the value of attribute source_url.



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

def source_url
  @source_url
end

Instance Method Details

#addObject

Add doc page to Jekyll pages



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

def add
  Octopress.site.pages << page
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
50
51
52
53
54
55
56
57
# File 'lib/octopress-docs/doc.rb', line 37

def page
  @page ||= begin
    p = Octopress::Docs::Page.new(Octopress.site, @path, page_dir, file, {'path'=>@base_url})
    p.data['layout'] = 'docs'
    p.data['escape_code'] = true

    p.data['plugin'] = { 
      'name'        => @plugin_name, 
      'slug'        => @plugin_slug,
      'type'        => @plugin_type,
      'source_url'  => @source_url,
      'description' => @description,
      'url'         => @base_url
    }

    p.data['dir'] = doc_dir
    p.data = @data.merge(p.data)
    p.data.merge!(comment_yaml(p.content))
    p
  end
end