octopress-docs 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0878e319fb7db83f2aac9b31a74237537f938079
4
- data.tar.gz: 681bec4bb92b553a2f37fb790a29fb8d01e8e150
3
+ metadata.gz: 9016278546132adf8327ea7465ed5a6d337b3679
4
+ data.tar.gz: 80a53837d9f7cc202ca720b9c7d24547f7582ffe
5
5
  SHA512:
6
- metadata.gz: 76ff3ea327d241f8608f97c2396f3d23cf7b60a2db9945bed6b27cf34fb38e1c509cc92ba440ca58716eafa5a5656e0c21b3d3edcb986662f133e0b589356178
7
- data.tar.gz: 25c729ff14d795020c18f6c3459500818bc146e502df8dfedaa50b0cacd0e5db4367a293ce74903df0e1d6c6154dae97de61647485f808161ce7fba97a5c9d72
6
+ metadata.gz: 5f8aec83d98d4ccf8099dd60e39a0e50b44615b057410614eca9364afc8a940d6d6a0580e59293082d891b47a1686eae53af46efca6a55fc754347bd82608564
7
+ data.tar.gz: c90728916468f1d7ecdb79fd01b5ee11bf480688f1dc33ecee41f8c4d28148d53bd8f4c6c94e40da565d37324a91632fe8aec76431ca70c2dc8291ad4261fa04
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  {% css_asset_tag %}
5
5
  <link rel='stylesheet' href='/stylesheets/site.css'>
6
+ <title>{{ page.title }}</title>
6
7
  </head>
7
8
  <body>
8
9
  {{ content }}
@@ -20,6 +20,7 @@ module Octopress
20
20
  end
21
21
 
22
22
  def self.serve_docs(options)
23
+ Octopress::Docs.docs_mode = true
23
24
  if options['jekyll']
24
25
  options = init_jekyll_docs(options)
25
26
  else
@@ -60,7 +61,7 @@ module Octopress
60
61
  end
61
62
 
62
63
  def self.require_plugins
63
- config = Octopress.site.config
64
+ config = Octopress::Configuration.jekyll_config
64
65
 
65
66
  if config['gems'].is_a?(Array)
66
67
  config['gems'].each {|g| require g }
@@ -78,10 +79,12 @@ module Octopress
78
79
 
79
80
  # Returns an Array of plugin search paths
80
81
  def self.plugins_path
81
- if (Octopress.site.config['plugins'] == Jekyll::Configuration::DEFAULTS['plugins'])
82
- [Jekyll.sanitized_path(Octopress.site.source, Octopress.site.config['plugins'])]
82
+ config = Octopress::Configuration.jekyll_config
83
+ plugins = config['plugins']
84
+ if (plugins == Jekyll::Configuration::DEFAULTS['plugins'])
85
+ [Jekyll.sanitized_path(config['source'], plugins)]
83
86
  else
84
- Array(Octopress.site.config['plugins']).map { |d| File.expand_path(d) }
87
+ Array(plugins).map { |d| File.expand_path(d) }
85
88
  end
86
89
  end
87
90
 
@@ -11,7 +11,7 @@ module Octopress
11
11
  @plugin_slug = options[:slug]
12
12
  @plugin_type = options[:type]
13
13
  @base_url = options[:base_url]
14
- @index = options[:index]
14
+ @data = options[:data] || {}
15
15
  end
16
16
 
17
17
  # Add doc page to Jekyll pages
@@ -44,7 +44,7 @@ module Octopress
44
44
  'docs_base_url' => @base_url
45
45
  }
46
46
  @page.data['dir'] = doc_dir
47
- @page.data['permalink'] = "/" if @index
47
+ @page.data = @data.merge(@page.data)
48
48
  @page
49
49
  end
50
50
 
@@ -59,7 +59,7 @@ module Octopress
59
59
  end
60
60
 
61
61
  def plugin_slug
62
- Filters.sluggify @plugin_type == 'theme' ? 'theme' : @plugin_slug
62
+ Jekyll::Utils.slugify(@plugin_type == 'theme' ? 'theme' : @plugin_slug)
63
63
  end
64
64
 
65
65
  def page_dir
@@ -1,14 +1,20 @@
1
1
  module Octopress
2
2
  module Docs
3
3
  class DocsSiteHook < Octopress::Hooks::Site
4
+ def post_read(site)
5
+ if Octopress::Docs.docs_mode && Octopress.site.nil?
6
+ Octopress.site = site
7
+ end
8
+ end
9
+
4
10
  def pre_render(site)
5
- if Octopress.config['docs_mode']
11
+ if Octopress::Docs.docs_mode
6
12
  site.pages.concat Octopress::Docs.pages
7
13
  end
8
14
  end
9
15
 
10
16
  def merge_payload(payload, site)
11
- if Octopress.config['docs_mode']
17
+ if Octopress::Docs.docs_mode
12
18
  Octopress::Docs.pages_info
13
19
  end
14
20
  end
@@ -17,7 +17,7 @@ module Octopress
17
17
  end
18
18
 
19
19
  def hooks
20
- self.site.page_hooks
20
+ Octopress.site.page_hooks
21
21
  end
22
22
 
23
23
  def destination(dest)
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Docs
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
@@ -12,9 +12,20 @@ require "octopress-docs/tag"
12
12
  require "octopress-docs/hooks"
13
13
 
14
14
  module Octopress
15
+ unless defined? Octopress.site
16
+ def self.site
17
+ @site
18
+ end
19
+
20
+ def self.site=(site)
21
+ @site = site
22
+ end
23
+ end
24
+
15
25
  module Docs
16
26
  attr_reader :docs
17
27
  @docs = {}
28
+ @docs_mode = false
18
29
 
19
30
  autoload :Doc, 'octopress-docs/doc'
20
31
 
@@ -22,6 +33,14 @@ module Octopress
22
33
  File.expand_path(File.join(File.dirname(__FILE__), '../', dir))
23
34
  end
24
35
 
36
+ def self.docs_mode
37
+ @docs_mode
38
+ end
39
+
40
+ def self.docs_mode=(mode)
41
+ @docs_mode = mode
42
+ end
43
+
25
44
  # Get all doc pages
26
45
  #
27
46
  def self.pages
@@ -58,14 +77,10 @@ module Octopress
58
77
 
59
78
  def self.add_plugin_docs(plugin)
60
79
  options = plugin_options(plugin)
61
- plugin_doc_pages = add_asset_docs(options)
62
-
63
- # If there is no docs index page, set the reame as the index page
64
- has_index = !plugin_doc_pages.select {|d| d.file =~ /^index/ }.empty?
65
- plugin_doc_pages << add_root_plugin_doc(plugin, 'readme', index: !has_index)
66
-
67
- plugin_doc_pages << add_root_plugin_doc(plugin, 'changelog')
80
+ options[:docs] ||= %w{readme docs}
68
81
 
82
+ plugin_doc_pages = add_asset_docs(options)
83
+ plugin_doc_pages.concat add_root_docs(options, plugin_doc_pages)
69
84
  plugin_doc_pages
70
85
  end
71
86
 
@@ -86,6 +101,7 @@ module Octopress
86
101
  options[:slug] = slug(options)
87
102
  options[:base_url] = base_url(options)
88
103
  options[:dir] ||= '.'
104
+ options
89
105
  end
90
106
 
91
107
  def self.slug(options)
@@ -103,21 +119,26 @@ module Octopress
103
119
 
104
120
  def self.add(options)
105
121
  options[:docs] ||= %w{readme changelog}
122
+ options = default_options(options)
106
123
  options[:docs_path] ||= File.join(options[:dir], 'assets', 'docs')
107
124
  docs = []
108
- docs.concat add_root_docs(options)
109
125
  docs.concat add_asset_docs(options)
126
+ docs.concat add_root_docs(options, docs)
110
127
  docs.compact!
111
128
  end
112
129
 
113
- def self.add_root_docs(options)
130
+ def self.add_root_docs(options, asset_docs=[])
114
131
  root_docs = []
115
132
  options[:docs].each do |doc|
116
- if doc =~ /readme/
117
- root_docs << add_root_doc(doc, options.merge({index: true}))
118
- else
119
- root_docs << add_root_doc(doc, options)
133
+ doc_data = {
134
+ 'title' => doc.capitalize
135
+ }
136
+
137
+ if doc =~ /readme/ && asset_docs.select {|d| d.file =~ /^index/ }.empty?
138
+ doc_data['permalink'] = '/'
120
139
  end
140
+
141
+ root_docs << add_root_doc(doc, options.merge(data: doc_data))
121
142
  end
122
143
  root_docs
123
144
  end
@@ -129,11 +150,6 @@ module Octopress
129
150
  end
130
151
  end
131
152
 
132
- def self.add_root_plugin_doc(plugin, filename, options={})
133
- options = plugin_options(plugin).merge(options)
134
- add_root_doc(filename, options)
135
- end
136
-
137
153
  def self.add_doc_page(options)
138
154
  page = Docs::Doc.new(options)
139
155
  @docs[options[:slug]] ||= []
@@ -169,6 +185,5 @@ module Octopress
169
185
  def self.select_first(dir, match)
170
186
  Dir.new(dir).select { |f| f =~/#{match}/i}.first
171
187
  end
172
-
173
188
  end
174
189
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry-debugger
84
+ name: pry-byebug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="