yard-api 0.1.2 → 0.1.3

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: e57e3582930e4a46f3b37f99587c6920eef9b569
4
- data.tar.gz: 10ddc0a2d4286478cc9ffaf0bcba61594addc973
3
+ metadata.gz: 199b61a69ee11af6ea6ba0dddb1b7227647258ec
4
+ data.tar.gz: 7d1e0fec57a1f4366d698c272af0c96056fdf1e7
5
5
  SHA512:
6
- metadata.gz: 52f99424016cc8c6926546d31e5196f79fc3d75e044b1aa371e7b161971584abf255b6f4335db309f8885bc42aba1ea10cb0ec1b473f9d0c2b0405e43b6acd77
7
- data.tar.gz: cf0581d7c557506965ebd32dd890d99d29711052732db16b1e65b56193548c06f394b0a37c1121f7eb7f8301f41ff130bb17fa17f4e09b6f483f6e3d4ec0b8e1
6
+ metadata.gz: 412350ca78f192d978a921c57f0a0294e184fe3ce9c754a9e9374a19ba4128deaf0e1f81e98c4f6e2f9599abe07b99d1b53874580c048ae22fdefeb7cbafbe44
7
+ data.tar.gz: a4ce1b0807cf2e4c5c27aadb4223a28f22a0a96a4a73a0fae2650c36692a5fba2bab480ff42d4f7464a9b51db2b8cbde5e8b33913a517ce72d9c6b9a92d423ac
@@ -1,6 +1,7 @@
1
1
  module YARD::APIPlugin
2
2
  class Options < YARD::Options
3
3
  default_attr :title, 'Rails API Project'
4
+ default_attr :source, 'doc/api'
4
5
  default_attr :static, []
5
6
  default_attr :files, []
6
7
  default_attr :route_namespace, ''
@@ -8,6 +9,11 @@ module YARD::APIPlugin
8
9
  default_attr :footer_copyright, nil
9
10
  default_attr :footer_note, nil
10
11
 
12
+ default_attr :one_file, false
13
+ default_attr :verbose, false
14
+ default_attr :debug, false
15
+ default_attr :theme, 'default'
16
+
11
17
  attr_accessor :readme
12
18
  end
13
19
  end
@@ -35,13 +35,15 @@ module YARD::Templates::Helpers::HtmlHelper
35
35
  elsif entry.is_a?(String)
36
36
  [ entry ]
37
37
  end
38
- end.flatten.compact
38
+ end.flatten.compact.uniq.map { |path| File.join(options.source, path) }
39
+
40
+ puts "Static pages: #{paths}" if options.verbose
39
41
 
40
42
  markdown_exts = YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS[:markdown]
41
43
  readme_page = options.readme
42
44
  pages = Dir.glob(paths)
43
45
 
44
- if readme_page.present?
46
+ if readme_page.present? && !options.one_file
45
47
  pages.delete_if { |page| page.match(readme_page) }
46
48
  end
47
49
 
@@ -57,6 +59,10 @@ module YARD::Templates::Helpers::HtmlHelper
57
59
  File.basename(page).sub(/\.\w+$/, '').gsub(/\W/, ' ').gsub(/\s+/, ' ').capitalize
58
60
  end
59
61
 
62
+ if options.verbose
63
+ puts "Serializing static page #{page}"
64
+ end
65
+
60
66
  {
61
67
  src: page,
62
68
  filename: filename,
@@ -85,9 +91,9 @@ module YARD::Templates::Helpers::HtmlHelper
85
91
  link_url("#{html_file}##{bookmark}", appendix.title)
86
92
  end
87
93
 
88
- def sidebar_link(title, href)
94
+ def sidebar_link(title, href, options={})
89
95
  <<-HTML
90
- <a href="#{url_for(href)}">#{title}</a>
96
+ <a href="#{url_for(href)}" class="#{options[:class_name]}">#{title}</a>
91
97
  HTML
92
98
  end
93
99
 
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module APIPlugin
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -4,8 +4,8 @@ module YARD::APIPlugin
4
4
  class YardocTask < ::YARD::Rake::YardocTask
5
5
  attr_reader :config
6
6
 
7
- def initialize()
8
- super(:yard_api, &:run)
7
+ def initialize(name=:yard_api)
8
+ super(name, &:run)
9
9
  end
10
10
 
11
11
  def run
data/lib/yard-api.rb CHANGED
@@ -45,4 +45,11 @@ module YARD
45
45
  module Templates
46
46
  Engine.register_template_path YARD::APIPlugin::TEMPLATE_PATH
47
47
  end
48
+
49
+ module CLI
50
+ class YardocOptions < Templates::TemplateOptions
51
+ default_attr :resources, []
52
+ default_attr :json_objects, []
53
+ end
54
+ end
48
55
  end
@@ -12,7 +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
+ serialize_resource_index if api_options['resource_index']
16
16
 
17
17
  options.delete(:objects)
18
18
 
@@ -38,12 +38,24 @@ def serialize_resource(resource, controllers)
38
38
  end
39
39
 
40
40
  def serialize_index
41
+ return serialize_onefile_index if api_options.one_file
42
+
41
43
  options[:file] = api_options['readme']
42
44
  serialize('index.html')
43
45
  options.delete(:file)
44
46
  end
45
47
 
46
- def serialize_mega_index
48
+ def serialize_onefile_index
49
+ options[:all_resources] = true
50
+
51
+ Templates::Engine.with_serializer('index.html', options[:serializer]) do
52
+ T('onefile').run(options)
53
+ end
54
+
55
+ options.delete(:all_resources)
56
+ end
57
+
58
+ def serialize_resource_index
47
59
  options[:all_resources] = true
48
60
 
49
61
  Templates::Engine.with_serializer("all_resources.html", options[:serializer]) do
@@ -58,9 +70,9 @@ def asset(path, content)
58
70
  end
59
71
 
60
72
  def generate_assets
61
- asset_root = Pathname.new(File.dirname(__FILE__))
62
- (Dir[asset_root + "css/**/*.css"] + Dir[asset_root + "js/**/*.js"]).each do |file|
63
- file = Pathname.new(file).relative_path_from(asset_root).to_s
73
+ layout = Object.new.extend(T('layout'))
74
+
75
+ [].concat(layout.stylesheets).concat(layout.javascripts).uniq.each do |file|
64
76
  asset(file, file(file, true))
65
77
  end
66
78
  end
@@ -3,17 +3,10 @@
3
3
 
4
4
  <title><%= api_options['title'] %></title>
5
5
 
6
- <link
7
- rel="stylesheet"
8
- href="<%= url_for("css/common.css") %>"
9
- type="text/css"
10
- media="screen"
11
- charset="utf-8" />
6
+ <% stylesheets.each do |stylesheet| %>
7
+ <link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" charset="utf-8" />
8
+ <% end %>
12
9
 
13
- <link
14
- href="<%= url_for("css/highlight.css") %>"
15
- rel="stylesheet"
16
- type="text/css" />
17
-
18
- <script src="<%= url_for("js/highlight/highlight.pack.js") %>" type="text/javascript"></script>
19
- <script src="<%= url_for("js/jquery-1.11.1.min.js") %>" type="text/javascript"></script>
10
+ <% javascripts.each do |javascript| %>
11
+ <script src="<%= url_for(javascript) %>" type="text/javascript"></script>
12
+ <% end %>
@@ -4,7 +4,7 @@
4
4
  <%= erb(:headers) %>
5
5
  </head>
6
6
 
7
- <body>
7
+ <body class="theme-<%= api_options.theme %>">
8
8
  <div id="sidebar">
9
9
  <%= erb(:sidebar) %>
10
10
  </div>
@@ -28,7 +28,7 @@
28
28
  console.log('Highlighting current page:', $page, currentPage);
29
29
  });
30
30
 
31
- $('#content pre.code').each(function(i, block) {
31
+ $('#content pre').each(function(i, block) {
32
32
  var code;
33
33
  var $block = $(block);
34
34
  var $codeEl = $block.find('> code');
@@ -17,6 +17,20 @@ def init
17
17
  end
18
18
  end
19
19
 
20
+ def stylesheets
21
+ %w[
22
+ css/common.css
23
+ css/highlight.css
24
+ ]
25
+ end
26
+
27
+ def javascripts
28
+ %w[
29
+ js/jquery-1.11.1.min.js
30
+ js/highlight/highlight.pack.js
31
+ ]
32
+ end
33
+
20
34
  def contents
21
35
  @contents
22
36
  end
@@ -1,4 +1,4 @@
1
- <nav>
1
+ <div>
2
2
  <h1>
3
3
  <%= api_options['title'] %>
4
4
  <%= api_options['version'] %>
@@ -6,18 +6,21 @@
6
6
 
7
7
  <h2 class='first'>Pages</h2>
8
8
 
9
- <%= sidebar_link('Home', 'index.html') %>
10
-
11
- <% static_pages.each do |page| %>
12
- <%= sidebar_link(page[:title], page[:filename]) %>
13
- <% end %>
9
+ <nav id="static_pages">
10
+ <%= sidebar_link('Home', 'index.html') %>
11
+ <% static_pages.each do |page| %>
12
+ <%= sidebar_link(page[:title], page[:filename]) %>
13
+ <% end %>
14
+ </nav>
14
15
 
15
16
  <h2>Resources</h2>
16
- <% if api_options['resource_index'] %>
17
- <%= sidebar_link('All Resources', 'all_resources.html') %>
18
- <% end %>
17
+ <nav id="api_resources">
18
+ <% if api_options['resource_index'] %>
19
+ <%= sidebar_link('All Resources', 'all_resources.html') %>
20
+ <% end %>
19
21
 
20
- <% options[:resources].each do |resource, controllers| %>
21
- <%= sidebar_link resource, "#{topicize(resource)}.html" %>
22
- <% end %>
23
- </nav>
22
+ <% options[:resources].each do |resource, controllers| %>
23
+ <%= sidebar_link resource, "#{topicize(resource)}.html" %>
24
+ <% end %>
25
+ </nav>
26
+ </div>
@@ -0,0 +1 @@
1
+ include T('api/layout/html')
@@ -0,0 +1,15 @@
1
+ <div>
2
+ <h1>
3
+ <%= sidebar_link("#{api_options.title} #{api_options.version}", 'index.html') %>
4
+ </h1>
5
+
6
+ <nav id="static_pages">
7
+ <% static_pages.each do |page| %>
8
+ <%= sidebar_link(page[:title], page[:filename]) %>
9
+ <% end %>
10
+
11
+ <% options[:resources].each do |resource, controllers| %>
12
+ <%= sidebar_link resource, "#{topicize(resource)}.html", class_name: "api_resource_link" %>
13
+ <% end %>
14
+ </nav>
15
+ </div>
data/yard-api.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.has_rdoc = 'yard'
17
17
  s.license = 'AGPL3'
18
18
  s.add_dependency 'yard', '0.8.7'
19
- s.add_dependency 'yard-appendix', '>=0.1.8'
20
- s.add_development_dependency 'rspec'
21
- s.add_development_dependency 'gem-release'
19
+ s.add_dependency 'yard-appendix', '~> 0.1.8'
20
+ s.add_development_dependency 'rspec', '~> 0'
21
+ s.add_development_dependency 'gem-release', '~> 0'
22
22
  end
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Amireh
@@ -28,42 +28,42 @@ dependencies:
28
28
  name: yard-appendix
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.1.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: gem-release
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: |2
@@ -102,6 +102,8 @@ files:
102
102
  - templates/api/method_details/html/header.erb
103
103
  - templates/api/method_details/html/method_signature.erb
104
104
  - templates/api/method_details/html/setup.rb
105
+ - templates/api/onefile/html/setup.rb
106
+ - templates/api/onefile/html/sidebar.erb
105
107
  - templates/api/tags/html/_example_code_block.erb
106
108
  - templates/api/tags/html/argument.erb
107
109
  - templates/api/tags/html/emits.erb