yard-restful 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown ADDED
@@ -0,0 +1,191 @@
1
+ # Yardoc RESTful Web Service Plugin
2
+
3
+ originally by [vWorkApp](http://www.vworkapp.com)
4
+ rewritten for 0.3.0 by [rknLA](http://github.com/rknLA) with substantial help from [lsegal](http://gnuu.org/)
5
+ customized by [spape](http://github.com/spape) for the [MAdeK](http://github.com/zhdk/madek)
6
+ further customization by [DerNalia](http://github.com/DerNalia) for [TinderBox](http://gettinderbox.com)
7
+ [API-Documentation](http://medienarchiv.zhdk.ch/api)
8
+
9
+ A plugin for [Yardoc](http://yardoc.org/) that generates documentation for RESTful web services.
10
+
11
+ ## Install
12
+ Bundler will reduce your headaches, so, please you that
13
+ gem 'yard-rest' # in your gemfile
14
+
15
+ You may need to include the following dependencies as well:
16
+ gem 'redcarpet'
17
+ gem 'yard'
18
+
19
+ It also requires the Jeweler gem if you plan to use the rake build tasks.
20
+
21
+ You'll probably want to add these to your .gitignore as well
22
+ /.yardoc/*/*
23
+ /.yardoc/*
24
+ /public/api
25
+
26
+ So you'll have to re-genenarte your API on every machine. This should encourage more up to dateness
27
+
28
+ ## Execution
29
+ It is recommended that you use a .yardopts file
30
+ --title "My API Documentation"
31
+ --plugin rest
32
+ --readme API_README
33
+ --output-dir ./public/api
34
+ app/models/*.rb
35
+ app/controllers/*.rb
36
+
37
+ So that way, whenever you want to generate your API docs, you simply need to run only
38
+ bundle exec yardoc
39
+
40
+
41
+ ## See an API-Example
42
+
43
+ [Yard-Rest-Plugin](http://DerNalia.github.com/yard-rest-plugin) and get a look to the "Example" resource.
44
+
45
+ ## Demo (see the plugin in action)
46
+
47
+ Visit [TinderBox API Documentation](http://mytinder.com/api/) for a demonstration.
48
+
49
+ ## Writing Comments
50
+
51
+ The following tags are provided:
52
+
53
+ - @resource resource. Specifies the resource (controller action/method) that the service is accessed from. This tag is compulsory, only **classes** and **methods** that include this in their comments are included in the API documentation.
54
+
55
+ - @url url. Specifies the URL which someone should use to access that resource.
56
+
57
+ - @action action. Specifies the http action (GET, POST, PUT etc.).
58
+
59
+ - @status\_codes Any possible returned states codes that the API user may need to handle.
60
+
61
+ - @required [type] name description. Specifies an argument that must be passed to the service. You can specify as many of these as you need.
62
+
63
+ - @optional [type] name description. Specifies an optional argument that may be passed to the service. You can specify as many of these as you need.
64
+
65
+ - @response_field [type] name description. Further specifies the fields that are returned within the response.
66
+
67
+ - @resource\_object ModelName. A modal that users of the API should know about.
68
+
69
+ - @resource\_object\_properties Description of the modal and attributes that the API user should know about.
70
+
71
+ - @resource\_object\_footnotes Anything else that needs to be said about the model
72
+ ### Examples
73
+
74
+ Examples should always be together in the following order: example_request, example_request_description, example_response, example_response_description (as soon as you write a example_request you need a following example_response and the other way around).
75
+
76
+ Markdown rendering for the text is activated if a tags text contains a newline (see example).
77
+
78
+ - @example_request example. An example of the request that is send to the service.
79
+
80
+ - @example_request_description description. The description text for the example request.
81
+
82
+ - @example_response example. An example of the response that is returned from the service.
83
+
84
+ - @example_response example.
85
+ ```json
86
+ {
87
+ "examples": [{
88
+ "id":1,
89
+ "title":"Animals",
90
+ "text":"Dogs and cats are some.",
91
+ "highlight":true
92
+ }]
93
+ }
94
+ ```
95
+
96
+ - @example_response_description example. The description text for the example response.
97
+
98
+ ## Ignored Documentation
99
+
100
+ This plugin only documents **classes** and **methods** with **@resource** or **@resource\_object** tags. It does not support module documentation.
101
+
102
+ ## Example:
103
+ For controllers:
104
+
105
+ ##
106
+ # A thing characteristic of its kind or illustrating a general rule:
107
+ # it's a good example of how European action can produce results | some of these carpets are among the finest examples of the period.
108
+ class ExamplesController
109
+ ##
110
+ # Get a collection of examples:
111
+ #
112
+ # @resource index
113
+ # @url /examples[ .format ]
114
+ #
115
+ # @action GET
116
+ #
117
+ # @optional [Boolean] highlight Show only highlighted examples.
118
+ #
119
+ # @response_field [Array] examples The collection of examples.
120
+ #
121
+ # @status_codes possible API status codes
122
+ # 404 - Not Found
123
+ # 401 - Unauthorized
124
+ # 422 - Unprocessable Entity
125
+ # 200 - OK
126
+ #
127
+ #
128
+ # @example_request {}
129
+ # @example_request_description Just requests an index of samples.
130
+ # @example_response {"examples": [{"id":1, "title":"Animals", "text":"Dogs and cats are some.", "highlight":true}, {"id":2, "title":"Computers", "text":"Windows PC or Apple's Macintosh.", "highlight":false}]}
131
+ # @example_response_description Responds with the index of examples.
132
+ #
133
+ # @example_request {"highlight": true}
134
+ # @example_request_description Request only highlighted examples.
135
+ # @example_response
136
+ # ```json
137
+ # {
138
+ # "examples": [{
139
+ # "id":1,
140
+ # "title":"Animals",
141
+ # "text":"Dogs and cats are some.",
142
+ # "highlight":true
143
+ # }]
144
+ # }
145
+ # ```
146
+ # @example_response_description Responds only with highlighted examples.
147
+ #
148
+ def index
149
+ #...
150
+ end
151
+ end
152
+
153
+ And for models:
154
+
155
+ ##
156
+ # @resource_object ExamplesModel
157
+ # @resource_object_properties
158
+ # ExamplesModel{
159
+ # id: Integer
160
+ # name: String
161
+ # }
162
+ #
163
+ # @resource_object_footnotes
164
+ # (1) For visibility, see {Shared}
165
+ class ExamplesModel
166
+
167
+ # @resource
168
+ CONSTANT_VARIABLE = 3
169
+
170
+ # internal documentation
171
+ # not picked up by yard-rest-plugin
172
+ # @return something_else
173
+ def something
174
+ #...
175
+ end
176
+
177
+ end
178
+
179
+ ## Development
180
+
181
+ As always, you can see what tasks are available by running:
182
+
183
+ rake -T
184
+
185
+ You can run the template locally over the included sample code by using the following rake tasks:
186
+
187
+ rake ex:clean
188
+ rake ex:generate
189
+
190
+
191
+
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "yard-restful"
8
+ gem.summary = %Q{Yardoc plugin for Restful web services}
9
+ gem.description = %Q{A customized plugin for Yardoc that produces API documentation for Restful web services}
10
+ gem.email = ''
11
+ gem.homepage = "https://github.com/kraft/yard-restful"
12
+ gem.authors = ['Konstantin Rafalsky']
13
+ gem.add_dependency("yard", '~>0.8.3')
14
+ gem.files = Dir.glob("{lib,templates}/**/*").concat(["Rakefile"])
15
+ gem.extra_rdoc_files = ['VERSION', 'README.markdown']
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ desc "Rebuild the gem from the gemspec"
23
+ task :rebuild do
24
+ gemfilename = 'yard-restful-' + File.open('VERSION').gets.strip + '.gem'
25
+ `rm yard-restful-*.gem`
26
+ `gem uninstall yard-restful&& \
27
+ gem build yard-restful.gemspec && \
28
+ gem install #{gemfilename}`
29
+ end
30
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.2.0
data/lib/yard-rest.rb ADDED
@@ -0,0 +1,8 @@
1
+ YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
2
+
3
+ require 'yard-rest/tags'
4
+ require 'yard-rest/rest_filters'
5
+ require 'yard-rest/html_blocks_helper'
6
+
7
+ YARD::Templates::Template.extra_includes << RestFilters
8
+ YARD::Templates::Template.extra_includes << ->(opts) { HtmlBlocksHelper if opts.format == :html }
@@ -0,0 +1,16 @@
1
+ module HtmlBlocksHelper
2
+
3
+ def rotate(name = nil)
4
+ @counter ||= {}
5
+ name ||= 'odd_even'
6
+ name = name.to_s
7
+
8
+ @counter[name] ||= 0
9
+ @counter[name] += 1
10
+
11
+ elements = name.split(/[^\w]|\_/)
12
+ @counter[name].even? ? elements[0] : elements[1]
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,29 @@
1
+ module YARD
2
+ module CodeObjects
3
+ class Base
4
+ def restful?
5
+ has_tag?(:restful_api)
6
+ end
7
+ def resource?
8
+ meths.any?{ |m| m.has_tag?(:url) }
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ module RestFilters
15
+
16
+ def select_restful(list)
17
+ (list || []).select(&:restful?)
18
+ end
19
+
20
+ def select_objects(list)
21
+ select_restful(list).reject(&:resource?).sort_by(&:name)
22
+ end
23
+
24
+ def select_resources(list)
25
+ select_restful(list).select(&:resource?).sort_by(&:name)
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,26 @@
1
+ # Define custom tags
2
+ tags = [
3
+ ["Declaration of RESTful API type",:restful_api],
4
+ ["URL", :url],
5
+ ["HTTP-Action for the Resource", :action],
6
+
7
+ #["Object Used in Resource", :resource_object],
8
+ ["Resource Object Property", :property, :with_types_and_name],
9
+ ["Resource Object Example", :example],
10
+
11
+ ["Required Arguments", :required, :with_types_and_name],
12
+ ["Optional Arguments", :optional, :with_types_and_name],
13
+
14
+ ["Example Request", :example_request],
15
+ ["Example Request Description", :example_request_description],
16
+ ["Request Fields", :request_field, :with_types_and_name],
17
+
18
+ ["Example Response", :example_response],
19
+ ["Example Response Description", :example_response_description],
20
+ ["Response Fields", :response_field, :with_types_and_name],
21
+ ["Response Type", :response, :with_types]
22
+ ]
23
+
24
+ tags.each do |tag|
25
+ YARD::Tags::Library.define_tag(*tag)
26
+ end
@@ -0,0 +1,17 @@
1
+ <% tags_list = object.tags(options.item) %>
2
+ <% if tags_list.size > 0 %>
3
+ <div class="parameters <%= rotate(:odd_even) %>">
4
+ <% unless options.title.empty? %>
5
+ <h4><%= options.title %></h4>
6
+ <% end %>
7
+ <ul>
8
+ <% tags_list.each do |tag| %>
9
+ <li>
10
+ <span class="name"><%= tag.name %></span>
11
+ <span class="type"><%= format_types(tag.types, false) %></span>
12
+ <span class="text"><%= htmlify(tag.text) %></span>
13
+ </li>
14
+ <% end %>
15
+ </ul>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <div class="service">
2
+ <h1 class="noborder title"><%= options[:title] %></h1>
3
+ <a class="back" href="<%= url_for('index.html') %>" title="back to the overview">&laquo; back to overview</a>
4
+ <h2><%= object.name.to_s.gsub(/Controller/,"") %></h2>
5
+ <%= yieldall %>
6
+ </div>
7
+
@@ -0,0 +1,12 @@
1
+ <% if object.restful? && !object.resource? %>
2
+ <h3 class="object_properties_title">Object properties</h3>
3
+ <%= yieldall(item: :property, title: '') %>
4
+ <% if object.tags(:example).size > 0 %>
5
+ <h3>Examples</h3>
6
+ <% object.tags(:example).each do |tag| %>
7
+ <div class="example">
8
+ <%= htmlify(tag.text) %>
9
+ </div>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,85 @@
1
+ <% if object.restful? && object.resource? %>
2
+ <div id="Services" class="method_details_list">
3
+ <% @meths.each do |meth| %>
4
+ <div class="method">
5
+ <h3><%= meth.name %></h3>
6
+ <p class="method_desc"><%= meth.docstring %></p>
7
+
8
+ <% if meth.tags(:url).size > 0 %>
9
+ <div class="resource_url <%=rotate(:odd_even)%>">
10
+ <h4>URL</h4>
11
+ <span class="action"><%= meth.tag(:action).text %></span>
12
+ <span class="url"><%= meth.tag(:url).text %></span>
13
+ </div>
14
+ <% end %>
15
+
16
+ <%= yieldall(object: meth, item: :required, title: 'Required Parameters') %>
17
+ <%= yieldall(object: meth, item: :optional, title: 'Optional Parameters') %>
18
+ <% if meth.tags(:response).size > 0 %>
19
+ <div class="parameters <%=rotate(:odd_even)%>">
20
+ <h4>Response Object</h4>
21
+ <ul>
22
+ <li>
23
+ <span class="type"><%= format_types(meth.tag(:response).types, false) %></span>
24
+ <span class="text"><%= htmlify(meth.tag(:response).text) %></span>
25
+ </li>
26
+ </ul>
27
+ </div>
28
+ <% else %>
29
+ <%= yieldall(object: meth, item: :response_field, title: 'Response Fields') %>
30
+ <% end %>
31
+
32
+ <% if meth.tags(:example_request).size > 0 %>
33
+ <div class="examples">
34
+ <h4>Examples</h4>
35
+ <% meth.tags(:example_request).each_with_index do |example_request, i| %>
36
+ <div class="example">
37
+ <% example_request_description = meth.tags(:example_request_description)[i] %>
38
+ <% example_response = meth.tags(:example_response)[i] %>
39
+ <% example_response_description = meth.tags(:example_response_description)[i] %>
40
+ <span class="description">
41
+ <% if example_request_description %>
42
+ <% if example_request_description.text =~ /\n/im %>
43
+ <%= htmlify(example_request_description.text) %>
44
+ <% else %>
45
+ <%= example_request_description.text %>
46
+ <% end %>
47
+ <% end %>
48
+ </span>
49
+ <span class="hash request">
50
+ <strong class="type">Request</strong>
51
+ <% if example_request %>
52
+ <% if example_request.text =~ /\n/im %>
53
+ <%= htmlify(example_request.text) %>
54
+ <% else %>
55
+ <%= example_request.text %>
56
+ <% end %>
57
+ <% end %>
58
+ </span>
59
+ <span class="hash response">
60
+ <strong class="type">Response</strong>
61
+ <% if example_response %>
62
+ <% if example_response.text =~ /\n/im %>
63
+ <%= htmlify(example_response.text) %>
64
+ <% else %>
65
+ <%= example_response.text %>
66
+ <% end %>
67
+ <% end %>
68
+ </span>
69
+ <span class="description">
70
+ <% if example_response_description %>
71
+ <% if example_response_description.text =~ /\n/im %>
72
+ <%= htmlify(example_response_description.text) %>
73
+ <% else %>
74
+ <%= example_response_description.text %>
75
+ <% end %>
76
+ <% end %>
77
+ </span>
78
+ </div>
79
+ <% end %>
80
+ </div>
81
+ <% end %>
82
+ </div>
83
+ <% end %>
84
+ </div>
85
+ <% end %>
@@ -0,0 +1,11 @@
1
+ def init
2
+ @page_title = "#{object.name.to_s.gsub(/Controller/,"")} - #{options[:title]}"
3
+ #sections :header, [T('docstring'), :method_details_list, [:fields_list], [T('method_details')]]
4
+ sections :header, [T('docstring'), :object_details, [:fields_list], :resource_details, [:fields_list]]
5
+ end
6
+
7
+ def resource_details
8
+ @meths = (object.meths.select{|x| x.has_tag? :url} || [])
9
+ erb(:resource_details)
10
+ end
11
+
@@ -0,0 +1,4 @@
1
+ def init
2
+ return if object.docstring.blank?
3
+ sections :text
4
+ end
@@ -0,0 +1 @@
1
+ <%= htmlify(object.docstring.strip) %>
@@ -0,0 +1,184 @@
1
+ body {
2
+ overflow-x: hidden;
3
+ overflow-y: auto;
4
+ padding: 0 !important;
5
+ margin: 0 !important;
6
+ width: 100%;
7
+ }
8
+ #toc {
9
+ height: 100%;
10
+ right: 0;
11
+ position: fixed;
12
+ top: 0;
13
+ width: 230px;
14
+ }
15
+ #header {
16
+ position: fixed;
17
+ top: 0;
18
+ z-index: 1001;
19
+ }
20
+ #header #search {
21
+ position: fixed;
22
+ top: 0;
23
+ right: 8px;
24
+ z-index: 1001;
25
+ }
26
+ #content {
27
+ margin-right: 285px;
28
+ position: relative;
29
+ padding: 20px;
30
+ z-index: 1;
31
+ }
32
+ #toc .title {display: none;}
33
+ #toc a:link, #content a:visited { text-decoration: none; color: #05a; }
34
+ #toc a:hover { background: #ffffa5; }
35
+ pre code {
36
+ display: block;
37
+ background: #EAF0FF;
38
+ padding: 12px;
39
+ line-height: 1.9em;
40
+ }
41
+ a.back {
42
+ font-size: 1.2em;
43
+ padding: 4px;
44
+ }
45
+ p.method_desc {
46
+ padding: 16px 0 0 14px;
47
+ font-size: 1.2em;
48
+ }
49
+ h2 {
50
+ margin: 2.4em 0 0.5em;
51
+ }
52
+ .service h2 + p {
53
+ font-size: 1.2em;
54
+ margin-bottom: 62px;
55
+ }
56
+ .method {
57
+ display: block;
58
+ margin-top: 40px;
59
+ padding-top: 0;
60
+ position: relative;
61
+ }
62
+ h3 {
63
+ font-size: 1.6em;
64
+ padding-top: 6px;
65
+ margin-bottom: -6px;
66
+ }
67
+ h4 {
68
+ margin: 0;
69
+ }
70
+ #resources {
71
+ padding: 14px 50px 32px;
72
+ }
73
+ #resources li {
74
+ padding: 5px;
75
+ list-style-position: outside;
76
+ list-style-type: disc;
77
+ text-decoration: none;
78
+ font-weight: normal;
79
+ font-size: 1.4em;
80
+ }
81
+ .resource_url {
82
+ border: 1px solid white;
83
+ display: block;
84
+ margin-top: 11px;
85
+ padding: 12px 12px 18px;
86
+ }
87
+ .resource_url .action {
88
+ padding-left: 46px;
89
+ font-weight: bold;
90
+ }
91
+ #search_frame #search {
92
+ display: none;
93
+ }
94
+ .parameters {
95
+ padding: 12px;
96
+ border: 1px solid white;
97
+ }
98
+ .parameters ul li {
99
+ display: block;
100
+ padding: 4px 0 0 6px;
101
+ }
102
+ .parameters ul li .name {
103
+ font-weight: bold;
104
+ padding-right: 10px;
105
+ }
106
+ .parameters ul li .text {
107
+ display: block;
108
+ }
109
+ .parameters ul li .text p {
110
+ margin-top: 0px;
111
+ }
112
+ .parameters ul li .type tt {
113
+ font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif; /*taken from original yard style.css*/
114
+ }
115
+ .odd {
116
+ background: #EAF0FF;
117
+ }
118
+ .even {
119
+ background: #D5E1FF;
120
+ }
121
+ .examples {
122
+ padding: 32px 12px 12px 12px;
123
+ }
124
+ .example {
125
+ border-bottom: 1px solid #BBB;
126
+ display: block;
127
+ padding: 18px 0 26px;
128
+ margin-bottom: 14px;
129
+ margin-top: 8px;
130
+ }
131
+ .example .description {
132
+ display: block;
133
+ font-size: 1.2em;
134
+ margin: 8px 0;
135
+ }
136
+
137
+ .example .hash {
138
+ display: block;
139
+ background: #EEF;
140
+ font-size: 1.1em;
141
+ border-radius: 4px;
142
+ box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
143
+ padding: 12px;
144
+ }
145
+
146
+ .example .hash .type {
147
+ display: block;
148
+ font-size: 0.8em;
149
+ color: #99A;
150
+ padding-bottom: 6px;
151
+ }
152
+
153
+ .example .hash.request {
154
+ border-bottom-left-radius: 0;
155
+ border-bottom-right-radius: 0;
156
+ }
157
+
158
+ .example .hash.response {
159
+ border-top: 1px solid white;
160
+ border-top-left-radius: 0;
161
+ border-top-right-radius: 0;
162
+ }
163
+
164
+ pre.code.json {
165
+ margin: 0;
166
+ }
167
+
168
+ pre.code.json code {
169
+ position: relative;
170
+ border: 1px solid transparent;
171
+ border-radius: 6px;
172
+ }
173
+
174
+ pre.code.json code:hover {
175
+ background: #d4e5fe;
176
+ }
177
+
178
+ pre.code.json code:active {
179
+ background: #c1d8fb;
180
+ }
181
+
182
+ .object_properties_title {
183
+ margin-bottom: 16px;
184
+ }
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title><%= options.title %></title>
8
+ </head>
9
+ <script type="text/javascript" charset="utf-8">
10
+ window.onload = function() {
11
+ var match = window.location.hash.match(/^#!(.+)/);
12
+ var name = '<%= url_for_main %>';
13
+ if (match) {
14
+ name = unescape(match[1]);
15
+ }
16
+ document.writeln('<frameset cols="20%,*">' +
17
+ '<frame name="list" src="<%= url_for_list('resource') %>" />' +
18
+ '<frame name="main" src="' + name + '" />' +
19
+ '</frameset>');
20
+ }
21
+ </script>
22
+ <noscript>
23
+ <frameset cols="20%,*">
24
+ <frame name="list" src="<%= url_for_list('resource') %>" />
25
+ <frame name="main" src="<%= url_for_main %>" />
26
+ </frameset>
27
+ </noscript>
28
+ </html>
@@ -0,0 +1,6 @@
1
+ <% @items.each do |obj| %>
2
+ <li class="<%= rotate(:r2_r1_r2) %>">
3
+ <%= linkify(obj, obj.name) %>
4
+ </li>
5
+ <% end %>
6
+
@@ -0,0 +1,5 @@
1
+ <% @items.each do |resource| %>
2
+ <li class="<%= rotate(:r2_r1) %>">
3
+ <%= linkify(resource, resource.name.to_s.gsub(/Controller/, "")) %>
4
+ </li>
5
+ <% end %>
@@ -0,0 +1,55 @@
1
+ function setup_toc() {
2
+ if ($('#content').length === 0) return;
3
+ var _toc = $('<ol class="top"></ol>');
4
+ var show = false;
5
+ var toc = _toc;
6
+ var counter = 0;
7
+ var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
8
+ var i;
9
+ if ($('#content h1').length > 1) tags.unshift('h1');
10
+ for (i = 0; i < tags.length; i++) { tags[i] = '#content ' + tags[i]; }
11
+ var lastTag = parseInt(tags[0][1], 10);
12
+ $(tags.join(', ')).each(function() {
13
+ if (this.id == "content") return;
14
+ show = true;
15
+ var thisTag = parseInt(this.tagName[1], 10);
16
+ if (this.id.length === 0) {
17
+ var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
18
+ if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
19
+ this.id = proposedId;
20
+ }
21
+ if (thisTag > lastTag) {
22
+ for (i = 0; i < thisTag - lastTag; i++) {
23
+ var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
24
+ }
25
+ }
26
+ if (thisTag < lastTag) {
27
+ for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
28
+ }
29
+ toc.append('<li><a href="#' + this.id + '">' + $(this).text() + '</a></li>');
30
+ lastTag = thisTag;
31
+ });
32
+ if (!show) return;
33
+ html = '<div id="toc"><p class="title"><a class="hide_toc" href="#"><strong>Table of Contents</strong></a> <small>(<a href="#" class="float_toc">left</a>)</small></p></div>';
34
+ $('#content').prepend(html);
35
+ $('#toc').append(_toc);
36
+ $('#toc .hide_toc').toggle(function() {
37
+ $('#toc .top').slideUp('fast');
38
+ $('#toc').toggleClass('hidden');
39
+ $('#toc .title small').toggle();
40
+ }, function() {
41
+ $('#toc .top').slideDown('fast');
42
+ $('#toc').toggleClass('hidden');
43
+ $('#toc .title small').toggle();
44
+ });
45
+ $('#toc .float_toc').toggle(function() {
46
+ $(this).text('float');
47
+ $('#toc').toggleClass('nofloat');
48
+ }, function() {
49
+ $(this).text('left');
50
+ $('#toc').toggleClass('nofloat');
51
+ });
52
+ }
53
+ $(document).ready(function(){
54
+ setup_toc();
55
+ });
@@ -0,0 +1,22 @@
1
+ include Helpers::ModuleHelper
2
+ include Helpers::FilterHelper
3
+
4
+ def generate_object_list
5
+ @items = select_objects(@objects)
6
+ @list_title = "List of Objects"
7
+ @list_type = "object"
8
+ generate_list_contents
9
+ end
10
+
11
+ def generate_resource_list
12
+ @items = select_resources(@objects)
13
+ @list_title = "List of Resources"
14
+ @list_type = "resource"
15
+ generate_list_contents
16
+ end
17
+
18
+ def init
19
+ super
20
+ asset("css/custom.css", file("css/custom.css", true))
21
+ end
22
+
@@ -0,0 +1,3 @@
1
+ <div id="footer">
2
+ Generated on <%= Time.now.strftime("%c") %> with ruby-<%= RUBY_VERSION %>
3
+ </div>
@@ -0,0 +1,17 @@
1
+ <div id="start">
2
+ <h1 class="noborder title"><%= options[:title] %></h1>
3
+
4
+ <%= htmlify(@readme.contents) if @readme%>
5
+
6
+ <h2>All Resources</h2>
7
+ <ul id="resources">
8
+ <% unless @resources.nil? %>
9
+ <% @resources.each do |resource| %>
10
+ <li><%= linkify(resource, resource.name.to_s.gsub(/Controller/, "")) %></li>
11
+ <% end %>
12
+ <% end %>
13
+ </ul>
14
+
15
+ <div class="clear"></div>
16
+
17
+ </div>
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <%= erb(:headers) %>
6
+ </head>
7
+ <body>
8
+ <div id="header">
9
+ <%= erb(:search) %>
10
+ </div>
11
+
12
+ <iframe id="search_frame"></iframe>
13
+
14
+ <div id="content" style="padding-top: 12px;">
15
+ <%= yieldall %>
16
+ </div>
17
+
18
+ <%= erb(:footer) %>
19
+ </body>
20
+ </html>
@@ -0,0 +1,33 @@
1
+ include Helpers::FilterHelper
2
+
3
+ def init
4
+ @page_title = options[:title]
5
+ if object == "_index.html"
6
+
7
+ elsif object.name == :root
8
+ sections :layout, [:index]
9
+ else
10
+ super
11
+ end
12
+ end
13
+
14
+ def stylesheets
15
+ super + %w(css/custom.css)
16
+ end
17
+
18
+ def javascripts
19
+ super + %w(js/rest_plugin.js)
20
+ end
21
+
22
+ def menu_lists
23
+ [
24
+ { :type => 'resource', :title => "Resources", :search_title => "Resources" },
25
+ { :type => 'object', :title => "Objects", :search_title => "Objects" }
26
+ ]
27
+ end
28
+
29
+ def index
30
+ @readme = options[:readme]
31
+ @resources = select_resources(@objects)
32
+ erb(:index)
33
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yard-restful
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Konstantin Rafalsky
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: yard
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.3
30
+ description: A customized plugin for Yardoc that produces API documentation for Restful
31
+ web services
32
+ email: ''
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files:
36
+ - README.markdown
37
+ - VERSION
38
+ files:
39
+ - Rakefile
40
+ - lib/yard-rest.rb
41
+ - lib/yard-rest/html_blocks_helper.rb
42
+ - lib/yard-rest/rest_filters.rb
43
+ - lib/yard-rest/tags.rb
44
+ - templates/default/class/html/fields_list.erb
45
+ - templates/default/class/html/header.erb
46
+ - templates/default/class/html/object_details.erb
47
+ - templates/default/class/html/resource_details.erb
48
+ - templates/default/class/html/setup.rb
49
+ - templates/default/docstring/html/setup.rb
50
+ - templates/default/docstring/html/text.erb
51
+ - templates/default/fulldoc/html/css/custom.css
52
+ - templates/default/fulldoc/html/frames.erb
53
+ - templates/default/fulldoc/html/full_list_object.erb
54
+ - templates/default/fulldoc/html/full_list_resource.erb
55
+ - templates/default/fulldoc/html/js/rest_plugin.js
56
+ - templates/default/fulldoc/html/setup.rb
57
+ - templates/default/layout/html/footer.erb
58
+ - templates/default/layout/html/index.erb
59
+ - templates/default/layout/html/layout.erb
60
+ - templates/default/layout/html/setup.rb
61
+ - README.markdown
62
+ - VERSION
63
+ homepage: https://github.com/kraft/yard-restful
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.24
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Yardoc plugin for Restful web services
87
+ test_files: []