yard-api 0.1.5 → 0.1.6

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: c4a7dbe342296a08ff5f47833f80909d984d0607
4
- data.tar.gz: 278a23bc1ba6409da13fa24b7c755b19a0a38d09
3
+ metadata.gz: 8e7c2eba4abe4ecd107cc9cc902e36c05e5816e9
4
+ data.tar.gz: bc34644b9a32d557a6863d6e316d2e1c9bfd70b1
5
5
  SHA512:
6
- metadata.gz: 4fcbd79b911d4e108f36a5dbdc8bb52457ed88b12c4324350d71da1c7c48e84e821ccc910c94297843b12004473861be20b5252418f6f80c4539399868f8a970
7
- data.tar.gz: 2d4c8731cf3ac058083028f433113cb2b9f41ef7603506f831329cdb1f7449532d4df9fc3b13702462023df2d065297d5cf87abe8d3262ee781f87807f771187
6
+ metadata.gz: d0abfc99e7f6d40e331219a96f5813b8a716d0fb7c78d0fc683543c6231053991833fec5450ca604deafa0ce7b55ec2618acd01336ec3480df3e250d2cb792e4
7
+ data.tar.gz: 3324e947fa1ed339a7cc8f9ca90d019a561fca7a4a6b2e3cbc099d2645112cb1a354549e18ebe6269d8a2cc89d1dee78f314293595b69311ae5926cd92217e27
@@ -71,12 +71,13 @@ module YARD::Templates::Helpers::BaseHelper
71
71
 
72
72
  def lookup_topic(controller_name)
73
73
  controller = nil
74
- topic = options[:resources].find { |r,cs|
75
- cs.any? { |c|
76
- controller = c if c.name.to_s == controller_name
77
- !controller.nil?
78
- }
79
- }
74
+ topic = options[:resources].find do |resource, controllers|
75
+ controllers.detect do |_controller|
76
+ if _controller.path.to_s == controller_name
77
+ controller = _controller
78
+ end
79
+ end
80
+ end
80
81
 
81
82
  [ topic, controller ]
82
83
  end
@@ -84,7 +85,7 @@ module YARD::Templates::Helpers::BaseHelper
84
85
  def lookup_appendix(title)
85
86
  appendix = nil
86
87
 
87
- puts "looking up appendix: #{title}"
88
+ puts "Looking up appendix: #{title}" if api_options.verbose
88
89
 
89
90
  if object
90
91
  # try in the object scope
@@ -12,6 +12,8 @@ module YARD::Templates::Helpers::HtmlHelper
12
12
  end
13
13
 
14
14
  def static_pages()
15
+ return @static_pages if @static_pages
16
+
15
17
  options = YARD::APIPlugin.options
16
18
 
17
19
  paths = Array(options.static).map do |entry|
@@ -37,8 +39,6 @@ module YARD::Templates::Helpers::HtmlHelper
37
39
  end
38
40
  end.flatten.compact.uniq.map { |path| File.join(options.source, path) }
39
41
 
40
- puts "Static pages: #{paths}" if options.verbose
41
-
42
42
  markdown_exts = YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS[:markdown]
43
43
  readme_page = options.readme
44
44
  pages = Dir.glob(paths)
@@ -47,7 +47,7 @@ module YARD::Templates::Helpers::HtmlHelper
47
47
  pages.delete_if { |page| page.match(readme_page) }
48
48
  end
49
49
 
50
- pages.map do |page|
50
+ @static_pages = pages.map do |page|
51
51
  filename = 'file.' + File.split(page).last.sub(/\..*$/, '.html')
52
52
 
53
53
  # extract page title if it's a markdown document; title is expected to
@@ -73,22 +73,30 @@ module YARD::Templates::Helpers::HtmlHelper
73
73
 
74
74
  # override yard-appendix link_appendix
75
75
  def link_appendix(ref)
76
- __errmsg = "unable to locate referenced appendix '#{ref}'"
76
+ puts "Linking appendix: #{ref}" if api_options.verbose
77
77
 
78
- puts "looking up appendix: #{ref}"
79
78
  unless appendix = lookup_appendix(ref.to_s)
80
- raise __errmsg
79
+ raise "Unable to locate referenced appendix '#{ref}'"
81
80
  end
82
81
 
83
- topic, controller = *lookup_topic(appendix.namespace.to_s)
82
+ html_file = if options[:all_resources] && api_options.one_file
83
+ 'index.html'
84
+ elsif options[:all_resources]
85
+ 'all_resources.html'
86
+ else
87
+ topic, controller = *lookup_topic(appendix.namespace.to_s)
84
88
 
85
- unless topic
86
- raise __errmsg
89
+ unless topic
90
+ raise "Unable to locate topic for appendix: #{ref}"
91
+ end
92
+
93
+ "#{topicize(topic.first)}.html"
87
94
  end
88
95
 
89
- html_file = "#{topicize topic.first}.html"
90
96
  bookmark = "#{appendix.name.to_s.gsub(' ', '+')}-appendix"
91
- link_url("#{html_file}##{bookmark}", appendix.title)
97
+ link_url("#{html_file}##{bookmark}", appendix.title).tap do |link|
98
+ puts "\tAppendix link: #{link}" if api_options.verbose
99
+ end
92
100
  end
93
101
 
94
102
  def sidebar_link(title, href, options={})
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module APIPlugin
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -7,13 +7,19 @@ end
7
7
  def appendix
8
8
  controllers = options[:controllers]
9
9
 
10
+ if options[:all_resources]
11
+ controllers = options[:resources].flatten.select { |o|
12
+ o.is_a?(YARD::CodeObjects::NamespaceObject)
13
+ }
14
+ end
15
+
10
16
  unless controllers && controllers.is_a?(Array)
11
17
  return
12
18
  end
13
19
 
14
- @appendixes = controllers.collect { |c|
15
- c.children.select { |o| :appendix == o.type }
16
- }.flatten
20
+ @appendixes = controllers.collect do |controller|
21
+ controller.children.select { |tag| :appendix == tag.type }
22
+ end.flatten.uniq
17
23
 
18
24
  super
19
25
  end
@@ -1,12 +1,12 @@
1
1
  <article>
2
- <%= html_markup_markdown(@docstring.strip) %>
2
+ <%= htmlify(@docstring) %>
3
3
  </article>
4
4
 
5
5
  <% c = options[:controllers].detect { |c| c.has_tag?(:note) } %>
6
6
  <% c && c.tags(:note).each do |tag| %>
7
7
  <blockquote class="note">
8
8
  <p><strong>Note</strong></p>
9
- <%= html_markup_markdown tag.text %>
9
+ <%= htmlify tag.text %>
10
10
  </blockquote>
11
11
  <% end %>
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Amireh