yard-api 0.1.1 → 0.1.2

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: 2d00ad89d7b00ed7802d02bb20aaee24f7fdad86
4
- data.tar.gz: f72ec72eadf4baa315a099c37d21276041bb2549
3
+ metadata.gz: e57e3582930e4a46f3b37f99587c6920eef9b569
4
+ data.tar.gz: 10ddc0a2d4286478cc9ffaf0bcba61594addc973
5
5
  SHA512:
6
- metadata.gz: f6d040c1451a6d858f14baf9b744da36efe2ed87708bc7eabb6a9757fa350cb3d42350cbe8a1a34fa6f1dd94ae51c3e894911840215b154fbbcd4e0b8b159b72
7
- data.tar.gz: 5dd3159103e8328edb0fca1e1be99279a1540815597b3ab186e95bcf206ed9fc6b622ca2b21f5767fcd492c1914a6b042f09bbd25918c45b2799337ec3cc94e4
6
+ metadata.gz: 52f99424016cc8c6926546d31e5196f79fc3d75e044b1aa371e7b161971584abf255b6f4335db309f8885bc42aba1ea10cb0ec1b473f9d0c2b0405e43b6acd77
7
+ data.tar.gz: cf0581d7c557506965ebd32dd890d99d29711052732db16b1e65b56193548c06f394b0a37c1121f7eb7f8301f41ff130bb17fa17f4e09b6f483f6e3d4ec0b8e1
data/README.md CHANGED
@@ -14,6 +14,11 @@ TODO
14
14
 
15
15
  ## Changelog
16
16
 
17
+ **14/9/2014**
18
+
19
+ - Support for single-page output through the `one_file` option
20
+ - Support for resource index generation ("All Resources") through the `resource_index` option
21
+
17
22
  **10/9/2014**
18
23
 
19
24
  - Support for github-flavored markdown when you're using Markdown as a markup, and `redcarpet` as the provider
@@ -84,4 +84,31 @@ module YARD::Templates::Helpers::HtmlHelper
84
84
  bookmark = "#{appendix.name.to_s.gsub(' ', '+')}-appendix"
85
85
  link_url("#{html_file}##{bookmark}", appendix.title)
86
86
  end
87
+
88
+ def sidebar_link(title, href)
89
+ <<-HTML
90
+ <a href="#{url_for(href)}">#{title}</a>
91
+ HTML
92
+ end
93
+
94
+ # Turns text into HTML using +markup+ style formatting.
95
+ #
96
+ # @override Syntax highlighting is not performed on the HTML block.
97
+ # @param [String] text the text to format
98
+ # @param [Symbol] markup examples are +:markdown+, +:textile+, +:rdoc+.
99
+ # To add a custom markup type, see {MarkupHelper}
100
+ # @return [String] the HTML
101
+ def htmlify(text, markup = options.markup)
102
+ markup_meth = "html_markup_#{markup}"
103
+ return text unless respond_to?(markup_meth)
104
+ return "" unless text
105
+ return text unless markup
106
+ html = send(markup_meth, text)
107
+ if html.respond_to?(:encode)
108
+ html = html.force_encoding(text.encoding) # for libs that mess with encoding
109
+ html = html.encode(:invalid => :replace, :replace => '?')
110
+ end
111
+ html = resolve_links(html)
112
+ html
113
+ end
87
114
  end
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module APIPlugin
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -34,6 +34,7 @@ module YARD::APIPlugin
34
34
 
35
35
  set_option('title', config['title'])
36
36
  set_option('output-dir', config['output'])
37
+ set_option('one-file') if config['one_file']
37
38
  set_option('readme', config['readme']) if File.exists?(config['readme'])
38
39
  set_option('verbose') if config['verbose']
39
40
  set_option('debug') if config['debug']
@@ -1,6 +1,6 @@
1
1
  <% untagged = object.tags.reject { |tag| tag.tag_name == 'API' }.empty? %>
2
2
 
3
3
  <% text = object.docstring.strip %>
4
- <% text = '*No documentation available yet.*' if text.empty? && untagged %>
4
+ <% text = '<em>No documentation available yet.</em>' if text.empty? && untagged %>
5
5
 
6
- <%= html_markup_markdown(text) %>
6
+ <%= htmlify(text) %>
@@ -12,6 +12,7 @@ def init
12
12
  generate_assets
13
13
  serialize_index
14
14
  serialize_static_pages
15
+ serialize_mega_index if api_options['resource_index']
15
16
 
16
17
  options.delete(:objects)
17
18
 
@@ -42,6 +43,16 @@ def serialize_index
42
43
  options.delete(:file)
43
44
  end
44
45
 
46
+ def serialize_mega_index
47
+ options[:all_resources] = true
48
+
49
+ Templates::Engine.with_serializer("all_resources.html", options[:serializer]) do
50
+ T('layout').run(options)
51
+ end
52
+
53
+ options.delete(:all_resources)
54
+ end
55
+
45
56
  def asset(path, content)
46
57
  options[:serializer].serialize(path, content) if options[:serializer]
47
58
  end
@@ -9,7 +9,21 @@
9
9
  <%= erb(:sidebar) %>
10
10
  </div>
11
11
 
12
- <div id="content"><%= yieldall %></div>
12
+ <% if options[:all_resources] %>
13
+ <div id="content">
14
+ <% if api_options['one_file'] %>
15
+ <% static_pages.each do |page| %>
16
+ <%= diskfile page[:src] %>
17
+ <% end %>
18
+ <% end %>
19
+
20
+ <% options[:resources].each do |resource, controllers| %>
21
+ <%= yieldall object: resource, controllers: controllers %>
22
+ <% end %>
23
+ </div>
24
+ <% else %>
25
+ <div id="content"><%= yieldall %></div>
26
+ <% end %>
13
27
 
14
28
  <%= erb(:footer) %>
15
29
  <%= erb(:scripts) %>
@@ -16,6 +16,18 @@
16
16
  $('<li>').append($link).appendTo($row);
17
17
  });
18
18
 
19
+ // Highlight the current page in the sidebar
20
+ $(function() {
21
+ var currentPage = location.pathname.match(/\/([^\/]+)$/)[1];
22
+ var $page = $('#sidebar [href="' + currentPage + '"]');
23
+ if ($page.length === 0) {
24
+ $page = $('#sidebar a[href=""]');
25
+ }
26
+
27
+ $page.addClass('current');
28
+ console.log('Highlighting current page:', $page, currentPage);
29
+ });
30
+
19
31
  $('#content pre.code').each(function(i, block) {
20
32
  var code;
21
33
  var $block = $(block);
@@ -1,20 +1,15 @@
1
1
  include Helpers::FilterHelper
2
2
 
3
3
  def init
4
- @breadcrumb = []
5
-
6
4
  @page_title = options[:title]
7
5
 
8
- if @file
9
- if @file.is_a?(String)
10
- @contents = File.read(@file)
11
- @file = File.basename(@file)
12
- else
13
- @contents = @file.contents
14
- @file = File.basename(@file.path)
15
- end
16
- def @object.source_type; nil; end
6
+ if options[:inline_file]
7
+ @contents = File.read(options[:file])
8
+ sections :diskfile
9
+ elsif @file
17
10
  sections :layout, [:diskfile]
11
+ elsif options[:all_resources]
12
+ sections :layout, [T('topic'), T('appendix')]
18
13
  elsif options[:controllers]
19
14
  sections :layout, [T('topic'), T('appendix')]
20
15
  else
@@ -34,9 +29,19 @@ def index
34
29
  erb(:index)
35
30
  end
36
31
 
37
- def diskfile
32
+ def diskfile(filename=@file)
33
+ if filename.is_a?(String)
34
+ @contents = File.read(filename)
35
+ filename = File.basename(filename)
36
+ elsif filename.is_a?(File)
37
+ @contents = filename.contents
38
+ filename = File.basename(filename.path)
39
+ end
40
+
41
+ extension = (File.extname(filename)[1..-1] || '').downcase
42
+
38
43
  content = "<div id='filecontents'>" +
39
- case (File.extname(@file)[1..-1] || '').downcase
44
+ case extension
40
45
  when 'htm', 'html'
41
46
  @contents
42
47
  when 'txt'
@@ -5,25 +5,19 @@
5
5
  </h1>
6
6
 
7
7
  <h2 class='first'>Pages</h2>
8
- <a
9
- href="<%= url_for("index.html") %>"
10
- class="<%= 'current' if options[:object] == 'index.html' %>">Home
11
- </a>
8
+
9
+ <%= sidebar_link('Home', 'index.html') %>
12
10
 
13
11
  <% static_pages.each do |page| %>
14
- <a href="<%= url_for(page[:filename]) %>"
15
- class="<%= 'current' if options[:object] == page[:filename] %>">
16
- <%= page[:title] %>
17
- </a>
12
+ <%= sidebar_link(page[:title], page[:filename]) %>
18
13
  <% end %>
19
14
 
20
15
  <h2>Resources</h2>
21
- <% options[:resources].each_with_index do |(resource, controllers), i| %>
22
- <%
23
- link = url_for("#{topicize resource}.html")
24
- klass = []
25
- klass << "current" if resource == options[:object]
26
- %>
27
- <a class="<%= klass.join(' ') %>" href="<%= link %>"><%= resource %></a>
16
+ <% if api_options['resource_index'] %>
17
+ <%= sidebar_link('All Resources', 'all_resources.html') %>
18
+ <% end %>
19
+
20
+ <% options[:resources].each do |resource, controllers| %>
21
+ <%= sidebar_link resource, "#{topicize(resource)}.html" %>
28
22
  <% end %>
29
23
  </nav>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Amireh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-10 00:00:00.000000000 Z
11
+ date: 2014-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard