yard-rest-plugin 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +19 -13
- data/VERSION +1 -1
- data/example/SampleController.rb +1 -0
- data/pkg/yard-rest-plugin-0.1.5.gem +0 -0
- data/pkg/yard-rest-plugin-0.2.0.gem +0 -0
- data/templates/rest/class/html/header.erb +19 -3
- data/templates/rest/fulldoc/html/css/style.css +10 -0
- data/templates/rest/fulldoc/html/full_list_resource.erb +8 -0
- data/templates/rest/fulldoc/html/full_list_topic.erb +12 -0
- data/templates/rest/fulldoc/html/js/app.js +6 -3
- data/templates/rest/fulldoc/html/js/full_list.js +62 -0
- data/templates/rest/fulldoc/html/setup.rb +21 -8
- data/templates/rest/layout/html/index.erb +17 -5
- data/templates/rest/layout/html/search.erb +3 -2
- data/templates/rest/layout/html/setup.rb +13 -3
- data/yard-rest-plugin.gemspec +4 -2
- metadata +6 -4
- data/templates/rest/fulldoc/html/full_list_service.erb +0 -8
data/README.markdown
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
Yardoc RESTful Web Service Plugin
|
2
|
-
|
1
|
+
# Yardoc RESTful Web Service Plugin
|
2
|
+
|
3
3
|
by VisFleet
|
4
4
|
|
5
5
|
A plugin for [Yardoc](http://yardoc.org/) that generates documentation for RESTful web services.
|
6
6
|
|
7
|
-
Install
|
8
|
-
-------
|
7
|
+
## Install
|
9
8
|
sudo gem install yard-rest-plugin
|
10
9
|
|
11
10
|
It also requires the Jeweler gem if you plan to use the rake build tasks.
|
12
11
|
|
13
|
-
Generating Docs
|
14
|
-
|
12
|
+
## Generating Docs
|
13
|
+
|
15
14
|
When using yardoc you ask it to use the "rest" template (the -t option). For example:
|
16
15
|
|
17
16
|
yardoc '*.rb' -t rest --title "Our App's API"
|
18
17
|
|
19
|
-
Writing Comments
|
20
|
-
|
18
|
+
## Writing Comments
|
19
|
+
|
21
20
|
In addition to starting your comment with the normal RDoc description. The following tags are provided:
|
22
21
|
|
23
|
-
- @url url. Specifies the URL that the service is accessed from. This tag is compulsory, only classes and methods
|
24
|
-
|
22
|
+
- @url url. Specifies the URL that the service is accessed from. This tag is compulsory, only **classes** and **methods** that include this in their comments are included.
|
23
|
+
|
24
|
+
- @topic topic. Specifies the topic to categorise a **class** (not a method) under.
|
25
25
|
|
26
26
|
- @argument [type] name description. Specifies an argument that is passed to the service. You can specify as
|
27
27
|
many of these as required
|
@@ -30,7 +30,13 @@ In addition to starting your comment with the normal RDoc description. The follo
|
|
30
30
|
|
31
31
|
- @response_field name description. Further specifies the fields that are returned within the response
|
32
32
|
|
33
|
-
|
33
|
+
## Ignored Documentation
|
34
|
+
|
35
|
+
This plugin only documents **classes** and **methods** with **@url** tags. It does not support module documentation.
|
36
|
+
|
37
|
+
The rationale here is that you are documenting external services (as represented by controllers and methods), and not internal code.
|
38
|
+
|
39
|
+
## Example:
|
34
40
|
|
35
41
|
##
|
36
42
|
# Retuns all samples, as XML, for the current user that match the given parameters.
|
@@ -68,8 +74,8 @@ For example:
|
|
68
74
|
def index
|
69
75
|
end
|
70
76
|
|
71
|
-
Development
|
72
|
-
|
77
|
+
## Development
|
78
|
+
|
73
79
|
You can run the template locally over the included sample code by using the following rake tasks:
|
74
80
|
|
75
81
|
rake ex:clean
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/example/SampleController.rb
CHANGED
Binary file
|
Binary file
|
@@ -1,8 +1,24 @@
|
|
1
1
|
<div class="service">
|
2
2
|
<h1><span class="minor_heading">Resource: </span><%= object.tag("url").text %></h1>
|
3
|
-
<% unless object.
|
4
|
-
|
5
|
-
<
|
3
|
+
<% unless object.tags("topic").empty? %>
|
4
|
+
<h3>Topics:</h3>
|
5
|
+
<ul class="box">
|
6
|
+
<% object.tags("topic").each do |topic| %>
|
7
|
+
<li><%= topic.text %></li>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
6
10
|
<% end %>
|
7
11
|
<%= yieldall %>
|
8
12
|
</div>
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<li><a href="<%= url_for('_index.html') %>">Index</a></li>
|
2
|
+
<% n = 1 %>
|
3
|
+
<% @items.sort_by {|s| s.name.to_s }.each do |resource| %>
|
4
|
+
<% unless resource.tags("url").first.nil? %>
|
5
|
+
<li class="r<%= n %>"><%= linkify(resource, resource.tags("url").first.text) %></li>
|
6
|
+
<% end %>
|
7
|
+
<% n = n == 2 ? 1 : 2 %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
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
|
+
<li class="r<%= n %>"><%= linkify(object, object.tag("url").text) %></li>
|
8
|
+
<% end%>
|
9
|
+
<% end %>
|
10
|
+
<% n = n == 2 ? 1 : 2 %>
|
11
|
+
<% end %>
|
12
|
+
|
@@ -4,10 +4,13 @@ function fixBoxInfoHeights() {
|
|
4
4
|
$(this).prev().height($(this).height());
|
5
5
|
});
|
6
6
|
}
|
7
|
-
|
8
7
|
function searchFrameLinks() {
|
9
|
-
$('#
|
10
|
-
toggleSearchFrame(this, relpath + '
|
8
|
+
$('#topic_list_link').click(function() {
|
9
|
+
toggleSearchFrame(this, relpath + 'topic_list.html');
|
10
|
+
});
|
11
|
+
|
12
|
+
$('#resource_list_link').click(function() {
|
13
|
+
toggleSearchFrame(this, relpath + 'resource_list.html');
|
11
14
|
});
|
12
15
|
|
13
16
|
$('#file_list_link').click(function() {
|
@@ -7,6 +7,11 @@ function fullListSearch() {
|
|
7
7
|
var link = $(this).children('a:last');
|
8
8
|
link.text(link.text());
|
9
9
|
});
|
10
|
+
if (clicked) {
|
11
|
+
clicked.parents('ul').each(function() {
|
12
|
+
$(this).removeClass('collapsed').prev().removeClass('collapsed');
|
13
|
+
});
|
14
|
+
}
|
10
15
|
highlight();
|
11
16
|
}
|
12
17
|
else {
|
@@ -40,6 +45,50 @@ function fullListSearch() {
|
|
40
45
|
$('#full_list').after("<div id='noresults'>No results were found.</div>")
|
41
46
|
}
|
42
47
|
|
48
|
+
clicked = null;
|
49
|
+
function linkList() {
|
50
|
+
$('#full_list li, #full_list li a:last').click(function(evt) {
|
51
|
+
if ($(this).hasClass('toggle')) return true;
|
52
|
+
if (this.tagName.toLowerCase() == "li") {
|
53
|
+
var toggle = $(this).children('a.toggle');
|
54
|
+
if (toggle.size() > 0 && evt.pageX < toggle.offset().left) {
|
55
|
+
toggle.click();
|
56
|
+
return false;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
if (clicked) clicked.removeClass('clicked');
|
60
|
+
var win = window.parent;
|
61
|
+
if (window.top.frames.main) {
|
62
|
+
win = window.top.frames.main;
|
63
|
+
var title = $('html head title', win.document).text();
|
64
|
+
$('html head title', window.parent.document).text(title);
|
65
|
+
}
|
66
|
+
if (this.tagName.toLowerCase() == "a") {
|
67
|
+
clicked = $(this).parent('li').addClass('clicked');
|
68
|
+
win.location = this.href;
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
clicked = $(this).addClass('clicked');
|
72
|
+
win.location = $(this).find('a:last').attr('href');
|
73
|
+
}
|
74
|
+
return false;
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
function collapse() {
|
79
|
+
if (!$('#full_list').hasClass('class')) return;
|
80
|
+
$('#full_list.class a.toggle').click(function() {
|
81
|
+
$(this).parent().toggleClass('collapsed').next().toggleClass('collapsed');
|
82
|
+
highlight();
|
83
|
+
return false;
|
84
|
+
});
|
85
|
+
$('#full_list.class ul').each(function() {
|
86
|
+
$(this).addClass('collapsed').prev().addClass('collapsed');
|
87
|
+
});
|
88
|
+
$('#full_list.class').children().removeClass('collapsed');
|
89
|
+
highlight();
|
90
|
+
}
|
91
|
+
|
43
92
|
function highlight(no_padding) {
|
44
93
|
var n = 1;
|
45
94
|
$('#full_list li:visible').each(function() {
|
@@ -52,4 +101,17 @@ function highlight(no_padding) {
|
|
52
101
|
});
|
53
102
|
}
|
54
103
|
|
104
|
+
function escapeShortcut() {
|
105
|
+
$(document).keydown(function(evt) {
|
106
|
+
if (evt.which == 27) {
|
107
|
+
$('#search_frame', window.top.document).slideUp(100);
|
108
|
+
$('#search a', window.top.document).removeClass('active inactive')
|
109
|
+
$(window.top).focus();
|
110
|
+
}
|
111
|
+
});
|
112
|
+
}
|
113
|
+
|
114
|
+
$(escapeShortcut);
|
55
115
|
$(fullListSearch);
|
116
|
+
$(linkList);
|
117
|
+
$(collapse);
|
@@ -1,10 +1,8 @@
|
|
1
1
|
include Helpers::ModuleHelper
|
2
|
-
|
2
|
+
include Helpers::FilterHelper
|
3
3
|
|
4
4
|
def init
|
5
|
-
pp "--1--", options[:objects]
|
6
5
|
options[:objects] = objects = run_verifier(options[:objects])
|
7
|
-
pp "--2--", options[:objects]
|
8
6
|
options[:files] = ([options[:readme]] + options[:files]).compact.map {|t| t.to_s }
|
9
7
|
options[:readme] = options[:files].first
|
10
8
|
options[:title] ||= "Documentation by YARD #{YARD::VERSION}"
|
@@ -69,15 +67,30 @@ def generate_assets
|
|
69
67
|
end
|
70
68
|
|
71
69
|
@object = Registry.root
|
72
|
-
|
70
|
+
generate_resource_list
|
71
|
+
generate_topic_list
|
73
72
|
generate_file_list
|
74
73
|
end
|
75
74
|
|
76
|
-
def
|
75
|
+
def generate_topic_list
|
76
|
+
topic_objects = options[:objects].reject {|o| o.root? || !is_class?(o) || o.tags('url').empty? || o.tags('topic').empty? }
|
77
|
+
@topics = {}
|
78
|
+
|
79
|
+
topic_objects.each do |object|
|
80
|
+
object.tags('topic').each { |topic| (@topics[topic.text] ||= []) << object }
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
@list_title = "Topic List"
|
85
|
+
@list_type = "topic"
|
86
|
+
asset('topic_list.html', erb(:full_list))
|
87
|
+
end
|
88
|
+
|
89
|
+
def generate_resource_list
|
77
90
|
@items = options[:objects]
|
78
|
-
@list_title = "
|
79
|
-
@list_type = "
|
80
|
-
asset('
|
91
|
+
@list_title = "Resource List"
|
92
|
+
@list_type = "resource"
|
93
|
+
asset('resource_list.html', erb(:full_list))
|
81
94
|
end
|
82
95
|
|
83
96
|
def generate_file_list
|
@@ -18,18 +18,18 @@
|
|
18
18
|
<table>
|
19
19
|
<tr>
|
20
20
|
<td valign='top' width="33%">
|
21
|
-
<% @
|
21
|
+
<% @topics.sort_by {|t,o| t.to_s }.each do |topic, objects| %>
|
22
22
|
<% if (i += 1) % 8 == 0 %>
|
23
23
|
</td><td valign='top' width="33%">
|
24
24
|
<% i = 0 %>
|
25
25
|
<% end %>
|
26
|
-
<ul id="alpha_<%=
|
27
|
-
<li class="letter"><%=
|
26
|
+
<ul id="alpha_<%= topic %>" class="alpha">
|
27
|
+
<li class="letter"><%= topic %></li>
|
28
28
|
<ul>
|
29
29
|
<% objects.each do |obj| %>
|
30
|
-
<% unless obj.tags("
|
30
|
+
<% unless obj.tags("url").first.nil? %>
|
31
31
|
<li>
|
32
|
-
<%= linkify(obj, obj.tags("
|
32
|
+
<%= linkify(obj, obj.tags("url").first.text) %>
|
33
33
|
</li>
|
34
34
|
<% end %>
|
35
35
|
<% end %>
|
@@ -40,4 +40,16 @@
|
|
40
40
|
</tr>
|
41
41
|
</table>
|
42
42
|
|
43
|
+
|
44
|
+
<h2>Resources A-Z</h2>
|
45
|
+
<ul>
|
46
|
+
<% @objects.each do |object| %>
|
47
|
+
<% unless object.tags("url").first.nil? %>
|
48
|
+
<li>
|
49
|
+
<%= linkify(object, object.tags("url").first.text) %>
|
50
|
+
</li>
|
51
|
+
<% end %>
|
52
|
+
<% end %>
|
53
|
+
</ul>
|
54
|
+
|
43
55
|
</div>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<div id="search">
|
2
|
-
<a id="
|
3
|
-
<a id
|
2
|
+
<a id="topic_list_link" href="#">Topic List</a>
|
3
|
+
<a id="resource_list_link" href="#">Resource List</a>
|
4
|
+
<a id="file_list_link" href="#">File List</a>
|
4
5
|
</div>
|
@@ -1,3 +1,5 @@
|
|
1
|
+
include Helpers::FilterHelper
|
2
|
+
|
1
3
|
def init
|
2
4
|
@breadcrumb = []
|
3
5
|
|
@@ -25,9 +27,17 @@ def contents
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def index
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
|
31
|
+
legitimate_objects = @objects.reject {|o| o.root? || !is_class?(o) || o.tags('url').empty?}
|
32
|
+
topic_objects = legitimate_objects.reject{|o| o.tags('topic').empty? }
|
33
|
+
@topics = {}
|
34
|
+
|
35
|
+
topic_objects.each do |object|
|
36
|
+
object.tags('topic').each { |topic| (@topics[topic.text] ||= []) << object }
|
37
|
+
end
|
38
|
+
|
39
|
+
@resources = legitimate_objects.sort_by {|o| o.tags('url').first.text }
|
40
|
+
|
31
41
|
erb(:index)
|
32
42
|
end
|
33
43
|
|
data/yard-rest-plugin.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{yard-rest-plugin}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aisha Fenton"]
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"lib/yard-rest-plugin.rb",
|
25
25
|
"lib/yard-rest-plugin/base_helper.rb",
|
26
26
|
"pkg/yard-rest-plugin-0.1.5.gem",
|
27
|
+
"pkg/yard-rest-plugin-0.2.0.gem",
|
27
28
|
"templates/rest/.DS_Store",
|
28
29
|
"templates/rest/class/html/header.erb",
|
29
30
|
"templates/rest/class/html/method_details_list.erb",
|
@@ -37,7 +38,8 @@ Gem::Specification.new do |s|
|
|
37
38
|
"templates/rest/fulldoc/html/css/style.css",
|
38
39
|
"templates/rest/fulldoc/html/full_list.erb",
|
39
40
|
"templates/rest/fulldoc/html/full_list_files.erb",
|
40
|
-
"templates/rest/fulldoc/html/
|
41
|
+
"templates/rest/fulldoc/html/full_list_resource.erb",
|
42
|
+
"templates/rest/fulldoc/html/full_list_topic.erb",
|
41
43
|
"templates/rest/fulldoc/html/js/app.js",
|
42
44
|
"templates/rest/fulldoc/html/js/full_list.js",
|
43
45
|
"templates/rest/fulldoc/html/js/jquery.js",
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Aisha Fenton
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/yard-rest-plugin.rb
|
48
48
|
- lib/yard-rest-plugin/base_helper.rb
|
49
49
|
- pkg/yard-rest-plugin-0.1.5.gem
|
50
|
+
- pkg/yard-rest-plugin-0.2.0.gem
|
50
51
|
- templates/rest/.DS_Store
|
51
52
|
- templates/rest/class/html/header.erb
|
52
53
|
- templates/rest/class/html/method_details_list.erb
|
@@ -60,7 +61,8 @@ files:
|
|
60
61
|
- templates/rest/fulldoc/html/css/style.css
|
61
62
|
- templates/rest/fulldoc/html/full_list.erb
|
62
63
|
- templates/rest/fulldoc/html/full_list_files.erb
|
63
|
-
- templates/rest/fulldoc/html/
|
64
|
+
- templates/rest/fulldoc/html/full_list_resource.erb
|
65
|
+
- templates/rest/fulldoc/html/full_list_topic.erb
|
64
66
|
- templates/rest/fulldoc/html/js/app.js
|
65
67
|
- templates/rest/fulldoc/html/js/full_list.js
|
66
68
|
- templates/rest/fulldoc/html/js/jquery.js
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<li><a href="<%= url_for('_index.html') %>">/</a></li>
|
2
|
-
<% n = 1 %>
|
3
|
-
<% @items.sort_by {|s| s.name.to_s }.each do |service| %>
|
4
|
-
<% unless service.tags("topic").first.nil? %>
|
5
|
-
<li class="r<%= n %>"><%= linkify(service, service.tags("topic").first.text) %></li>
|
6
|
-
<% end %>
|
7
|
-
<% n = n == 2 ? 1 : 2 %>
|
8
|
-
<% end %>
|