yard-rest-plugin 0.1.0
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.
- data/README.markdown +0 -0
- data/Rakefile +31 -0
- data/VERSION +1 -0
- data/example/README.markdown +11 -0
- data/example/SampleController.rb +84 -0
- data/lib/yard_rest_plugin.rb +14 -0
- data/lib/yard_rest_plugin/base_helper.rb +18 -0
- data/templates/rest/.DS_Store +0 -0
- data/templates/rest/class/html/setup.rb +1 -0
- data/templates/rest/docstring/html/setup.rb +4 -0
- data/templates/rest/docstring/html/text.erb +1 -0
- data/templates/rest/fulldoc/.DS_Store +0 -0
- data/templates/rest/fulldoc/html/.DS_Store +0 -0
- data/templates/rest/fulldoc/html/css/common.css +1 -0
- data/templates/rest/fulldoc/html/css/full_list.css +78 -0
- data/templates/rest/fulldoc/html/css/style.css +225 -0
- data/templates/rest/fulldoc/html/full_list.erb +29 -0
- data/templates/rest/fulldoc/html/full_list_files.erb +5 -0
- data/templates/rest/fulldoc/html/full_list_service.erb +6 -0
- data/templates/rest/fulldoc/html/js/app.js +39 -0
- data/templates/rest/fulldoc/html/js/full_list.js +55 -0
- data/templates/rest/fulldoc/html/js/jquery.js +19 -0
- data/templates/rest/fulldoc/html/setup.rb +87 -0
- data/templates/rest/layout/html/footer.erb +3 -0
- data/templates/rest/layout/html/headers.erb +13 -0
- data/templates/rest/layout/html/index.erb +40 -0
- data/templates/rest/layout/html/layout.erb +22 -0
- data/templates/rest/layout/html/search.erb +4 -0
- data/templates/rest/layout/html/setup.rb +58 -0
- data/templates/rest/method_details/html/header.erb +3 -0
- data/templates/rest/method_details/html/method_signature.erb +7 -0
- data/templates/rest/method_details/html/setup.rb +7 -0
- data/templates/rest/module/html/header.erb +4 -0
- data/templates/rest/module/html/method_details_list.erb +6 -0
- data/templates/rest/module/setup.rb +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/setup.rb +22 -0
- data/yard-rest-plugin.gemspec +76 -0
- metadata +101 -0
data/README.markdown
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "yard-rest-plugin"
|
8
|
+
gem.summary = %Q{A plugin for Yardoc that produces API documentation for Restful web services}
|
9
|
+
gem.description = %Q{A plugin for Yardoc that produces API documentation for Restful web services}
|
10
|
+
gem.email = "aisha.fenton@visfleet.com"
|
11
|
+
gem.homepage = "http://github.com/visfleet/yard-rest-plugin"
|
12
|
+
gem.authors = ["Aisha Fenton"]
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :ex do
|
21
|
+
desc "Generate example docs"
|
22
|
+
task :generate do
|
23
|
+
`yardoc 'example/*.rb' -t rest --backtrace -p ./templates -e ./lib/yard_rest_plugin.rb -r example/README.markdown --title 'Sample API'`
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Clean example docs"
|
27
|
+
task :clean do
|
28
|
+
`rm -R doc`
|
29
|
+
`rm -R .yardoc`
|
30
|
+
end
|
31
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Sample API
|
2
|
+
==========
|
3
|
+
This is a sample API. You should see:
|
4
|
+
|
5
|
+
- This file
|
6
|
+
- An index containing one service /sample.
|
7
|
+
- That service should contain only one action: Index
|
8
|
+
- Index should have a description, list of arguments, an example response, and a list of response fields.
|
9
|
+
- Nothing else should be included because it doesn't have a URL specified.
|
10
|
+
|
11
|
+
Click [here](./_index.html) to go to the Index
|
@@ -0,0 +1,84 @@
|
|
1
|
+
##
|
2
|
+
# The Sample sevices let you list, create, update, and delete Samples from our application.
|
3
|
+
# @url /sample
|
4
|
+
#
|
5
|
+
class SampleController
|
6
|
+
|
7
|
+
##
|
8
|
+
# Retuns all samples, as XML, for the current user that match the given parameters.
|
9
|
+
#
|
10
|
+
# @url
|
11
|
+
# [GET] /samples/index.[format]?[arguments]
|
12
|
+
#
|
13
|
+
# @argument [String] format Only "xml" is support at this time.
|
14
|
+
# @argument [String] name The name of the sample
|
15
|
+
# @argument [String] reource The resource that sample belongs to
|
16
|
+
# @argument ["@assigned"|"@complete"|"!@complete"] search Return jobs that are assigned, complete, or
|
17
|
+
# uncomplete.
|
18
|
+
#
|
19
|
+
# @example_response
|
20
|
+
# <samples type="array">
|
21
|
+
# <sample>
|
22
|
+
# <id>961</id>
|
23
|
+
# <name>My Sample</name>
|
24
|
+
# <state>complete</state>
|
25
|
+
# <last_unassigned_user_id type="integer"></last_unassigned_user_id>
|
26
|
+
# <resource_id type="integer">127</resource_id>
|
27
|
+
# <notes></notes>
|
28
|
+
# <updated_at type="datetime">2010-03-09T20:43:29Z</updated_at>
|
29
|
+
# <created_at type="datetime">2010-03-09T20:43:16Z</created_at>
|
30
|
+
# </interval>
|
31
|
+
# <intervals>
|
32
|
+
#
|
33
|
+
# @response_field id A unique ID identifying the Sample
|
34
|
+
# @response_field name The name of the sample
|
35
|
+
# @response_field state The current status of the Sample. Can be complete, uncomplete, etc.
|
36
|
+
# @response_field notes Any notes given for the sample
|
37
|
+
# @response_field updated_at The Date/Time (in ISO8601) that the Sample was last updated
|
38
|
+
# @response_field created_at The Date/Time (in ISO8601) that the Sample was created
|
39
|
+
#
|
40
|
+
def index
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
#
|
45
|
+
# Shouldn't be included
|
46
|
+
def show
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# Creates a new Sample
|
51
|
+
# @url [POST] /new
|
52
|
+
# @url [POST] /really_new
|
53
|
+
#
|
54
|
+
def create
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# This one shouldn't show.
|
61
|
+
#
|
62
|
+
class BogusController
|
63
|
+
end
|
64
|
+
|
65
|
+
module First
|
66
|
+
module Second
|
67
|
+
|
68
|
+
##
|
69
|
+
# Third level deep namespace class
|
70
|
+
# @url /otherpath/third
|
71
|
+
#
|
72
|
+
class Third
|
73
|
+
|
74
|
+
##
|
75
|
+
# Does action!
|
76
|
+
# @url [PUT] /otherpath/third/action
|
77
|
+
#
|
78
|
+
def action
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Needed because running outside Gem
|
2
|
+
# XXX Is there a better way to deal with this?
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
require "yard_rest_plugin/base_helper"
|
6
|
+
|
7
|
+
YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
|
8
|
+
|
9
|
+
# Define custom tags
|
10
|
+
YARD::Tags::Library.define_tag("URL for Service", :url)
|
11
|
+
YARD::Tags::Library.define_tag("Arguments", :argument, :with_types_and_name)
|
12
|
+
YARD::Tags::Library.define_tag("Example Respones", :example_response)
|
13
|
+
YARD::Tags::Library.define_tag("Response Field", :response_field, :with_name)
|
14
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module YARD::Templates::Helpers
|
2
|
+
module BaseHelper
|
3
|
+
|
4
|
+
# Adds additional test that only includes Objects that contain a URL tag
|
5
|
+
def run_verifier(list)
|
6
|
+
if options[:verifier]
|
7
|
+
list = list.reject {|item| options[:verifier].call(item).is_a?(FalseClass) }
|
8
|
+
end
|
9
|
+
|
10
|
+
reject_without_url(list)
|
11
|
+
end
|
12
|
+
|
13
|
+
def reject_without_url(list)
|
14
|
+
list.reject {|object| object.tags("url").empty? }
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
include T('rest/module/html')
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= htmlify(object.docstring.strip) %>
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
/* Override this file with custom rules */
|
@@ -0,0 +1,78 @@
|
|
1
|
+
body {
|
2
|
+
font-family:"Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
|
3
|
+
font-size:13px;
|
4
|
+
height:101%;
|
5
|
+
overflow-x:hidden;
|
6
|
+
margin:0;
|
7
|
+
}
|
8
|
+
|
9
|
+
h1 {
|
10
|
+
font-size:1.4em;
|
11
|
+
margin:0;
|
12
|
+
padding:12px 10px 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.clear { clear:both; }
|
16
|
+
|
17
|
+
#search {
|
18
|
+
position:absolute;
|
19
|
+
right:5px;
|
20
|
+
top:9px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#full_list {
|
24
|
+
list-style:none;
|
25
|
+
margin-left:0;
|
26
|
+
padding:0;
|
27
|
+
}
|
28
|
+
|
29
|
+
#full_list ul { padding:0; }
|
30
|
+
|
31
|
+
#full_list li {
|
32
|
+
font-size:1.1em;
|
33
|
+
list-style:none;
|
34
|
+
margin:0;
|
35
|
+
padding:5px 5px 5px 12px;
|
36
|
+
}
|
37
|
+
|
38
|
+
#noresults {
|
39
|
+
display:none;
|
40
|
+
padding:7px 12px;
|
41
|
+
}
|
42
|
+
|
43
|
+
li {
|
44
|
+
color:#888;
|
45
|
+
cursor:pointer;
|
46
|
+
}
|
47
|
+
|
48
|
+
li.r1 { background: #fafafa; }
|
49
|
+
li.r2 { background: #f0f0f0; }
|
50
|
+
|
51
|
+
li:hover { background:#ddd; }
|
52
|
+
|
53
|
+
a:link,a:visited {
|
54
|
+
text-decoration:none;
|
55
|
+
color:#05a;
|
56
|
+
}
|
57
|
+
|
58
|
+
li.clicked {
|
59
|
+
background:#05a;
|
60
|
+
color:#ccc;
|
61
|
+
}
|
62
|
+
|
63
|
+
li.clicked a:link,li.clicked a:visited {
|
64
|
+
color:#eee;
|
65
|
+
}
|
66
|
+
|
67
|
+
#search input {
|
68
|
+
border:1px solid #bbb;
|
69
|
+
-moz-border-radius:3px;
|
70
|
+
-webkit-border-radius:3px;
|
71
|
+
}
|
72
|
+
|
73
|
+
#full_list.insearch li.found {
|
74
|
+
display:list-item;
|
75
|
+
padding-left:10px;
|
76
|
+
}
|
77
|
+
|
78
|
+
#full_list.insearch li { display:none; }
|
@@ -0,0 +1,225 @@
|
|
1
|
+
body {
|
2
|
+
padding: 0 20px;
|
3
|
+
font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
|
4
|
+
font-size: 13px;
|
5
|
+
}
|
6
|
+
|
7
|
+
h1 {
|
8
|
+
font-size: 25px;
|
9
|
+
margin: 1em 0 0.5em;
|
10
|
+
padding-top: 4px;
|
11
|
+
}
|
12
|
+
|
13
|
+
h1.noborder {
|
14
|
+
border-top: 0px;
|
15
|
+
margin-top: 0;
|
16
|
+
padding-top: 4px;
|
17
|
+
}
|
18
|
+
|
19
|
+
h1.title { margin-bottom: 10px; }
|
20
|
+
|
21
|
+
h1.alphaindex {
|
22
|
+
margin-top: 0;
|
23
|
+
font-size: 22px;
|
24
|
+
}
|
25
|
+
|
26
|
+
h1 .minor_heading { color: #777777; }
|
27
|
+
|
28
|
+
h2 {
|
29
|
+
padding: 0;
|
30
|
+
padding-bottom: 3px;
|
31
|
+
border-bottom: 1px #aaa solid;
|
32
|
+
font-size: 1.4em;
|
33
|
+
margin: 1.8em 0 0.5em;
|
34
|
+
}
|
35
|
+
|
36
|
+
.inline { display: inline; }
|
37
|
+
.inline p:first-child { display: inline; }
|
38
|
+
|
39
|
+
h3.inherited {
|
40
|
+
font-style: italic;
|
41
|
+
font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
|
42
|
+
font-weight: normal;
|
43
|
+
padding: 0;
|
44
|
+
margin: 0;
|
45
|
+
margin-top: 12px;
|
46
|
+
margin-bottom: 3px;
|
47
|
+
font-size: 13px;
|
48
|
+
}
|
49
|
+
p.inherited {
|
50
|
+
padding: 0;
|
51
|
+
margin: 0;
|
52
|
+
margin-left: 25px;
|
53
|
+
}
|
54
|
+
|
55
|
+
/* Content */
|
56
|
+
#content a:link, #content a:visited {
|
57
|
+
text-decoration: none;
|
58
|
+
color: #05a;
|
59
|
+
}
|
60
|
+
#content a:hover {
|
61
|
+
background: #ffffa5;
|
62
|
+
}
|
63
|
+
|
64
|
+
/* Index files listing */
|
65
|
+
#files {
|
66
|
+
padding-left: 15px;
|
67
|
+
font-size: 1.1em;
|
68
|
+
padding: 0;
|
69
|
+
}
|
70
|
+
#files li {
|
71
|
+
list-style: none;
|
72
|
+
display: inline;
|
73
|
+
padding: 7px 12px;
|
74
|
+
line-height: 35px;
|
75
|
+
}
|
76
|
+
|
77
|
+
.method_details {
|
78
|
+
border-top: 1px dotted #aaa;
|
79
|
+
margin-top: 15px;
|
80
|
+
padding-top: 0;
|
81
|
+
}
|
82
|
+
.method_details.first { border: 0; }
|
83
|
+
|
84
|
+
ul.signature {
|
85
|
+
font-size: 1.1em;
|
86
|
+
font-weight: normal;
|
87
|
+
font-family: Monaco, Consolas, Courier, monospace;
|
88
|
+
padding: 6px 10px;
|
89
|
+
margin-top: 18px;
|
90
|
+
background: #e5e8ff;
|
91
|
+
border: 1px solid #d8d8e5;
|
92
|
+
-moz-border-radius: 3px;
|
93
|
+
-webkit-border-radius: 3px;
|
94
|
+
list-style: none;
|
95
|
+
}
|
96
|
+
|
97
|
+
/* All tags */
|
98
|
+
.tags { margin-bottom: 12px; }
|
99
|
+
.tags h3 {
|
100
|
+
font-size: 1em;
|
101
|
+
margin-bottom: 0;
|
102
|
+
}
|
103
|
+
.tags ul {
|
104
|
+
margin-top: 5px;
|
105
|
+
padding-left: 30px;
|
106
|
+
list-style: square;
|
107
|
+
}
|
108
|
+
.tags ul li {
|
109
|
+
margin-bottom: 3px;
|
110
|
+
}
|
111
|
+
.tags ul .name {
|
112
|
+
font-family: monospace;
|
113
|
+
font-weight: bold;
|
114
|
+
}
|
115
|
+
.tags ul p.note { padding: 3px 6px; }
|
116
|
+
|
117
|
+
/* Repsonse example tag */
|
118
|
+
.tags .examples h3 { margin-bottom: 10px; }
|
119
|
+
.tags .examples h4 {
|
120
|
+
padding: 0;
|
121
|
+
margin: 0;
|
122
|
+
margin-left: 15px;
|
123
|
+
font-weight: bold;
|
124
|
+
font-size: 0.9em;
|
125
|
+
}
|
126
|
+
.tags .example {
|
127
|
+
padding: 5px 12px;
|
128
|
+
margin-top: 4px;
|
129
|
+
border: 1px solid #eef;
|
130
|
+
background: #f5f5ff;
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
/* Search menu */
|
135
|
+
#search {
|
136
|
+
position: absolute;
|
137
|
+
right: 14px;
|
138
|
+
top: 0px;
|
139
|
+
}
|
140
|
+
#search a:link, #search a:visited {
|
141
|
+
display: block; float: left; margin-right: 4px;
|
142
|
+
padding: 8px 10px; text-decoration: none; color: #05a; background: #eaeaff;
|
143
|
+
border: 1px solid #d8d8e5;
|
144
|
+
-moz-border-radius-bottomleft: 3px; -moz-border-radius-bottomright: 3px;
|
145
|
+
-webkit-border-bottom-left-radius: 3px; -webkit-border-bottom-right-radius: 3px;
|
146
|
+
}
|
147
|
+
#search a:hover {
|
148
|
+
background: #eef;
|
149
|
+
color: #06b;
|
150
|
+
}
|
151
|
+
#search a.active {
|
152
|
+
background: #568; padding-bottom: 20px; color: #fff; border: 1px solid #457;
|
153
|
+
-moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px;
|
154
|
+
-webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px;
|
155
|
+
}
|
156
|
+
#search a.inactive {
|
157
|
+
color: #999;
|
158
|
+
}
|
159
|
+
|
160
|
+
/* Search frame */
|
161
|
+
#search_frame {
|
162
|
+
background: #fff;
|
163
|
+
display: none;
|
164
|
+
position: absolute;
|
165
|
+
top: 36px;
|
166
|
+
right: 18px;
|
167
|
+
width: 500px;
|
168
|
+
height: 80%;
|
169
|
+
overflow-y: scroll;
|
170
|
+
border: 1px solid #999;
|
171
|
+
border-collapse: collapse;
|
172
|
+
-webkit-box-shadow: -2px 5px 25px #aaa;
|
173
|
+
-moz-box-shadow: -2px 5px 25px #aaa;
|
174
|
+
-moz-border-radius: 2px;
|
175
|
+
-webkit-border-radius: 2px;
|
176
|
+
}
|
177
|
+
|
178
|
+
/* Footer */
|
179
|
+
#footer {
|
180
|
+
margin-top: 15px;
|
181
|
+
border-top: 1px solid #ccc;
|
182
|
+
text-align: center;
|
183
|
+
padding: 7px 0;
|
184
|
+
color: #999;
|
185
|
+
}
|
186
|
+
|
187
|
+
/* Alphabetal Index Listing */
|
188
|
+
#listing ul.alpha { font-size: 1.1em; }
|
189
|
+
#listing ul.alpha { margin: 0; padding: 0; padding-bottom: 10px; list-style: none; }
|
190
|
+
#listing ul.alpha li.letter { font-size: 1.4em; padding-bottom: 10px; }
|
191
|
+
#listing ul.alpha ul { margin: 0; padding-left: 15px; }
|
192
|
+
|
193
|
+
li.r1 { background: #f0f0f0; }
|
194
|
+
li.r2 { background: #fafafa; }
|
195
|
+
|
196
|
+
/* Note tag */
|
197
|
+
.note {
|
198
|
+
color: #222;
|
199
|
+
-moz-border-radius: 3px;
|
200
|
+
-webkit-border-radius: 3px;
|
201
|
+
background: #e3e4e3;
|
202
|
+
border: 1px solid #d5d5d5;
|
203
|
+
padding: 7px 10px;
|
204
|
+
}
|
205
|
+
.note.todo {
|
206
|
+
background: #ffffc5;
|
207
|
+
border-color: #ececaa;
|
208
|
+
}
|
209
|
+
.note.title {
|
210
|
+
text-transform: lowercase;
|
211
|
+
padding: 1px 5px;
|
212
|
+
margin-left: 5px;
|
213
|
+
font-size: 0.9em;
|
214
|
+
font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
|
215
|
+
}
|
216
|
+
h1 .note.title {
|
217
|
+
font-size: 0.5em;
|
218
|
+
font-weight: normal;
|
219
|
+
padding: 3px 5px;
|
220
|
+
position: relative;
|
221
|
+
top: -3px;
|
222
|
+
text-transform: capitalize;
|
223
|
+
}
|
224
|
+
|
225
|
+
|