octopress 3.0.0.rc.23 → 3.0.0.rc.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/assets/docs/docs.md +28 -0
- data/lib/octopress.rb +2 -1
- data/lib/octopress/commands/docs.rb +41 -0
- data/lib/octopress/docs.rb +256 -0
- data/lib/octopress/docs/doc.rb +91 -0
- data/lib/octopress/docs/hooks.rb +19 -0
- data/lib/octopress/docs/jekyll/convertible.rb +32 -0
- data/lib/octopress/docs/jekyll/page.rb +52 -0
- data/lib/octopress/docs/liquid_filters.rb +14 -0
- data/lib/octopress/version.rb +1 -1
- data/local/Gemfile +11 -0
- data/local/_config.yml +5 -0
- data/local/_includes/nav.html +7 -0
- data/local/_layouts/default.html +12 -0
- data/local/_layouts/docs.html +15 -0
- data/local/_layouts/docs_index.html +7 -0
- data/local/_plugins/docs.rb +5 -0
- data/local/_sass/_solarized.scss +1 -0
- data/local/index.html +13 -0
- data/local/stylesheets/site.scss +3 -0
- data/site/Gemfile +12 -0
- data/site/_config.yml +7 -0
- data/site/_includes/nav.html +7 -0
- data/site/_layouts/default.html +14 -0
- data/site/_layouts/docs.html +15 -0
- data/site/_layouts/docs_index.html +7 -0
- data/site/_plugins/docs.rb +2 -0
- data/site/index.html +13 -0
- data/site/stylesheets/site.scss +2 -0
- metadata +50 -82
- data/.clash.yml +0 -164
- data/.gitignore +0 -21
- data/.travis.yml +0 -8
- data/Gemfile +0 -4
- data/Rakefile +0 -1
- data/octopress.gemspec +0 -35
- data/scaffold/_templates/draft +0 -4
- data/scaffold/_templates/page +0 -4
- data/scaffold/_templates/post +0 -5
- data/test/Gemfile +0 -3
- data/test/_config.yml +0 -3
- data/test/_expected/blank/_config.yml +0 -1
- data/test/_expected/blank/_templates/draft +0 -4
- data/test/_expected/blank/_templates/page +0 -4
- data/test/_expected/blank/_templates/post +0 -5
- data/test/_expected/blank/index.html +0 -0
- data/test/_expected/integrate/_posts/2011-11-11-a-random-post.markdown +0 -6
- data/test/_expected/integrate/_posts/2012-11-11-another-random-post.markdown +0 -6
- data/test/_expected/integrate/_posts/2013-11-11-this-post-is-happy.markdown +0 -6
- data/test/_expected/isolate-path/_posts/2011-11-11-a-random-post.markdown +0 -6
- data/test/_expected/isolate-path/_posts/_exile/2012-11-11-another-random-post.markdown +0 -6
- data/test/_expected/isolate-path/_posts/_exile/2013-11-11-this-post-is-happy.markdown +0 -6
- data/test/_expected/isolate-search/_posts/2011-11-11-a-random-post.markdown +0 -6
- data/test/_expected/isolate-search/_posts/2012-11-11-another-random-post.markdown +0 -6
- data/test/_expected/isolate-search/_posts/_exile/2013-11-11-this-post-is-happy.markdown +0 -6
- data/test/_expected/isolate/_posts/2013-11-11-this-post-is-happy.markdown +0 -6
- data/test/_expected/isolate/_posts/_exile/2011-11-11-a-random-post.markdown +0 -6
- data/test/_expected/isolate/_posts/_exile/2012-11-11-another-random-post.markdown +0 -6
- data/test/_expected/new-draft-slug/_drafts/idea.markdown +0 -5
- data/test/_expected/new-draft/_drafts/some-cool-idea.markdown +0 -6
- data/test/_expected/new-page-date/pages/awesome-page.html +0 -6
- data/test/_expected/new-page-extension/pages/awesome-page.md +0 -5
- data/test/_expected/new-page-index/pages/index.html +0 -5
- data/test/_expected/new-page-template/pages/awesome-page.html +0 -6
- data/test/_expected/new-page/pages/awesome-page.html +0 -5
- data/test/_expected/new-post-dir/_posts/stuff/2014-02-11-some-stuff.markdown +0 -6
- data/test/_expected/new-post-slug/_posts/2014-03-13-awesome.markdown +0 -6
- data/test/_expected/new-post/_posts/2014-03-12-awesome-stuff.markdown +0 -6
- data/test/_expected/publish-draft-date/_posts/2014-03-11-some-cool-idea.markdown +0 -6
- data/test/_expected/publish-draft-dir/_posts/ideas/2014-03-10-some-cool-idea.markdown +0 -6
- data/test/_expected/publish-draft/_posts/2014-03-10-some-cool-idea.markdown +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80b8a068d4811564da346c04165ff5958a72545b
|
4
|
+
data.tar.gz: 38db301d32c4ab9eebcfc5a4ad9ea9df4e5bb08a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc120b3c743aa1d11bc6ab6f553f6a4c08f7b295a983560c609439119d162a9f86f45a4c9981d5608da0dc76f536b4cbebfb1732950dae9fa93444f521e10c1e
|
7
|
+
data.tar.gz: 060dfc709a8f52b7fb910d3a3ff194490b64bd67a16820432fc43f2b99ebd421c820a5b61a0f28799c560b864bb2390388badd171de94fbeed37fd116cdcf53f
|
data/CHANGELOG.md
CHANGED
data/assets/docs/docs.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
title: Documentation Plugins
|
3
|
+
permalink: /docs/
|
4
|
+
---
|
5
|
+
|
6
|
+
# Octopress Docs
|
7
|
+
|
8
|
+
If you have the Octopress gem installed, run `$ octopress docs` from the root of your Jekyll site, and a website will mount at `http://localhost:4444` with documentation for Octopress and any plugins which support this feature.
|
9
|
+
|
10
|
+
## Adding docs to your plugin
|
11
|
+
|
12
|
+
If your plugin is built on Octopress Ink, these documentation pages are added automatically. If not, use
|
13
|
+
the code below to automatically add your plugin's Readme, Changelog and any pages in your gem path under `assets/docs`.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
if defined? Octopress::Docs
|
17
|
+
Octopress::Docs.add({
|
18
|
+
name: "Your Plugin",
|
19
|
+
description: "This plugin causes awesomeness",
|
20
|
+
path: File.expand_path(File.join(File.dirname(__FILE__), "../")), # gem root
|
21
|
+
slug: "your-plugin", # optional
|
22
|
+
source_url: "https://github.com/some/project", # optional
|
23
|
+
website: "http://example.com", # optional
|
24
|
+
})
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
It's a bit odd, but the `if defined? Octopress::Docs` allows you to register doc pages if possible, without having to add the octopress gem as a dependency.
|
data/lib/octopress.rb
CHANGED
@@ -5,11 +5,12 @@ module Octopress
|
|
5
5
|
require 'octopress/command'
|
6
6
|
require 'octopress/version'
|
7
7
|
require 'octopress/commands/new'
|
8
|
+
require 'octopress/commands/docs'
|
8
9
|
require 'octopress/commands/init'
|
9
10
|
require 'octopress/commands/publish'
|
10
11
|
require 'octopress/commands/isolate'
|
11
12
|
require 'octopress/isolate'
|
12
|
-
require 'octopress
|
13
|
+
require 'octopress/docs'
|
13
14
|
|
14
15
|
autoload :Page, 'octopress/page'
|
15
16
|
autoload :Post, 'octopress/post'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Docs
|
3
|
+
class Commands < Octopress::Command
|
4
|
+
def self.init_with_program(p)
|
5
|
+
p.command(:docs) do |c|
|
6
|
+
c.syntax 'octopress docs'
|
7
|
+
c.description "Launch local server with docs for Octopress v#{Octopress::VERSION} and Octopress plugins."
|
8
|
+
|
9
|
+
c.option 'port', '-P', '--port [PORT]', 'Port to listen on'
|
10
|
+
c.option 'host', '-H', '--host [HOST]', 'Host to bind to'
|
11
|
+
if ENV['OCTODEV']
|
12
|
+
c.option 'watch', '--watch', 'Watch docs site for changes and rebuild. (For docs development)'
|
13
|
+
end
|
14
|
+
|
15
|
+
c.action do |args, options|
|
16
|
+
serve_docs(options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.serve_docs(options)
|
22
|
+
|
23
|
+
# Activate dependencies for serving docs.
|
24
|
+
#
|
25
|
+
options = Docs.load_docs(options)
|
26
|
+
Octopress::Ink.load_plugin_assets = false
|
27
|
+
|
28
|
+
|
29
|
+
Jekyll.logger.log_level = :error
|
30
|
+
Jekyll::Commands::Build.process(options)
|
31
|
+
url = "http://#{options['host']}:#{options['port']}"
|
32
|
+
puts "Serving Docs site: #{url}"
|
33
|
+
puts " press ctrl-c to stop."
|
34
|
+
Jekyll::Commands::Serve.process(options)
|
35
|
+
Jekyll.logger.log_level = :info
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -0,0 +1,256 @@
|
|
1
|
+
require "find"
|
2
|
+
require "octopress/docs/doc"
|
3
|
+
|
4
|
+
module Octopress
|
5
|
+
module Docs
|
6
|
+
attr_reader :docs
|
7
|
+
@docs = {}
|
8
|
+
@enabled = false
|
9
|
+
|
10
|
+
autoload :Doc, 'octopress/docs/doc'
|
11
|
+
|
12
|
+
def self.pages
|
13
|
+
doc_pages.values.flatten
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.enabled?
|
17
|
+
@enabled
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.doc_pages
|
21
|
+
if !@pages
|
22
|
+
@pages = @docs.dup
|
23
|
+
|
24
|
+
@pages.each do |slug, docs|
|
25
|
+
|
26
|
+
# Convert docs to pages
|
27
|
+
#
|
28
|
+
docs.map! { |doc| doc.page }
|
29
|
+
|
30
|
+
# Inject docs links from other docs pages
|
31
|
+
#
|
32
|
+
docs.map! do |doc|
|
33
|
+
doc.data = doc.data.merge({
|
34
|
+
'docs' => plugin_page_links(@pages[slug])
|
35
|
+
})
|
36
|
+
doc
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
@pages
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.plugin_page_links(pages)
|
44
|
+
pages.clone.map { |page|
|
45
|
+
data = page.data
|
46
|
+
title = data['link_title'] || data['title'] || page.basename
|
47
|
+
url = File.join('/', data['plugin']['url'], page.url.sub('index.html', ''))
|
48
|
+
|
49
|
+
{
|
50
|
+
'title' => title,
|
51
|
+
'url' => url
|
52
|
+
}
|
53
|
+
}.sort_by { |i|
|
54
|
+
# Sort by depth of url
|
55
|
+
i['url'].split('/').size
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
# Return a hash of plugin docs information
|
61
|
+
# for Jekyll site payload
|
62
|
+
#
|
63
|
+
def self.pages_info
|
64
|
+
docs = {}
|
65
|
+
|
66
|
+
# Retrieve plugin info from docs
|
67
|
+
#
|
68
|
+
doc_pages.each do |slug, pages|
|
69
|
+
data = pages.first.data
|
70
|
+
docs[slug] = data['plugin'].merge({
|
71
|
+
'pages' => data['docs']
|
72
|
+
})
|
73
|
+
end
|
74
|
+
|
75
|
+
# Sort docs alphabetically by name
|
76
|
+
#
|
77
|
+
docs = Hash[docs.sort_by { |k,v| v['name'] }]
|
78
|
+
|
79
|
+
@pages_info = { 'plugin_docs' => docs }
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.add_plugin_docs(plugin)
|
83
|
+
options = plugin_options(plugin)
|
84
|
+
options[:docs] ||= %w{readme docs}
|
85
|
+
|
86
|
+
plugin_doc_pages = add_asset_docs(options)
|
87
|
+
plugin_doc_pages.concat add_root_docs(options, plugin_doc_pages)
|
88
|
+
plugin_doc_pages
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.plugin_options(plugin)
|
92
|
+
options = {
|
93
|
+
name: plugin.name,
|
94
|
+
slug: plugin.slug,
|
95
|
+
type: plugin.type,
|
96
|
+
path: plugin.path,
|
97
|
+
source_url: plugin.source_url,
|
98
|
+
website: plugin.website,
|
99
|
+
docs_path: File.join(plugin.assets_path, 'docs'),
|
100
|
+
docs: %w{readme changelog}
|
101
|
+
}
|
102
|
+
|
103
|
+
options[:base_url] = base_url(options)
|
104
|
+
options
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.default_options(options)
|
108
|
+
options[:docs] ||= %w{readme changelog}
|
109
|
+
options[:type] ||= 'plugin'
|
110
|
+
options[:slug] = slug(options)
|
111
|
+
options[:base_url] = base_url(options)
|
112
|
+
options[:path] ||= '.'
|
113
|
+
options[:docs_path] ||= File.join(options[:path], 'assets', 'docs')
|
114
|
+
options
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.slug(options)
|
118
|
+
slug = options[:slug] || options[:name]
|
119
|
+
options[:type] == 'theme' ? 'theme' : Jekyll::Utils.slugify(slug)
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.base_url(options)
|
123
|
+
options[:base_url] || if options[:type] == 'theme'
|
124
|
+
'theme'
|
125
|
+
else
|
126
|
+
if options[:source_url] =~ /github\.com\/(octopress|imathis)/
|
127
|
+
File.join('octopress', options[:slug].sub(/octopress-/,''))
|
128
|
+
else
|
129
|
+
File.join('plugins', options[:slug])
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# Add doc pages for a plugin
|
135
|
+
#
|
136
|
+
# Input: options describing a plugin
|
137
|
+
#
|
138
|
+
# Output: array of docs
|
139
|
+
#
|
140
|
+
def self.add(options)
|
141
|
+
options = default_options(options)
|
142
|
+
docs = []
|
143
|
+
docs.concat add_asset_docs(options)
|
144
|
+
docs.concat add_root_docs(options, docs)
|
145
|
+
docs.compact!
|
146
|
+
end
|
147
|
+
|
148
|
+
# Add pages from the root of a gem (README, CHANGELOG, etc)
|
149
|
+
#
|
150
|
+
def self.add_root_docs(options, asset_docs=[])
|
151
|
+
root_docs = []
|
152
|
+
options[:docs].each do |doc|
|
153
|
+
doc_data = {
|
154
|
+
'title' => doc.capitalize
|
155
|
+
}
|
156
|
+
|
157
|
+
if doc =~ /readme/ && asset_docs.select {|d| d.file =~ /^index/ }.empty?
|
158
|
+
doc_data['permalink'] = '/'
|
159
|
+
end
|
160
|
+
|
161
|
+
root_docs << add_root_doc(doc, options.merge(data: doc_data))
|
162
|
+
end
|
163
|
+
root_docs
|
164
|
+
end
|
165
|
+
|
166
|
+
# Add a single root doc
|
167
|
+
#
|
168
|
+
def self.add_root_doc(filename, options)
|
169
|
+
if file = select_first(options[:path], filename)
|
170
|
+
add_doc_page(options.merge({file: file}))
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Register a new doc page for a plugin
|
175
|
+
#
|
176
|
+
def self.add_doc_page(options)
|
177
|
+
page = Docs::Doc.new(options)
|
178
|
+
@docs[options[:slug]] ||= []
|
179
|
+
@docs[options[:slug]] << page
|
180
|
+
page
|
181
|
+
end
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
# Add doc pages from /asset/docs
|
186
|
+
#
|
187
|
+
def self.add_asset_docs(options)
|
188
|
+
docs = []
|
189
|
+
find_doc_pages(options[:docs_path]).each do |doc|
|
190
|
+
unless doc =~ /^_/
|
191
|
+
opts = options.merge({file: doc, path: options[:docs_path]})
|
192
|
+
docs << add_doc_page(opts)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
docs
|
196
|
+
end
|
197
|
+
|
198
|
+
# Find all files in a directory recursively
|
199
|
+
#
|
200
|
+
def self.find_doc_pages(dir)
|
201
|
+
|
202
|
+
return [] unless Dir.exist? dir
|
203
|
+
|
204
|
+
Find.find(dir).to_a.reject do |f|
|
205
|
+
File.directory? f
|
206
|
+
end.map do |f|
|
207
|
+
# truncate file to relative path
|
208
|
+
f.sub(dir+'/', '')
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.select_first(dir, match)
|
213
|
+
Dir.new(dir).select { |f| f =~/#{match}/i}.first
|
214
|
+
end
|
215
|
+
|
216
|
+
def self.load_docs(options=nil)
|
217
|
+
@enabled = true
|
218
|
+
|
219
|
+
require "octopress-hooks"
|
220
|
+
require "octopress/docs/hooks"
|
221
|
+
require "octopress/docs/liquid_filters"
|
222
|
+
require "octopress/docs/jekyll/convertible"
|
223
|
+
require "octopress/docs/jekyll/page"
|
224
|
+
|
225
|
+
if !options.nil?
|
226
|
+
# Look at the local site and require all of its plugins
|
227
|
+
# Ensuring their documentation is loaded into the docs site
|
228
|
+
#
|
229
|
+
site = Octopress.read_site({'config'=>options['config']})
|
230
|
+
site.plugin_manager.conscientious_require
|
231
|
+
|
232
|
+
# Require escape code last to set Octopress hook priority.
|
233
|
+
#
|
234
|
+
options = Docs.site.config.merge(options)
|
235
|
+
end
|
236
|
+
|
237
|
+
require "octopress-escape-code"
|
238
|
+
options
|
239
|
+
end
|
240
|
+
|
241
|
+
def self.site(options={})
|
242
|
+
@site ||= Octopress.site(site_options.merge(options))
|
243
|
+
end
|
244
|
+
|
245
|
+
def self.site_options
|
246
|
+
source = Octopress.gem_dir('local')
|
247
|
+
{
|
248
|
+
'source' => source,
|
249
|
+
'destination' => File.join(source, '/_site'),
|
250
|
+
'layouts' => File.join(source, '/_layouts'),
|
251
|
+
'port' => '4444',
|
252
|
+
'serving' => true,
|
253
|
+
}
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Docs
|
3
|
+
class Doc
|
4
|
+
attr_reader :filename, :plugin_name, :plugin_slug, :base_url, :plugin_type, :description, :source_url
|
5
|
+
|
6
|
+
def initialize(options={})
|
7
|
+
@file = options[:file]
|
8
|
+
@path = options[:path] ||= '.'
|
9
|
+
@file_dir = File.dirname(@file)
|
10
|
+
@plugin_name = options[:name]
|
11
|
+
@plugin_slug = options[:slug]
|
12
|
+
@plugin_type = options[:type]
|
13
|
+
@base_url = options[:base_url]
|
14
|
+
@source_url = options[:source_url]
|
15
|
+
@description = options[:description]
|
16
|
+
@data = options[:data] || {}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Add doc page to Jekyll pages
|
20
|
+
#
|
21
|
+
def add
|
22
|
+
Octopress.site.pages << page
|
23
|
+
end
|
24
|
+
|
25
|
+
def disabled?
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def file
|
30
|
+
File.basename(@file)
|
31
|
+
end
|
32
|
+
|
33
|
+
def info
|
34
|
+
" - #{permalink.ljust(35)}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def page
|
38
|
+
@page ||= begin
|
39
|
+
p = Octopress::Docs::Page.new(Octopress.site, @path, page_dir, file, {'path'=>@base_url})
|
40
|
+
p.data['layout'] = 'docs'
|
41
|
+
p.data['escape_code'] = true
|
42
|
+
|
43
|
+
p.data['plugin'] = {
|
44
|
+
'name' => @plugin_name,
|
45
|
+
'slug' => @plugin_slug,
|
46
|
+
'type' => @plugin_type,
|
47
|
+
'source_url' => @source_url,
|
48
|
+
'description' => @description,
|
49
|
+
'url' => @base_url
|
50
|
+
}
|
51
|
+
|
52
|
+
p.data['dir'] = doc_dir
|
53
|
+
p.data = @data.merge(p.data)
|
54
|
+
p.data.merge!(comment_yaml(p.content))
|
55
|
+
p
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def permalink
|
62
|
+
File.basename(file, ".*")
|
63
|
+
end
|
64
|
+
|
65
|
+
def read
|
66
|
+
File.open(File.join(@path, @file)).read
|
67
|
+
end
|
68
|
+
|
69
|
+
def plugin_slug
|
70
|
+
Jekyll::Utils.slugify(@plugin_type == 'theme' ? 'theme' : @plugin_slug)
|
71
|
+
end
|
72
|
+
|
73
|
+
def page_dir
|
74
|
+
@file_dir == '.' ? '' : @file_dir
|
75
|
+
end
|
76
|
+
|
77
|
+
def doc_dir
|
78
|
+
File.join(@path, page_dir, File.dirname(@file))
|
79
|
+
end
|
80
|
+
|
81
|
+
def comment_yaml(content)
|
82
|
+
if content =~ /<!-{3}\s+(.+)?-{3}>/m
|
83
|
+
SafeYAML.load($1)
|
84
|
+
else
|
85
|
+
{}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|