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

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

#gemObject (readonly)

Returns the value of attribute gem.



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

def gem
  @gem
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#slugObject (readonly)

Returns the value of attribute slug.



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

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

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#addObject

Add doc page to Jekyll pages



23
24
25
# File 'lib/octopress/docs/doc.rb', line 23

def add
  Octopress.site.pages << page
end

#disabled?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/octopress/docs/doc.rb', line 27

def disabled?
  false
end

#fileObject



31
32
33
# File 'lib/octopress/docs/doc.rb', line 31

def file
  File.basename(@file)
end

#infoObject



35
36
37
# File 'lib/octopress/docs/doc.rb', line 35

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

#pageObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/octopress/docs/doc.rb', line 39

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'        => @name, 
      'slug'        => @slug,
      'type'        => @type,
      'source_url'  => @source_url,
      'description' => @description,
      'url'         => @base_url,
      'version'     => @version,
      'gem'         => @gem,
    }

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