yard-web-plugin 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/lib/yard-web-plugin.rb +23 -0
  8. data/lib/yard-web-plugin/base_helper.rb +41 -0
  9. data/templates/rest/class/html/header.erb +39 -0
  10. data/templates/rest/class/html/method_details_list.erb +8 -0
  11. data/templates/rest/class/html/setup.rb +9 -0
  12. data/templates/rest/disqus/html/disqus.erb +24 -0
  13. data/templates/rest/disqus/setup.rb +9 -0
  14. data/templates/rest/docstring/html/setup.rb +4 -0
  15. data/templates/rest/docstring/html/text.erb +1 -0
  16. data/templates/rest/fulldoc/html/css/common.css +1 -0
  17. data/templates/rest/fulldoc/html/css/full_list.css +78 -0
  18. data/templates/rest/fulldoc/html/css/style.css +235 -0
  19. data/templates/rest/fulldoc/html/full_list.erb +29 -0
  20. data/templates/rest/fulldoc/html/full_list_files.erb +5 -0
  21. data/templates/rest/fulldoc/html/full_list_resource.erb +8 -0
  22. data/templates/rest/fulldoc/html/full_list_topic.erb +14 -0
  23. data/templates/rest/fulldoc/html/js/app.js +42 -0
  24. data/templates/rest/fulldoc/html/js/full_list.js +117 -0
  25. data/templates/rest/fulldoc/html/js/jquery.js +19 -0
  26. data/templates/rest/fulldoc/html/setup.rb +102 -0
  27. data/templates/rest/layout/html/footer.erb +3 -0
  28. data/templates/rest/layout/html/headers.erb +13 -0
  29. data/templates/rest/layout/html/index.erb +60 -0
  30. data/templates/rest/layout/html/layout.erb +22 -0
  31. data/templates/rest/layout/html/search.erb +5 -0
  32. data/templates/rest/layout/html/setup.rb +69 -0
  33. data/templates/rest/method_details/html/header.erb +3 -0
  34. data/templates/rest/method_details/html/method_signature.erb +28 -0
  35. data/templates/rest/method_details/html/setup.rb +7 -0
  36. data/templates/rest/module/setup.rb +4 -0
  37. data/templates/rest/tags/html/example_request.erb +9 -0
  38. data/templates/rest/tags/html/example_response.erb +9 -0
  39. data/templates/rest/tags/html/generic_tag.erb +17 -0
  40. data/templates/rest/tags/html/index.erb +3 -0
  41. data/templates/rest/tags/setup.rb +41 -0
  42. metadata +123 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Alexey Ilyichev
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = yard-web-plugin
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Alexey Ilyichev. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "yard-web-plugin"
8
+ gem.summary = %Q{This is a fork of yard-rest-plugin}
9
+ gem.description = %Q{See yard-rest-plugin for more detail}
10
+ gem.email = "alexey.ilyichev@qik.com"
11
+ gem.homepage = "http://github.com/alexz77/yard-web-plugin"
12
+ gem.authors = ["Alexey Ilyichev"]
13
+ gem.add_dependency "yard", "~>0.6.1"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "yard-web-plugin #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.2
@@ -0,0 +1,23 @@
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-web-plugin/base_helper"
6
+
7
+ YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
8
+ # TODO: Check ruby version and support ruby 1.9 in future
9
+ YARD::Parser::SourceParser.parser_type = :ruby18
10
+
11
+ # Define custom tags
12
+ YARD::Tags::Library.define_tag("URL for Service", :url)
13
+ YARD::Tags::Library.define_tag("Topic for Service", :topic)
14
+ YARD::Tags::Library.define_tag("Arguments", :argument, :with_types_and_name)
15
+ YARD::Tags::Library.define_tag("Example Request", :example_request)
16
+ YARD::Tags::Library.define_tag("Request Fields", :request_field, :with_types_and_name)
17
+ YARD::Tags::Library.define_tag("Example Response", :example_response)
18
+ YARD::Tags::Library.define_tag("Response Fields", :response_field, :with_types_and_name)
19
+ YARD::Tags::Library.define_tag("Headers", :header, :with_name)
20
+ YARD::Tags::Library.define_tag("Response codes", :response_code, :with_name)
21
+ YARD::Tags::Library.define_tag("Image", :image)
22
+ YARD::Tags::Library.define_tag("Overall", :overall)
23
+
@@ -0,0 +1,41 @@
1
+ require 'pp'
2
+
3
+ module YARD::Templates::Helpers
4
+ module BaseHelper
5
+
6
+ # Adds additional test that only includes Objects that contain a URL tag
7
+ def run_verifier(list)
8
+
9
+ if options[:verifier]
10
+ list.reject! { |item| options[:verifier].call(item).is_a?(FalseClass) }
11
+ end
12
+
13
+ reject_module(list)
14
+ end
15
+
16
+ def index_objects(list)
17
+ res = reject_module(list)
18
+ res = reject_without_url(res)
19
+ res = reject_without_topic(res)
20
+ res = reject_overall(res)
21
+
22
+ res
23
+ end
24
+
25
+ def reject_module(list)
26
+ list.reject { |object| [:root, :module].include?(object.type) }
27
+ end
28
+
29
+ def reject_without_url(list)
30
+ list.reject { |object| [:class, :method].include?(object.type) and object.tags("url").empty? }
31
+ end
32
+
33
+ def reject_without_topic(list)
34
+ list.reject { |object| [:class].include?(object.type) and object.tags("topic").empty? }
35
+ end
36
+
37
+ def reject_overall(list)
38
+ list.reject { |object| object.has_tag?('overall') }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,39 @@
1
+ <div class="service">
2
+ <h1>
3
+ <% if object.tags("url").size == 1 %>
4
+ <span class="minor_heading">Resource: </span>
5
+ <%= object.tag("url").text %>
6
+ <% elsif object.tags("url").size > 1 %>
7
+ <span class="minor_heading">Resource: </span>
8
+ <ul>
9
+ <% object.tags("url").each do |url_tag| %>
10
+ <li><%= url_tag.text %></li>
11
+ <% end %>
12
+ </ul>
13
+ <% end %>
14
+ </h1>
15
+ <% unless object.tags("topic").empty? %>
16
+ <h3 class="topic">Topics:</h3>
17
+ <ul class="box">
18
+ <% object.tags("topic").each do |topic| %>
19
+ <li><%= topic.text %></li>
20
+ <% end %>
21
+ </ul>
22
+ <% end %>
23
+ <% object.tags("image").each do |image| %>
24
+ <img src="<%= image.text %>">
25
+ <% end %>
26
+ <%= yieldall %>
27
+ </div>
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
@@ -0,0 +1,8 @@
1
+ <% unless @meths.empty? %>
2
+ <div id="Services" class="method_details_list">
3
+ <h2>Actions</h2>
4
+ <% @meths.each_with_index do |meth, i| %>
5
+ <%= yieldall :object => meth, :index => i %>
6
+ <% end %>
7
+ </div>
8
+ <% end %>
@@ -0,0 +1,9 @@
1
+ def init
2
+ sections :header, [T('docstring'), :method_details_list, [T('method_details')]]
3
+ end
4
+
5
+ def method_details_list
6
+ @meths = object.meths(:inherited => false, :included => false)
7
+ @meths = run_verifier(@meths)
8
+ erb(:method_details_list)
9
+ end
@@ -0,0 +1,24 @@
1
+ <h2>Discuss this Resource</h2>
2
+ <div id="disqus_thread"></div>
3
+ <script type="text/javascript">
4
+ var disqus_shortname = 'vworkapi';
5
+ var disqus_identifier = "<%= @disqus_identifier %>";
6
+ // var disqus_developer = 1;
7
+ /**
8
+ * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
9
+ */
10
+ (function() {
11
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
12
+ dsq.src = 'http://vworkapi.disqus.com/embed.js';
13
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
14
+ })();
15
+ </script>
16
+ <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=vworkapi">comments powered by Disqus.</a></noscript>
17
+ <a href="http://disqus.com" class="dsq-brlink">API comments powered by <span class="logo-disqus">Disqus</span></a>
18
+ <script type="text/javascript">
19
+ (function () {
20
+ var s = document.createElement('script'); s.async = true;
21
+ s.src = 'http://disqus.com/forums/vworkapi/count.js';
22
+ (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
23
+ }());
24
+ </script>
@@ -0,0 +1,9 @@
1
+ def init
2
+ sections :disqus
3
+ end
4
+
5
+ def disqus()
6
+ @disqus_identifier = object.tag('url').text #.gsub(/\//, '_')
7
+
8
+ erb('disqus')
9
+ end
@@ -0,0 +1,4 @@
1
+ def init
2
+ return if object.docstring.blank?
3
+ sections :text, T('tags')
4
+ end
@@ -0,0 +1 @@
1
+ <%= htmlify(object.docstring.strip) %>
@@ -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,235 @@
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
+ ul.box {
226
+ font-size: 1em;
227
+ height: 1em;
228
+ }
229
+
230
+ ul.box li {
231
+ float: left;
232
+ display: block;
233
+ text-align: left;
234
+ padding-right: 10px;
235
+ }