yard-api 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a4a3b1beee6e7ade875e7a95004d14da25fb0d7
4
- data.tar.gz: ea2078d3f6d4ecf6afdc91aa635ebf53cb046343
3
+ metadata.gz: c4a7dbe342296a08ff5f47833f80909d984d0607
4
+ data.tar.gz: 278a23bc1ba6409da13fa24b7c755b19a0a38d09
5
5
  SHA512:
6
- metadata.gz: eeb5f091e4cd539126f6fd69dd93186b9e7ef5ab9f417cf588c25b48fc979585c1b18c4d5bdc0345af656b0d0812c7c7132ef558719622b111c687c85f9e6316
7
- data.tar.gz: adb5d639749e0544ef05234636cbe666459a9dc6bfc9fae9c239a25e796ea4539c1b343e4e4a648d81fb8039bd398cb7e0cfc2dd10a14a7b3eb4f288b9944782
6
+ metadata.gz: 4fcbd79b911d4e108f36a5dbdc8bb52457ed88b12c4324350d71da1c7c48e84e821ccc910c94297843b12004473861be20b5252418f6f80c4539399868f8a970
7
+ data.tar.gz: 2d4c8731cf3ac058083028f433113cb2b9f41ef7603506f831329cdb1f7449532d4df9fc3b13702462023df2d065297d5cf87abe8d3262ee781f87807f771187
data/README.md CHANGED
@@ -8,12 +8,28 @@ TODO
8
8
 
9
9
  TODO
10
10
 
11
+ ## Configuration
12
+
13
+ `yard-api` will look for a file in `config/yard_api.yml` in the Rails root for customizations. Configuration fields not specified in that file will be filled with the default values found in [config/yard_api.yml](https://github.com/amireh/yard-api/blob/master/config/yard_api.yml).
14
+
15
+ Read that file to view all the available options.
16
+
11
17
  ## Notes
12
18
 
13
19
  - can only document classes and class methods; modules, root objects, and constants are ignored
14
20
 
15
21
  ## Changelog
16
22
 
23
+ **15/9/2014**
24
+
25
+ - `@argument` tags can now be formatted in a table by setting the `tabular_arguments` option to true
26
+ - `@argument_scope`: a new tag that improves the formatting of endpoint arguments that are scoped by a common prefix (e.g, nested inside a json object), like `user[name]` => `name`
27
+ - `@argument` can now parse accepted values in two formats; inline within the types array, or by explicitly writing it in the tag text using any of `Accepted values: [...]`, `Accepts: [...]`, or `Possible values: [...]`
28
+ - A new option: `strict_arguments` that provides a default for the `is_required` property of `@argument` tags. This default is used if the tag does not explicitly state `Optional` or `Required` in its type specifier.
29
+ - Support for dynamic javascript and style code based on options. See `templates/layout/setup.rb#inline_{javascripts,stylesheets}`
30
+ - A new set of options for customizing layout: `content_width`, `sidebar_width` and `spacer`
31
+ - `github_url` and `github_branch` options for tuning api endpoint source links
32
+
17
33
  **14/9/2014**
18
34
 
19
35
  - Support for single-page output through the `one_file` option
@@ -1,13 +1,18 @@
1
1
  module YARD::APIPlugin
2
+ # See config/yard_api.yml for documentation for the options.
2
3
  class Options < YARD::Options
3
4
  default_attr :title, 'Rails API Project'
5
+ default_attr :window_title, 'Rails API Project Documentation'
6
+ default_attr :version, ''
4
7
  default_attr :source, 'doc/api'
5
8
  default_attr :static, []
6
9
  default_attr :files, []
7
10
  default_attr :route_namespace, ''
11
+ default_attr :github_url, nil
12
+ default_attr :github_branch, 'master'
8
13
 
9
- default_attr :footer_copyright, nil
10
- default_attr :footer_note, nil
14
+ default_attr :footer_copyright, ''
15
+ default_attr :footer_note, ''
11
16
 
12
17
  default_attr :one_file, false
13
18
  default_attr :verbose, false
@@ -17,6 +22,10 @@ module YARD::APIPlugin
17
22
  default_attr :tabular_arguments, false
18
23
  default_attr :strict_arguments, false
19
24
 
25
+ default_attr :sidebar_width, 240
26
+ default_attr :content_width, 'fluid'
27
+ default_attr :spacer, 20
28
+
20
29
  attr_accessor :readme
21
30
  end
22
31
  end
@@ -92,6 +92,8 @@ module YARD::Templates::Helpers::HtmlHelper
92
92
  end
93
93
 
94
94
  def sidebar_link(title, href, options={})
95
+ options[:class_name] ||= (object == href ? 'active' : nil)
96
+
95
97
  <<-HTML
96
98
  <a href="#{url_for(href)}" class="#{options[:class_name]}">#{title}</a>
97
99
  HTML
@@ -1,5 +1,5 @@
1
1
  module YARD
2
2
  module APIPlugin
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -9,6 +9,8 @@ module YARD::APIPlugin
9
9
  end
10
10
 
11
11
  def run
12
+ YARD::APIPlugin.options.reset_defaults
13
+
12
14
  @config = load_config
13
15
  t = self
14
16
 
@@ -0,0 +1,16 @@
1
+ <style>
2
+ body {
3
+ padding-left: <%= api_options.sidebar_width + api_options.spacer %>px;
4
+ padding-right: <%= api_options.spacer %>px;
5
+ }
6
+
7
+ #sidebar {
8
+ width: <%= api_options.sidebar_width %>px;
9
+ }
10
+
11
+ <% if api_options.content_width.to_i > 0 %>
12
+ #content {
13
+ max-width: <%= api_options.content_width %>px;
14
+ }
15
+ <% end %>
16
+ </style>
@@ -1,11 +1,9 @@
1
1
  <div id="footer">
2
2
  <p>
3
- <% if api_options['footer_copyright'] %>
4
- <%= api_options['footer_copyright'] %>
5
- <% end %>
3
+ <%= api_options.footer_copyright.to_s %>
6
4
 
7
5
  Generated on <%= Time.now.strftime("%c") %>
8
6
  </p>
9
7
 
10
- <%= api_options['footer_note'].to_s %>
8
+ <%= api_options.footer_note.to_s %>
11
9
  </div>
@@ -1,7 +1,7 @@
1
1
  <meta name="Content-Type" content="text/html;charset=UTF-8">
2
2
  <meta charset="UTF-8">
3
3
 
4
- <title><%= api_options['title'] %></title>
4
+ <title><%= api_options.window_title || api_options.title %></title>
5
5
 
6
6
  <% stylesheets.each do |stylesheet| %>
7
7
  <link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" charset="utf-8" />
@@ -2,16 +2,20 @@
2
2
  <html>
3
3
  <head>
4
4
  <%= erb(:headers) %>
5
+
6
+ <% inline_stylesheets.each do |style| %>
7
+ <%= erb(style) %>
8
+ <% end %>
5
9
  </head>
6
10
 
7
- <body class="theme-<%= api_options.theme %>">
11
+ <body class="theme-<%= api_options.theme %> <%= 'onefile' if api_options.one_file %>">
8
12
  <div id="sidebar">
9
13
  <%= erb(:sidebar) %>
10
14
  </div>
11
15
 
12
16
  <% if options[:all_resources] %>
13
17
  <div id="content">
14
- <% if api_options['one_file'] %>
18
+ <% if api_options.one_file %>
15
19
  <% static_pages.each do |page| %>
16
20
  <%= diskfile page[:src] %>
17
21
  <% end %>
@@ -27,5 +31,9 @@
27
31
 
28
32
  <%= erb(:footer) %>
29
33
  <%= erb(:scripts) %>
34
+
35
+ <% inline_javascripts.each do |script| %>
36
+ <%= erb(script) %>
37
+ <% end %>
30
38
  </body>
31
39
  </html>
@@ -20,11 +20,16 @@
20
20
  $(function() {
21
21
  var currentPage = location.pathname.match(/\/([^\/]+)$/)[1];
22
22
  var $page = $('#sidebar [href="' + currentPage + '"]');
23
- if ($page.length === 0) {
24
- $page = $('#sidebar a[href=""]');
23
+
24
+ if (!currentPage) {
25
+ return;
25
26
  }
26
27
 
27
- $page.addClass('current');
28
+ // if ($page.length === 0) {
29
+ // $page = $('#sidebar a[href=""]');
30
+ // }
31
+
32
+ // $page.addClass('active');
28
33
  console.log('Highlighting current page:', $page, currentPage);
29
34
  });
30
35
 
@@ -24,6 +24,10 @@ def stylesheets
24
24
  ]
25
25
  end
26
26
 
27
+ def inline_stylesheets
28
+ [ '_dynamic_styles' ]
29
+ end
30
+
27
31
  def javascripts
28
32
  %w[
29
33
  js/jquery-1.11.1.min.js
@@ -31,6 +35,10 @@ def javascripts
31
35
  ]
32
36
  end
33
37
 
38
+ def inline_javascripts
39
+ []
40
+ end
41
+
34
42
  def contents
35
43
  @contents
36
44
  end
@@ -4,8 +4,9 @@
4
4
  <%= object.tag("API").try(:text) %>
5
5
  </a>
6
6
 
7
- <% if @controller_path %>
8
- <span class='defined-in'><a href="https://github.com/amireh/pibi/blob/master/<%= @controller_path %>"><%= "#{@route.requirements[:controller].camelize}Controller\##{@route.requirements[:action]}" %></a></span>
7
+ <% if @controller_path && !api_options.github_url.to_s.empty? %>
8
+ <span class='defined-in'>
9
+ <a href="<%= api_options.github_url %>/blob/<%= api_options.github_branch %>/<%= @controller_path %>"><%= "#{@route.requirements[:controller].camelize}Controller\##{@route.requirements[:action]}" %></a></span>
9
10
  <% end %>
10
11
  </h2>
11
12
  <%= yieldall %>
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.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Amireh
@@ -95,6 +95,7 @@ files:
95
95
  - templates/api/docstring/html/setup.rb
96
96
  - templates/api/docstring/html/text.erb
97
97
  - templates/api/fulldoc/html/setup.rb
98
+ - templates/api/layout/html/_dynamic_styles.erb
98
99
  - templates/api/layout/html/footer.erb
99
100
  - templates/api/layout/html/headers.erb
100
101
  - templates/api/layout/html/layout.erb