octopress-docs 0.0.9 → 0.0.10

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: 9016278546132adf8327ea7465ed5a6d337b3679
4
- data.tar.gz: 80a53837d9f7cc202ca720b9c7d24547f7582ffe
3
+ metadata.gz: b7d9c16f5a6ec8fa4a578e5d748d012a6f9a0d8e
4
+ data.tar.gz: 926e1271abaf66985a4b1ff241e8fc324409eff5
5
5
  SHA512:
6
- metadata.gz: 5f8aec83d98d4ccf8099dd60e39a0e50b44615b057410614eca9364afc8a940d6d6a0580e59293082d891b47a1686eae53af46efca6a55fc754347bd82608564
7
- data.tar.gz: c90728916468f1d7ecdb79fd01b5ee11bf480688f1dc33ecee41f8c4d28148d53bd8f4c6c94e40da565d37324a91632fe8aec76431ca70c2dc8291ad4261fa04
6
+ metadata.gz: 7a2235e5295576bd5f95562cd90504409fff3f8588f8413b12a8a2423c2ab04f3bbbd994e8487e50d40f0129200020bfd534bc0ac3335395fe3714c900160b75
7
+ data.tar.gz: 6b2a03703eef7a4ce73629dc57ccd6cead78a00533b7d25853eafccfcc7185772839632f5453b43041f6668614d47550e701e61d14afc22310093a5d5e6ca955
data/README.md CHANGED
@@ -1,35 +1,22 @@
1
1
  # Octopress Docs
2
2
 
3
- TODO: Write a gem description
3
+ 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.
4
4
 
5
- ## Installation
5
+ ## Adding docs to your plugin
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'octopress-docs'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install octopress-docs
18
-
19
- ## Usage
20
-
21
- Automatically add your Readme and Changelog files along with any pages in your gem path under `/assets/docs`.
7
+ Use the code below to automatically add your plugin's Readme, Changelog and any pages in your gem path under `assets/docs`.
8
+ If your plugin is built on Octopress Ink, these documentation pages are added automatically.
22
9
 
23
10
  ```ruby
24
- begin
25
- require 'octopress-docs'
26
- Octopress::Docs.add({
27
- name: "Your Plugin",
28
- slug: "your-plugin",
29
- dir: File.expand_path(File.join(File.dirname(__FILE__), "../../"))
30
- })
31
- rescue LoadError
32
- end
11
+ require 'octopress-docs'
12
+ Octopress::Docs.add({
13
+ name: "Your Plugin",
14
+ description: "This plugin causes awesomeness",
15
+ dir: File.expand_path(File.join(File.dirname(__FILE__), "../../")),
16
+ slug: "your-plugin", # optional
17
+ source_url: "https://github.com/some/project", # optional
18
+ website: "http://example.com", # optional
19
+ })
33
20
  ```
34
21
 
35
22
  ## Contributing
@@ -0,0 +1,8 @@
1
+ <header>
2
+ <a href="/"><h1>Octopress Local Docs</h1></a>
3
+ <p>Local documentation for your site's plugins.</p>
4
+ <nav class='main-nav' role='navigation'>
5
+ <a href="/">Home</a>
6
+ <a href="/docs/plugins/octopress-docs/">About</a>
7
+ </nav>
8
+ </header>
@@ -1,13 +1,10 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- {% css_asset_tag %}
5
4
  <link rel='stylesheet' href='/stylesheets/site.css'>
6
5
  <title>{{ page.title }}</title>
7
6
  </head>
8
7
  <body>
9
8
  {{ content }}
10
- {% js_asset_tag %}
11
9
  </body>
12
10
  </html>
13
-
@@ -1,14 +1,15 @@
1
1
  ---
2
2
  layout: default
3
3
  ---
4
+ {% include nav.html %}
4
5
 
5
6
  {{ content }}
6
7
 
7
- <h4>{{ page.plugin.name }} Doc Pages</h4>
8
- <nav role='navigation'>
9
- <ul>
10
- {% for doc in plugin_docs[page.plugin.slug].docs %}
11
- <li><a href="{{ doc.url }}">{{ doc.title }}</a></li>
8
+ {% assign doc_pages = plugin_docs[page.plugin.slug].docs %}
9
+ {% if doc_pages.size > 1 %}
10
+ <nav class='plugin-nav' role='navigation'>
11
+ {% for doc in doc_pages %}
12
+ <a href="{{ doc.url }}">{{ doc.title }}</a>
12
13
  {% endfor %}
13
- </ul>
14
14
  </nav>
15
+ {% endif %}
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+ {% include nav.html %}
5
+
6
+ <h2>Installed plugins</h2>
7
+ {{ content }}
data/docs/index.html CHANGED
@@ -1,12 +1,13 @@
1
1
  ---
2
- layout: default
2
+ layout: docs_index
3
3
  ---
4
4
 
5
5
  {% for plugin in plugin_docs %}
6
- <h4>{{ plugin[1].name }}</h4>
7
- <ul>
8
- {% for doc in plugin[1].docs %}
9
- <li><a href="{{ doc.url }}">{{ doc.title }}</a></li>
10
- {% endfor %}
6
+ <ul class='plugin'>
7
+ <li>
8
+ <a href="/{{ plugin[1].url }}">{{ plugin[1].name }}</a>{% if plugin[1].description %} - {{ plugin[1].description }}{% endif %}
9
+ {% assign source = plugin[1].source_url %}
10
+ {% if source %} - {{ source | docs_source_url }}{% endif %}
11
+ </li>
11
12
  </ul>
12
13
  {% endfor %}
@@ -11,7 +11,6 @@ module Octopress
11
11
  if ENV['OCTODEV']
12
12
  c.option 'watch', '--watch', 'Watch docs site for changes and rebuild. (For docs development)'
13
13
  end
14
- c.option 'jekyll', '--jekyll', "Launch local server with docs for Jekyll v#{Jekyll::VERSION}"
15
14
 
16
15
  c.action do |args, options|
17
16
  serve_docs(options)
@@ -20,12 +19,17 @@ module Octopress
20
19
  end
21
20
 
22
21
  def self.serve_docs(options)
22
+ # Activate dependencies for serving docs.
23
+ require "octopress-escape-code"
24
+ require "octopress-hooks"
25
+ require "octopress-docs/page"
26
+ require "octopress-docs/doc"
27
+ require "octopress-docs/hooks"
28
+ require "octopress-docs/liquid_filters"
29
+
23
30
  Octopress::Docs.docs_mode = true
24
- if options['jekyll']
25
- options = init_jekyll_docs(options)
26
- else
27
- options = init_octopress_docs(options)
28
- end
31
+ options = init_octopress_docs(options)
32
+ options["port"] ||= '4444'
29
33
  options["serving"] = true
30
34
  options = Jekyll.configuration Jekyll::Utils.symbolize_hash_keys(options)
31
35
  Jekyll::Commands::Build.process(options)
@@ -1,7 +1,7 @@
1
1
  module Octopress
2
2
  module Docs
3
3
  class Doc
4
- attr_reader :filename, :plugin_name, :base_url
4
+ attr_reader :filename, :plugin_name, :base_url, :plugin_type, :description, :source_url
5
5
 
6
6
  def initialize(options={})
7
7
  @file = options[:file]
@@ -11,6 +11,8 @@ module Octopress
11
11
  @plugin_slug = options[:slug]
12
12
  @plugin_type = options[:type]
13
13
  @base_url = options[:base_url]
14
+ @source_url = options[:source_url]
15
+ @description = options[:description]
14
16
  @data = options[:data] || {}
15
17
  end
16
18
 
@@ -41,10 +43,14 @@ module Octopress
41
43
  @page.data['plugin'] = {
42
44
  'name' => @plugin_name,
43
45
  'slug' => plugin_slug,
44
- 'docs_base_url' => @base_url
46
+ 'docs_base_url' => @base_url,
47
+ 'source_url' => @source_url,
48
+ 'description' => @description
45
49
  }
50
+
46
51
  @page.data['dir'] = doc_dir
47
52
  @page.data = @data.merge(@page.data)
53
+ @page.data.merge!(comment_yaml(@page.content))
48
54
  @page
49
55
  end
50
56
 
@@ -70,6 +76,13 @@ module Octopress
70
76
  File.join(@dir, page_dir, File.dirname(@file))
71
77
  end
72
78
 
79
+ def comment_yaml(content)
80
+ if content =~ /<!-{3}\s+(.+)?-{3}>/m
81
+ SafeYAML.load($1)
82
+ else
83
+ {}
84
+ end
85
+ end
73
86
  end
74
87
  end
75
88
  end
@@ -0,0 +1,13 @@
1
+ # For plugin authors who need to generate urls pointing to ther doc pages.
2
+ module DocsFilters
3
+ def docs_source_url(input)
4
+ if input =~ /github.com/
5
+ label = "GitHub"
6
+ else
7
+ label = "source"
8
+ end
9
+ "<a href='#{input}'>#{label}</a>"
10
+ end
11
+ end
12
+
13
+ Liquid::Template.register_filter(DocsFilters)
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Docs
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
  end
5
5
  end
@@ -8,7 +8,6 @@ require "octopress-docs/version"
8
8
  require "octopress-docs/command"
9
9
  require "octopress-docs/page"
10
10
  require "octopress-docs/doc"
11
- require "octopress-docs/tag"
12
11
  require "octopress-docs/hooks"
13
12
 
14
13
  module Octopress
@@ -52,10 +51,15 @@ module Octopress
52
51
  docs.each { |slug, pages|
53
52
  docs[slug] = {
54
53
  "name" => pages.first.plugin_name,
55
- "docs" => plugin_docs(pages)
54
+ "docs" => plugin_docs(pages),
55
+ "url" => pages.first.base_url,
56
+ "type" => pages.first.plugin_type,
57
+ "description" => pages.first.description,
58
+ "source_url" => pages.first.source_url
56
59
  }
57
60
  }
58
61
 
62
+
59
63
  { 'plugin_docs' => docs }
60
64
  end
61
65
 
@@ -91,6 +95,8 @@ module Octopress
91
95
  type: plugin.type,
92
96
  base_url: plugin.docs_url,
93
97
  dir: plugin.path,
98
+ source_url: plugin.source_url,
99
+ website: plugin.website,
94
100
  docs_path: File.join(plugin.assets_path, 'docs'),
95
101
  docs: %w{readme changelog}
96
102
  }
@@ -187,3 +193,12 @@ module Octopress
187
193
  end
188
194
  end
189
195
  end
196
+
197
+ # Add documentation for this plugin
198
+
199
+ Octopress::Docs.add({
200
+ name: "Octopress Docs",
201
+ description: "The fancy local documentation viewer.",
202
+ source_url: "https://github.com/octopress/docs",
203
+ dir: File.expand_path(File.join(File.dirname(__FILE__), "../"))
204
+ })
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.9
4
+ version: 0.0.10
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-10-08 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: octopress
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: pry-byebug
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -106,8 +120,10 @@ files:
106
120
  - docs/Gemfile
107
121
  - docs/Gemfile.lock
108
122
  - docs/_config.yml
123
+ - docs/_includes/nav.html
109
124
  - docs/_layouts/default.html
110
125
  - docs/_layouts/docs.html
126
+ - docs/_layouts/docs_index.html
111
127
  - docs/_sass/_solarized.scss
112
128
  - docs/index.html
113
129
  - docs/stylesheets/site.scss
@@ -115,8 +131,8 @@ files:
115
131
  - lib/octopress-docs/command.rb
116
132
  - lib/octopress-docs/doc.rb
117
133
  - lib/octopress-docs/hooks.rb
134
+ - lib/octopress-docs/liquid_filters.rb
118
135
  - lib/octopress-docs/page.rb
119
- - lib/octopress-docs/tag.rb
120
136
  - lib/octopress-docs/version.rb
121
137
  homepage: https://github.com/octopress/docs
122
138
  licenses:
@@ -1,18 +0,0 @@
1
- # For plugin authors who need to generate urls pointing to ther doc pages.
2
-
3
- module Octopress
4
- module Docs
5
- class DocUrlTag < Liquid::Tag
6
- def initialize(tag_name, markup, tokens)
7
- super
8
- @url = markup.strip
9
- end
10
-
11
- def render(context)
12
- '/' + File.join(context['page']['plugin']['docs_base_url'], @url)
13
- end
14
- end
15
- end
16
- end
17
-
18
- Liquid::Template.register_tag('doc_url', Octopress::Docs::DocUrlTag)