yard-rest 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/example/doc/README_FOR_API +12 -0
- data/templates/rest/class/html/header.erb +18 -0
- data/templates/rest/class/html/method_details_list.erb +80 -0
- data/templates/rest/class/html/setup.rb +16 -0
- data/templates/rest/docstring/html/setup.rb +4 -0
- data/templates/rest/docstring/html/text.erb +1 -0
- data/templates/rest/fulldoc/html/full_list_resource.erb +5 -0
- data/templates/rest/fulldoc/html/full_list_topic.erb +14 -0
- data/templates/rest/fulldoc/html/js/rest_plugin.js +22 -0
- data/templates/rest/fulldoc/html/setup.rb +23 -0
- data/templates/rest/layout/html/footer.erb +3 -0
- data/templates/rest/layout/html/index.erb +19 -0
- data/templates/rest/layout/html/layout.erb +210 -0
- data/templates/rest/layout/html/search.erb +4 -0
- data/templates/rest/layout/html/setup.rb +29 -0
- data/templates/rest/method_details/html/header.erb +3 -0
- data/templates/rest/method_details/html/method_url.erb +8 -0
- data/templates/rest/method_details/html/setup.rb +7 -0
- data/templates/rest/tags/html/example_request.erb +9 -0
- data/templates/rest/tags/html/example_response.erb +9 -0
- data/templates/rest/tags/html/generic_tag.erb +17 -0
- data/templates/rest/tags/html/index.erb +3 -0
- data/templates/rest/tags/html/key_for.erb +20 -0
- data/templates/rest/tags/html/value_for.erb +13 -0
- data/templates/rest/tags/setup.rb +47 -0
- metadata +26 -1
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "https://github.com/spape/yard-rest-plugin"
|
12
12
|
gem.authors = ['R. Kevin Nelson', 'Aisha Fenton', 'Sebastian Pape']
|
13
13
|
gem.add_dependency("yard", '~>0.7.4')
|
14
|
-
gem.files = Dir.glob("{lib,example,templates/rest}
|
14
|
+
gem.files = Dir.glob("{lib,example,templates/rest}/**/*").concat(["Rakefile"])
|
15
15
|
gem.extra_rdoc_files = ['VERSION', 'README.markdown']
|
16
16
|
end
|
17
17
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## Introduction
|
2
|
+
Welcome to the API documentation.
|
3
|
+
|
4
|
+
## Quick Example
|
5
|
+
/examples.json
|
6
|
+
This returns a list of examples.
|
7
|
+
|
8
|
+
## JSON as Standard Format
|
9
|
+
Our standard format for the API is JSON. To communicate to the API you have to set the format explicitly on each request.
|
10
|
+
### How to send JSON-Requests
|
11
|
+
/examples.json
|
12
|
+
/examples (with Header: "Accept: application/json")
|
@@ -0,0 +1,18 @@
|
|
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">« back to overview</a>
|
4
|
+
<h2><%= object.name.to_s.gsub(/Controller/,"") %></h2>
|
5
|
+
<%= yieldall %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<% unless @meths.empty? %>
|
2
|
+
<div id="Services" class="method_details_list">
|
3
|
+
<% @meths.each_with_index do |meth, i| %>
|
4
|
+
<div class="method">
|
5
|
+
<p class="method_desc"><%= meth.docstring %></p>
|
6
|
+
<h3 class="resource_url"><strong><%= meth.tag(:resource).text %></strong> [<%= meth.tag(:action).text %>]</h3>
|
7
|
+
|
8
|
+
<div class="parameters">
|
9
|
+
<% if meth.tags(:required).size %>
|
10
|
+
<div class="required">
|
11
|
+
<h4>Required Parameters</h4>
|
12
|
+
<% meth.tags(:required).each do |required| %>
|
13
|
+
<ul>
|
14
|
+
<li>
|
15
|
+
<span class="name"><%= required.name%></span>
|
16
|
+
<span class="type"><%= required.types.join%></span>
|
17
|
+
<span class="text"><%= required.text%></span>
|
18
|
+
</li>
|
19
|
+
</ul>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<% if meth.tags(:optional).size %>
|
25
|
+
<div class="optional">
|
26
|
+
<h4>Optional Parameters</h4>
|
27
|
+
<% meth.tags(:optional).each do |optional| %>
|
28
|
+
<ul>
|
29
|
+
<li>
|
30
|
+
<span class="name"><%= optional.name%></span>
|
31
|
+
<span class="type"><%= optional.types.join%></span>
|
32
|
+
<span class="text"><%= optional.text%></span>
|
33
|
+
</li>
|
34
|
+
</ul>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
38
|
+
</div><!-- parameters -->
|
39
|
+
|
40
|
+
<% if meth.tags(:response_field).size %>
|
41
|
+
<div class="response_fields">
|
42
|
+
<h4>Response Fields</h4>
|
43
|
+
<% meth.tags(:response_field).each do |response_field| %>
|
44
|
+
<ul>
|
45
|
+
<li>
|
46
|
+
<span class="name"><%= response_field.name%></span>
|
47
|
+
<span class="type"><%= response_field.types.join%></span>
|
48
|
+
<span class="text"><%= response_field.text%></span>
|
49
|
+
</li>
|
50
|
+
</ul>
|
51
|
+
<% end %>
|
52
|
+
</div>
|
53
|
+
<% end %>
|
54
|
+
|
55
|
+
<% if meth.tags(:example_request).size %>
|
56
|
+
<div class="examples">
|
57
|
+
<h4>Examples</h4>
|
58
|
+
<% meth.tags(:example_request).each_with_index do |example_request, i| %>
|
59
|
+
<div class="example">
|
60
|
+
<% example_request_description = meth.tags(:example_request_description)[i] %>
|
61
|
+
<% example_response = meth.tags(:example_response)[i] %>
|
62
|
+
<% example_response_description = meth.tags(:example_response_description)[i] %>
|
63
|
+
<span class="description"><%= (example_request_description.nil?) ? "" : example_request_description.text %></span>
|
64
|
+
<span class="hash request">
|
65
|
+
<strong class="type">Request</strong>
|
66
|
+
<%= (example_request.nil?) ? "" : example_request.text %>
|
67
|
+
</span>
|
68
|
+
<span class="hash response">
|
69
|
+
<strong class="type">Response</strong>
|
70
|
+
<%= (example_response.nil?) ? "" : example_response.text %>
|
71
|
+
</span>
|
72
|
+
<span class="description"><%= (example_response_description.nil?) ? "" : example_response_description.text %></span>
|
73
|
+
</div>
|
74
|
+
<% end %>
|
75
|
+
</div>
|
76
|
+
<% end %>
|
77
|
+
</div>
|
78
|
+
<% end %>
|
79
|
+
</div>
|
80
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
def init
|
2
|
+
@page_title = "#{object.name.to_s.gsub(/Controller/,"")} - #{options[:title]}"
|
3
|
+
sections :header, [T('docstring'), :method_details_list, [T('method_details')]]
|
4
|
+
end
|
5
|
+
|
6
|
+
def method_details_list
|
7
|
+
objects = Array(object)
|
8
|
+
objects_with_resources_tags = index_objects(objects)
|
9
|
+
@meths = []
|
10
|
+
unless objects_with_resources_tags.empty?
|
11
|
+
objects_with_resources_tags.each do |obj|
|
12
|
+
@meths += obj.meths.select{|x| x.has_tag? :resource}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
erb(:method_details_list)
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= htmlify(object.docstring.strip) %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<li><a href="<%= url_for('_index.html') %>">Index</a></li>
|
2
|
+
<% n = 1 %>
|
3
|
+
<% @topics.sort_by {|s,o| s }.each do |topic,objects| %>
|
4
|
+
<li class="r<%= n %>"><%= topic%></li>
|
5
|
+
<% unless objects.empty? %>
|
6
|
+
<% objects.each do |object| %>
|
7
|
+
<% object.tags("url").each do |url_tag| %>
|
8
|
+
<li class="r<%= n %>"><%= linkify(object, url_tag.text) %></li>
|
9
|
+
<% end %>
|
10
|
+
<% end%>
|
11
|
+
<% end %>
|
12
|
+
<% n = n == 2 ? 1 : 2 %>
|
13
|
+
<% end %>
|
14
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
function resourceSearchFrameLinks() {
|
2
|
+
$('#resource_list_link').click(function() {
|
3
|
+
toggleSearchFrame(this, relpath + 'resource_list.html');
|
4
|
+
});
|
5
|
+
}
|
6
|
+
|
7
|
+
$(resourceSearchFrameLinks);
|
8
|
+
|
9
|
+
/*
|
10
|
+
function resourceKeyboardShortcuts() {
|
11
|
+
if (window.top.frames.main) return;
|
12
|
+
$(document).keypress(function(evt) {
|
13
|
+
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
|
14
|
+
if (typeof evt.orignalTarget !== "undefined" &&
|
15
|
+
(evt.originalTarget.nodeName == "INPUT" ||
|
16
|
+
evt.originalTarget.nodeName == "TEXTAREA")) return;
|
17
|
+
switch (evt.charCode) {
|
18
|
+
case 82: case 114: $('#resource_list_link').click(); break; // 'r' or 'R'
|
19
|
+
}
|
20
|
+
});
|
21
|
+
}
|
22
|
+
*/
|
@@ -0,0 +1,23 @@
|
|
1
|
+
include Helpers::ModuleHelper
|
2
|
+
include Helpers::FilterHelper
|
3
|
+
|
4
|
+
def generate_topic_list
|
5
|
+
topic_objects = index_objects(@objects).reject { |o| o.root? }
|
6
|
+
@topics = {}
|
7
|
+
|
8
|
+
topic_objects.each do |object|
|
9
|
+
object.tags('topic').each { |topic| (@topics[topic.text] ||= []) << object }
|
10
|
+
end
|
11
|
+
|
12
|
+
@list_title = 'Topic List'
|
13
|
+
@list_type = 'topic'
|
14
|
+
|
15
|
+
asset('topic_list.html', erb(:full_list))
|
16
|
+
end
|
17
|
+
|
18
|
+
def generate_resource_list
|
19
|
+
@items = index_objects(@objects)
|
20
|
+
@list_title = "List of Resources"
|
21
|
+
@list_type = "resource"
|
22
|
+
asset('resource_list.html', erb(:full_list))
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div id="start">
|
2
|
+
<h1 class="noborder title"><%= options[:title] %></h1>
|
3
|
+
|
4
|
+
<% if @readme %>
|
5
|
+
<%= htmlify(@readme.contents, :markdown) %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<h2>All Resources</h2>
|
9
|
+
<ul id="resources">
|
10
|
+
<% unless @resources.nil? %>
|
11
|
+
<% @resources.sort_by { |s| s.name.to_s }.each do |resource| %>
|
12
|
+
<li><%= linkify(resource, resource.name.to_s.gsub(/Controller/, "")) %></li>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
|
17
|
+
<div class="clear"></div>
|
18
|
+
|
19
|
+
</div>
|
@@ -0,0 +1,210 @@
|
|
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
|
+
<style type="text/css">
|
7
|
+
#toc {top: 24px;}
|
8
|
+
#toc .title {display: none;}
|
9
|
+
#toc a:link, #content a:visited { text-decoration: none; color: #05a; }
|
10
|
+
#toc a:hover { background: #ffffa5; }
|
11
|
+
pre code {
|
12
|
+
display: block;
|
13
|
+
background: #EAF0FF;
|
14
|
+
padding: 12px;
|
15
|
+
line-height: 1.9em;
|
16
|
+
}
|
17
|
+
a.back {
|
18
|
+
font-size: 1.2em;
|
19
|
+
padding: 4px;
|
20
|
+
}
|
21
|
+
p.method_desc {
|
22
|
+
padding: 16px 0 0 14px;
|
23
|
+
font-size: 1.2em;
|
24
|
+
}
|
25
|
+
h2 {
|
26
|
+
margin: 2.4em 0 0.5em;
|
27
|
+
}
|
28
|
+
h2 + p {
|
29
|
+
font-size: 1.2em;
|
30
|
+
margin-bottom: 62px;
|
31
|
+
}
|
32
|
+
.method {
|
33
|
+
display: block;
|
34
|
+
margin-top: 40px;
|
35
|
+
padding-top: 0;
|
36
|
+
position: relative;
|
37
|
+
box-shadow: 0 -6px 12px rgba(0,0,0,0.1);
|
38
|
+
}
|
39
|
+
h3 {
|
40
|
+
font-size: 1.2em;
|
41
|
+
font-weight: normal;
|
42
|
+
padding-top: 6px;
|
43
|
+
margin-bottom: -6px;
|
44
|
+
}
|
45
|
+
h4 {
|
46
|
+
margin: 0;
|
47
|
+
}
|
48
|
+
#resources {
|
49
|
+
padding: 14px 20px 52px;
|
50
|
+
}
|
51
|
+
#resources li {
|
52
|
+
border-right: 1px solid #0055AA;
|
53
|
+
display: block;
|
54
|
+
font-size: 1.4em;
|
55
|
+
float: left;
|
56
|
+
padding-right: 14px;
|
57
|
+
padding-left: 12px;
|
58
|
+
}
|
59
|
+
.resource_url {
|
60
|
+
border: 1px solid white;
|
61
|
+
display: block;
|
62
|
+
background: #EAF0FF;
|
63
|
+
margin-top: 11px;
|
64
|
+
padding: 12px 12px 18px;
|
65
|
+
}
|
66
|
+
#search_frame #search {
|
67
|
+
display: none;
|
68
|
+
}
|
69
|
+
.parameters, .response_fields {
|
70
|
+
background: none repeat scroll 0 0 #EAF0FF;
|
71
|
+
}
|
72
|
+
.parameters .required {
|
73
|
+
background: #d5e1ff;
|
74
|
+
padding: 12px;
|
75
|
+
border: 1px solid white;
|
76
|
+
}
|
77
|
+
.parameters .optional, .response_fields {
|
78
|
+
padding: 18px 12px 12px 12px;
|
79
|
+
border: 1px solid white;
|
80
|
+
}
|
81
|
+
.parameters .optional ul li, .parameters .required li, .response_fields li {
|
82
|
+
display: block;
|
83
|
+
padding: 4px 0 0 6px;
|
84
|
+
}
|
85
|
+
.parameters .optional ul li .name, .parameters .required li .name, .response_fields li .name {
|
86
|
+
font-weight: bold;
|
87
|
+
}
|
88
|
+
.parameters .optional ul li .text, .parameters .required li .text, .response_fields li .text {
|
89
|
+
display: block;
|
90
|
+
}
|
91
|
+
.examples {
|
92
|
+
padding: 32px 12px 12px 12px;
|
93
|
+
}
|
94
|
+
.example {
|
95
|
+
border-bottom: 1px solid #BBB;
|
96
|
+
display: block;
|
97
|
+
padding: 18px 0 26px;
|
98
|
+
margin-bottom: 14px;
|
99
|
+
margin-top: 8px;
|
100
|
+
}
|
101
|
+
.example .description {
|
102
|
+
display: block;
|
103
|
+
font-size: 1.2em;
|
104
|
+
margin: 8px 0;
|
105
|
+
}
|
106
|
+
|
107
|
+
.example .hash {
|
108
|
+
display: block;
|
109
|
+
background: #EEF;
|
110
|
+
font-size: 1.1em;
|
111
|
+
border-radius: 4px;
|
112
|
+
box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
|
113
|
+
padding: 12px;
|
114
|
+
}
|
115
|
+
|
116
|
+
.example .hash .type {
|
117
|
+
display: block;
|
118
|
+
font-size: 0.8em;
|
119
|
+
color: #99A;
|
120
|
+
padding-bottom: 6px;
|
121
|
+
}
|
122
|
+
|
123
|
+
.example .hash.request {
|
124
|
+
border-bottom-left-radius: 0;
|
125
|
+
border-bottom-right-radius: 0;
|
126
|
+
}
|
127
|
+
|
128
|
+
.example .hash.response {
|
129
|
+
border-top: 1px solid white;
|
130
|
+
border-top-left-radius: 0;
|
131
|
+
border-top-right-radius: 0;
|
132
|
+
}
|
133
|
+
</style>
|
134
|
+
<script type="text/javascript">
|
135
|
+
//<![CDATA[
|
136
|
+
|
137
|
+
function setup_toc() {
|
138
|
+
if ($('#content').length === 0) return;
|
139
|
+
var _toc = $('<ol class="top"></ol>');
|
140
|
+
var show = false;
|
141
|
+
var toc = _toc;
|
142
|
+
var counter = 0;
|
143
|
+
var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
|
144
|
+
var i;
|
145
|
+
if ($('#content h1').length > 1) tags.unshift('h1');
|
146
|
+
for (i = 0; i < tags.length; i++) { tags[i] = '#content ' + tags[i]; }
|
147
|
+
var lastTag = parseInt(tags[0][1], 10);
|
148
|
+
$(tags.join(', ')).each(function() {
|
149
|
+
if (this.id == "content") return;
|
150
|
+
show = true;
|
151
|
+
var thisTag = parseInt(this.tagName[1], 10);
|
152
|
+
if (this.id.length === 0) {
|
153
|
+
var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
|
154
|
+
if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
|
155
|
+
this.id = proposedId;
|
156
|
+
}
|
157
|
+
if (thisTag > lastTag) {
|
158
|
+
for (i = 0; i < thisTag - lastTag; i++) {
|
159
|
+
var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
if (thisTag < lastTag) {
|
163
|
+
for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
|
164
|
+
}
|
165
|
+
toc.append('<li><a href="#' + this.id + '">' + $(this).text() + '</a></li>');
|
166
|
+
lastTag = thisTag;
|
167
|
+
});
|
168
|
+
if (!show) return;
|
169
|
+
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>';
|
170
|
+
$('#content').prepend(html);
|
171
|
+
$('#toc').append(_toc);
|
172
|
+
$('#toc .hide_toc').toggle(function() {
|
173
|
+
$('#toc .top').slideUp('fast');
|
174
|
+
$('#toc').toggleClass('hidden');
|
175
|
+
$('#toc .title small').toggle();
|
176
|
+
}, function() {
|
177
|
+
$('#toc .top').slideDown('fast');
|
178
|
+
$('#toc').toggleClass('hidden');
|
179
|
+
$('#toc .title small').toggle();
|
180
|
+
});
|
181
|
+
$('#toc .float_toc').toggle(function() {
|
182
|
+
$(this).text('float');
|
183
|
+
$('#toc').toggleClass('nofloat');
|
184
|
+
}, function() {
|
185
|
+
$(this).text('left');
|
186
|
+
$('#toc').toggleClass('nofloat');
|
187
|
+
});
|
188
|
+
}
|
189
|
+
$(document).ready(setup_toc);
|
190
|
+
//]]>
|
191
|
+
</script>
|
192
|
+
</head>
|
193
|
+
<body>
|
194
|
+
<script type="text/javascript" charset="utf-8">
|
195
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
196
|
+
</script>
|
197
|
+
|
198
|
+
<div id="header">
|
199
|
+
<%= erb(:search) %>
|
200
|
+
</div>
|
201
|
+
|
202
|
+
<iframe id="search_frame"></iframe>
|
203
|
+
|
204
|
+
<div id="content" style="padding-top: 12px;">
|
205
|
+
<%= yieldall %>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
<%= erb(:footer) %>
|
209
|
+
</body>
|
210
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
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 javascripts
|
15
|
+
super + %w(js/rest_plugin.js)
|
16
|
+
end
|
17
|
+
|
18
|
+
def menu_lists
|
19
|
+
[ { :type => 'resource', :title => "Resources", :search_title => "List of Resources" },
|
20
|
+
{ :type => 'topic', :title => "Topics", :search_title => "Topic List" },
|
21
|
+
{ :type => 'file', :title => "Files", :search_title => "File List" } ]
|
22
|
+
end
|
23
|
+
|
24
|
+
def index
|
25
|
+
path_to_readme = (options[:readme]) ? options[:readme] : "./doc/README_FOR_API"
|
26
|
+
@readme = YARD::CodeObjects::ExtraFileObject.new(path_to_readme) if File.exists?(path_to_readme)
|
27
|
+
@resources = index_objects(@objects)
|
28
|
+
erb(:index)
|
29
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% if object.has_tag?(:example_request) %>
|
2
|
+
<div class="examples">
|
3
|
+
<h3>Example Request:</h3>
|
4
|
+
<% object.tags(:example_request).each do |tag| %>
|
5
|
+
<h4><%= htmlify_line(tag.name) %></h4>
|
6
|
+
<pre class="example code"><%= html_syntax_highlight(tag.text, :plain) %></pre>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% if object.has_tag?(:example_response) %>
|
2
|
+
<div class="examples">
|
3
|
+
<h3>Example Response:</h3>
|
4
|
+
<% object.tags(:example_response).each do |tag| %>
|
5
|
+
<h4><%= htmlify_line(tag.name) %></h4>
|
6
|
+
<pre class="example code"><%= html_syntax_highlight(tag.text, :plain) %></pre>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<h3><%= @label ? @label : YARD::Tags::Library.labels[@name] %>:</h3>
|
2
|
+
<ul class="<%= @name %>">
|
3
|
+
<% object.tags(@name).each do |tag| %>
|
4
|
+
<li>
|
5
|
+
<% unless @no_types %>
|
6
|
+
<span class='type'><%= format_types(tag.types) %></span>
|
7
|
+
<% end %>
|
8
|
+
<% unless @no_names %>
|
9
|
+
<span class='name'><%= h tag.name %></span>
|
10
|
+
<% end %>
|
11
|
+
<% if tag.text && !tag.text.empty? %>
|
12
|
+
<% unless (@no_types || tag.types.nil? || tag.types.empty?) && @no_names %>—<% end %>
|
13
|
+
<%= htmlify_line(tag.text) %>
|
14
|
+
<% end %>
|
15
|
+
</li>
|
16
|
+
<% end %>
|
17
|
+
</ul>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% if object.has_tag?(:key_for) %>
|
2
|
+
<% object.tags(:key_for).group_by{|tag| tag.name }.each_pair do |hash_name, tags| %>
|
3
|
+
<h3>Keys for Hash (<tt><%= hash_name %></tt>):</h3>
|
4
|
+
<ul>
|
5
|
+
<% tags.each do |tag| %>
|
6
|
+
<li>
|
7
|
+
<span class="name"><%= tag.pair.name %></span>
|
8
|
+
<span class="type"><%= format_types(tag.pair.types) || ['Object'] %></span>
|
9
|
+
<span class="default">
|
10
|
+
<% if tag.pair.defaults %>
|
11
|
+
— default:
|
12
|
+
<%= tag.pair.defaults.map {|t| "<tt>#{h t}</tt>" }.join(", ") %>
|
13
|
+
<% end %>
|
14
|
+
</span>
|
15
|
+
<%= htmlify_line(tag.pair.text) if tag.pair.text %>
|
16
|
+
</li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% if object.has_tag?(:value_for) %>
|
2
|
+
<% object.tags(:value_for).group_by{|tag| tag.name }.each_pair do |argument_name, tags| %>
|
3
|
+
<h3>Valid values for (<tt><%= argument_name %></tt>):</h3>
|
4
|
+
<ul>
|
5
|
+
<% tags.each do |tag| %>
|
6
|
+
<li>
|
7
|
+
<span class="name"><%= tag.pair.name %></span>
|
8
|
+
<%= htmlify_line(tag.pair.text) if tag.pair.text %>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
def init
|
2
|
+
super
|
3
|
+
sections.push(:index,[:argument,
|
4
|
+
:optional_argument,
|
5
|
+
:key_for,
|
6
|
+
:value_for,
|
7
|
+
:example_request,
|
8
|
+
:request_field,
|
9
|
+
:example_response,
|
10
|
+
:response_field,
|
11
|
+
:header,
|
12
|
+
:response_code])
|
13
|
+
end
|
14
|
+
|
15
|
+
def request_field
|
16
|
+
generic_tag :request_field
|
17
|
+
end
|
18
|
+
|
19
|
+
def response_field
|
20
|
+
generic_tag :response_field
|
21
|
+
end
|
22
|
+
|
23
|
+
def argument
|
24
|
+
generic_tag :argument, :no_types => false
|
25
|
+
end
|
26
|
+
|
27
|
+
def optional_argument
|
28
|
+
generic_tag :optional_argument, :no_types => false
|
29
|
+
end
|
30
|
+
|
31
|
+
def header
|
32
|
+
generic_tag :header
|
33
|
+
end
|
34
|
+
|
35
|
+
def response_code
|
36
|
+
generic_tag :response_code
|
37
|
+
end
|
38
|
+
|
39
|
+
def generic_tag(name, opts = {})
|
40
|
+
return unless object.has_tag?(name)
|
41
|
+
@no_names = true if opts[:no_names]
|
42
|
+
@no_types = true if opts[:no_types]
|
43
|
+
@name = name
|
44
|
+
out = erb('generic_tag')
|
45
|
+
@no_names, @no_types = nil, nil
|
46
|
+
out
|
47
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -40,9 +40,34 @@ extra_rdoc_files:
|
|
40
40
|
files:
|
41
41
|
- Rakefile
|
42
42
|
- example/app/controllers/examples_controller.rb
|
43
|
+
- example/doc/README_FOR_API
|
43
44
|
- lib/yard-rest.rb
|
44
45
|
- lib/yard-rest/rest_filters.rb
|
45
46
|
- lib/yard-rest/tags.rb
|
47
|
+
- templates/rest/class/html/header.erb
|
48
|
+
- templates/rest/class/html/method_details_list.erb
|
49
|
+
- templates/rest/class/html/setup.rb
|
50
|
+
- templates/rest/docstring/html/setup.rb
|
51
|
+
- templates/rest/docstring/html/text.erb
|
52
|
+
- templates/rest/fulldoc/html/full_list_resource.erb
|
53
|
+
- templates/rest/fulldoc/html/full_list_topic.erb
|
54
|
+
- templates/rest/fulldoc/html/js/rest_plugin.js
|
55
|
+
- templates/rest/fulldoc/html/setup.rb
|
56
|
+
- templates/rest/layout/html/footer.erb
|
57
|
+
- templates/rest/layout/html/index.erb
|
58
|
+
- templates/rest/layout/html/layout.erb
|
59
|
+
- templates/rest/layout/html/search.erb
|
60
|
+
- templates/rest/layout/html/setup.rb
|
61
|
+
- templates/rest/method_details/html/header.erb
|
62
|
+
- templates/rest/method_details/html/method_url.erb
|
63
|
+
- templates/rest/method_details/html/setup.rb
|
64
|
+
- templates/rest/tags/html/example_request.erb
|
65
|
+
- templates/rest/tags/html/example_response.erb
|
66
|
+
- templates/rest/tags/html/generic_tag.erb
|
67
|
+
- templates/rest/tags/html/index.erb
|
68
|
+
- templates/rest/tags/html/key_for.erb
|
69
|
+
- templates/rest/tags/html/value_for.erb
|
70
|
+
- templates/rest/tags/setup.rb
|
46
71
|
- README.markdown
|
47
72
|
- VERSION
|
48
73
|
homepage: https://github.com/spape/yard-rest-plugin
|