Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaned up, fixed up, hacked up for own purposes. Work in progress.

  • Loading branch information...
commit 91fef068422fff98abb6b617833f9e0044fa209e 1 parent 34dbc42
@kanevski authored
View
9 lib/yard-rest-plugin.rb
@@ -4,12 +4,14 @@
require "yard-rest-plugin/base_helper"
-YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
+YARD::Templates::Engine.register_template_path(File.dirname(__FILE__) + '/../templates')
+YARD::Server.register_static_path(File.dirname(__FILE__) + '/../templates/rest/fulldoc/html')
+
# TODO: Check ruby version and support ruby 1.9 in future
YARD::Parser::SourceParser.parser_type = :ruby18
# Define custom tags
-YARD::Tags::Library.define_tag("URL for Service", :url)
+YARD::Tags::Library.define_tag("URL for Service", :url, :with_types)
YARD::Tags::Library.define_tag("Topic for Service", :topic)
YARD::Tags::Library.define_tag("Arguments", :argument, :with_types_and_name)
YARD::Tags::Library.define_tag("Example Request", :example_request)
@@ -19,5 +21,4 @@
YARD::Tags::Library.define_tag("Headers", :header, :with_name)
YARD::Tags::Library.define_tag("Response codes", :response_code, :with_name)
YARD::Tags::Library.define_tag("Image", :image)
-YARD::Tags::Library.define_tag("Overall", :overall)
-
+YARD::Tags::Library.define_tag("Overall", :overall)
View
17 lib/yard-rest-plugin/base_helper.rb
@@ -1,18 +1,5 @@
-require 'pp'
-
module YARD::Templates::Helpers
module BaseHelper
-
- # Adds additional test that only includes Objects that contain a URL tag
- def run_verifier(list)
-
- if options[:verifier]
- list.reject! { |item| options[:verifier].call(item).is_a?(FalseClass) }
- end
-
- index_objects(list)
- end
-
def index_objects(list)
res = reject_module(list)
res = reject_without_url(res)
@@ -27,7 +14,9 @@ def reject_module(list)
end
def reject_without_url(list)
- list.reject { |object| [:class, :method].include?(object.type) and object.tags("url").empty? }
+ list.reject do |object|
+ [:class, :method].include?(object.type) and object.tags("url").empty?
+ end
end
def reject_without_topic(list)
View
16 templates/rest/class/html/header.erb
@@ -1,3 +1,5 @@
+<h1 class="noborder title"><a href="<%= url_for('') %>"><%= options[:title] %></a></h1>
+
<div class="service">
<h1>
<% if object.tags("url").size == 1 %>
@@ -24,16 +26,4 @@
<img src="<%= image.text %>">
<% end %>
<%= yieldall %>
-</div>
-
-
-
-
-
-
-
-
-
-
-
-
+</div>
View
4 templates/rest/class/html/setup.rb
@@ -3,7 +3,7 @@ def init
end
def method_details_list
- @meths = object.meths(:inherited => false, :included => false)
- @meths = run_verifier(@meths)
+ @meths = object.meths(:inherited => false, :included => false)
+ @meths = index_objects(@meths)
erb(:method_details_list)
end
View
24 templates/rest/disqus/html/disqus.erb
@@ -1,24 +0,0 @@
-<h2>Discuss this Resource</h2>
-<div id="disqus_thread"></div>
-<script type="text/javascript">
- var disqus_shortname = 'vworkapi';
- var disqus_identifier = "<%= @disqus_identifier %>";
- // var disqus_developer = 1;
- /**
- * var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
- */
- (function() {
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
- dsq.src = 'http://vworkapi.disqus.com/embed.js';
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
- })();
-</script>
-<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript=vworkapi">comments powered by Disqus.</a></noscript>
-<a href="http://disqus.com" class="dsq-brlink">API comments powered by <span class="logo-disqus">Disqus</span></a>
-<script type="text/javascript">
-(function () {
- var s = document.createElement('script'); s.async = true;
- s.src = 'http://disqus.com/forums/vworkapi/count.js';
- (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
-}());
-</script>
View
9 templates/rest/disqus/setup.rb
@@ -1,9 +0,0 @@
-def init
- sections :disqus
-end
-
-def disqus()
- @disqus_identifier = object.tag('url').text #.gsub(/\//, '_')
-
- erb('disqus')
-end
View
261 templates/rest/fulldoc/html/css/style.css
@@ -1,31 +1,31 @@
-body {
+body {
padding: 0 20px;
- font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
+ font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
font-size: 13px;
}
h1 {
- font-size: 25px;
- margin: 1em 0 0.5em;
- padding-top: 4px;
+ font-size: 25px;
+ margin: 1em 0 0.5em;
+ padding-top: 4px;
}
-h1.noborder {
- border-top: 0px;
- margin-top: 0;
- padding-top: 4px;
+h1.noborder {
+ border-top: 0px;
+ margin-top: 0;
+ padding-top: 4px;
}
h1.title { margin-bottom: 10px; }
-h1.alphaindex {
- margin-top: 0;
- font-size: 22px;
+h1.alphaindex {
+ margin-top: 0;
+ font-size: 22px;
}
h1 .minor_heading { color: #777777; }
-h2 {
+h2 {
padding: 0;
padding-bottom: 3px;
border-bottom: 1px #aaa solid;
@@ -52,117 +52,121 @@ p.inherited {
margin-left: 25px;
}
+.clear {
+ clear: both;
+}
+
/* Content */
-#content a:link, #content a:visited {
- text-decoration: none;
- color: #05a;
+#content a:link, #content a:visited {
+ text-decoration: none;
+ color: #05a;
}
-#content a:hover {
- background: #ffffa5;
+#content a:hover {
+ background: #ffffa5;
}
/* Index files listing */
-#files {
- padding-left: 15px;
- font-size: 1.1em;
- padding: 0;
+#files {
+ padding-left: 15px;
+ font-size: 1.1em;
+ padding: 0;
}
-#files li {
- list-style: none;
- display: inline;
- padding: 7px 12px;
- line-height: 35px;
+#files li {
+ list-style: none;
+ display: inline;
+ padding: 7px 12px;
+ line-height: 35px;
}
-.method_details {
- border-top: 1px dotted #aaa;
- margin-top: 15px;
- padding-top: 0;
+.method_details {
+ border-top: 1px dotted #aaa;
+ margin-top: 15px;
+ padding-top: 0;
}
.method_details.first { border: 0; }
-ul.signature {
- font-size: 1.1em;
- font-weight: normal;
- font-family: Monaco, Consolas, Courier, monospace;
- padding: 6px 10px;
- margin-top: 18px;
- background: #e5e8ff;
- border: 1px solid #d8d8e5;
- -moz-border-radius: 3px;
+ul.signature {
+ font-size: 1.1em;
+ font-weight: normal;
+ font-family: Monaco, Consolas, Courier, monospace;
+ padding: 6px 10px;
+ margin-top: 18px;
+ background: #e5e8ff;
+ border: 1px solid #d8d8e5;
+ -moz-border-radius: 3px;
-webkit-border-radius: 3px;
list-style: none;
}
/* All tags */
.tags { margin-bottom: 12px; }
-.tags h3 {
- font-size: 1em;
- margin-bottom: 0;
+.tags h3 {
+ font-size: 1em;
+ margin-bottom: 0;
}
-.tags ul {
- margin-top: 5px;
- padding-left: 30px;
- list-style: square;
+.tags ul {
+ margin-top: 5px;
+ padding-left: 30px;
+ list-style: square;
}
-.tags ul li {
- margin-bottom: 3px;
+.tags ul li {
+ margin-bottom: 3px;
}
-.tags ul .name {
- font-family: monospace;
- font-weight: bold;
+.tags ul .name {
+ font-family: monospace;
+ font-weight: bold;
}
.tags ul p.note { padding: 3px 6px; }
/* Repsonse example tag */
.tags .examples h3 { margin-bottom: 10px; }
-.tags .examples h4 {
- padding: 0;
- margin: 0;
- margin-left: 15px;
- font-weight: bold;
- font-size: 0.9em;
-}
-.tags .example {
- padding: 5px 12px;
- margin-top: 4px;
- border: 1px solid #eef;
+.tags .examples h4 {
+ padding: 0;
+ margin: 0;
+ margin-left: 15px;
+ font-weight: bold;
+ font-size: 0.9em;
+}
+.tags .example {
+ padding: 5px 12px;
+ margin-top: 4px;
+ border: 1px solid #eef;
background: #f5f5ff;
}
/* Search menu */
-#search {
- position: absolute;
- right: 14px;
- top: 0px;
+#search {
+ position: absolute;
+ right: 14px;
+ top: 0px;
}
-#search a:link, #search a:visited {
+#search a:link, #search a:visited {
display: block; float: left; margin-right: 4px;
padding: 8px 10px; text-decoration: none; color: #05a; background: #eaeaff;
border: 1px solid #d8d8e5;
- -moz-border-radius-bottomleft: 3px; -moz-border-radius-bottomright: 3px;
+ -moz-border-radius-bottomleft: 3px; -moz-border-radius-bottomright: 3px;
-webkit-border-bottom-left-radius: 3px; -webkit-border-bottom-right-radius: 3px;
}
-#search a:hover {
- background: #eef;
- color: #06b;
+#search a:hover {
+ background: #eef;
+ color: #06b;
}
-#search a.active {
- background: #568; padding-bottom: 20px; color: #fff; border: 1px solid #457;
+#search a.active {
+ background: #568; padding-bottom: 20px; color: #fff; border: 1px solid #457;
-moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px;
-webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px;
}
-#search a.inactive {
- color: #999;
+#search a.inactive {
+ color: #999;
}
/* Search frame */
#search_frame {
background: #fff;
display: none;
- position: absolute;
- top: 36px;
+ position: absolute;
+ top: 36px;
right: 18px;
width: 500px;
height: 80%;
@@ -176,12 +180,12 @@ ul.signature {
}
/* Footer */
-#footer {
- margin-top: 15px;
- border-top: 1px solid #ccc;
- text-align: center;
- padding: 7px 0;
- color: #999;
+#footer {
+ margin-top: 15px;
+ border-top: 1px solid #ccc;
+ text-align: center;
+ padding: 7px 0;
+ color: #999;
}
/* Alphabetal Index Listing */
@@ -194,32 +198,32 @@ li.r1 { background: #f0f0f0; }
li.r2 { background: #fafafa; }
/* Note tag */
-.note {
+.note {
color: #222;
- -moz-border-radius: 3px;
- -webkit-border-radius: 3px;
- background: #e3e4e3;
- border: 1px solid #d5d5d5;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ background: #e3e4e3;
+ border: 1px solid #d5d5d5;
padding: 7px 10px;
}
-.note.todo {
- background: #ffffc5;
- border-color: #ececaa;
+.note.todo {
+ background: #ffffc5;
+ border-color: #ececaa;
}
-.note.title {
- text-transform: lowercase;
- padding: 1px 5px;
- margin-left: 5px;
- font-size: 0.9em;
- font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
+.note.title {
+ text-transform: lowercase;
+ padding: 1px 5px;
+ margin-left: 5px;
+ font-size: 0.9em;
+ font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, sans-serif;
}
-h1 .note.title {
- font-size: 0.5em;
- font-weight: normal;
- padding: 3px 5px;
- position: relative;
- top: -3px;
- text-transform: capitalize;
+h1 .note.title {
+ font-size: 0.5em;
+ font-weight: normal;
+ padding: 3px 5px;
+ position: relative;
+ top: -3px;
+ text-transform: capitalize;
}
ul.box {
@@ -233,3 +237,50 @@ ul.box li {
text-align: left;
padding-right: 10px;
}
+
+
+/* URL Tag */
+.tag-urls {
+ list-style: none;
+ padding: 0;
+}
+
+.tag-urls li {
+ font-size: 18px;
+ text-decoration: none;
+ padding: 0;
+ margin: 0;
+ clear: both;
+}
+
+.tag-urls .method {
+ display: block;
+ background-color: #e0e0e0;
+ float: left;
+ padding: 5px 10px;
+}
+
+.tag-urls .path {
+ display: block;
+ float: left;
+ padding: 5px 10px;
+}
+
+/* Resource List */
+
+.all-resources {
+ list-style: none;
+ padding: 0;
+}
+
+.all-resources li {
+ font-size: 14px;
+}
+
+.all-resources .method {
+ display: inline-block;
+ padding: 5px 10px;
+ width: 50px;
+ text-align: right;
+ color: #666;
+}
View
2  templates/rest/fulldoc/html/full_list_files.erb
@@ -1,5 +1,5 @@
<% n = 1 %>
<% @items.each do |item| %>
- <li class="r<%= n %>"><%= link_file item, File.basename(item).gsub(/\.[^.]+$/, '') %></li>
+ <li class="r<%= n %>"><%= link_file item, item.name %></li>
<% n = n == 2 ? 1 : 2 %>
<% end %>
View
8 templates/rest/fulldoc/html/setup.rb
@@ -3,7 +3,8 @@
def init
options[:objects] = objects = run_verifier(options[:objects])
- options[:files] = ([options[:readme]] + options[:files]).compact.map { |t| t.to_s }
+
+ #options[:files] = ([options[:readme]] + options[:files]).compact.map { |t| t.to_s }
options[:readme] = options[:files].first
options[:title] ||= "Documentation by YARD #{YARD::VERSION}"
@@ -45,7 +46,7 @@ def serialize_file(file, title = nil)
options[:object] = Registry.root
options[:file] = file
options[:page_title] = title
- options[:serialized_path] = 'file.' + File.basename(file.gsub(/\.[^.]+$/, '')) + '.html'
+ options[:serialized_path] = 'file.' + file.name + '.html'
serialize_index(options) if file == options[:readme]
Templates::Engine.with_serializer(options[:serialized_path], options[:serializer]) do
@@ -86,7 +87,8 @@ def generate_topic_list
end
def generate_resource_list
- @items = index_objects(options[:objects])
+ all_items = Registry.all
+ @items = index_objects(all_items)
@list_title = "Resource List"
@list_type = "resource"
asset('resource_list.html', erb(:full_list))
View
84 templates/rest/layout/html/index.erb
@@ -1,60 +1,48 @@
<div id="listing">
<h1 class="noborder title"><%= options[:title] %></h1>
- <% @overall_objects.each do |obj| %>
- <%= yieldall :object => obj %>
- <% end %>
-
- <% if @files && @files.size > 0 %>
- <h2>Files A-Z</h2>
- <ul id="files">
- <% n = 1 %>
- <% @files.each_with_index do |file, i| %>
- <li class="r<%= n %>"><%= link_file(file, File.basename(file).gsub(/\.[^.]+$/, '')) %></li>
- <% n = n == 2 ? 1 : 2 %>
- <% end %>
- </ul>
- <% end %>
- <div class="clear"></div>
-
- <h2>Topics A-Z</h2>
- <% i = 0 %>
- <table>
- <tr>
- <td valign='top' width="33%">
- <% @topics.sort_by { |t, o| t.to_s }.each do |topic, objects| %>
- <% if (i += 1) % 8 == 0 %>
- </td>
- <td valign='top' width="33%">
- <% i = 0 %>
- <% end %>
- <ul id="alpha_<%= topic %>" class="alpha">
- <li class="letter"><%= topic %></li>
- <ul>
- <% objects.each do |obj| %>
- <% obj.tags("url").each do |url_tag| %>
- <li><%= linkify(obj, url_tag.text) %></li>
- <% end %>
- <% end %>
- </ul>
- </ul>
- <% end %>
- </td>
- </tr>
- </table>
-
-
- <h2>Resources A-Z</h2>
- <ul>
+ <h2>All Resources</h2>
+ <ul class="all-resources">
<% urls = [] %>
<% @resources.each do |object| %>
<% object.tags("url").each do |url_tag| %>
- <% urls << [url_tag.text, object] %>
+ <% urls << [url_tag.text, object, url_tag] %>
<% end %>
<% end %>
- <% urls.sort_by(& :first).each do |elem| %>
- <li><%= linkify(elem.last, elem.first) %></li>
+ <% urls.sort_by(&:first).each do |elem| %>
+ <li>
+ <span class="method <%= elem.last.type %>"><%= elem.last.type %></span>
+ <span class="url"><%= linkify(elem[1], elem.first) %></span>
+ </li>
<% end %>
</ul>
+ <% if !@topics.empty? %>
+ <h2>Topics A-Z</h2>
+ <% i = 0 %>
+ <table>
+ <tr>
+ <td valign='top' width="33%">
+ <% @topics.sort_by { |t, o| t.to_s }.each do |topic, objects| %>
+ <% if (i += 1) % 8 == 0 %>
+ </td>
+ <td valign='top' width="33%">
+ <% i = 0 %>
+ <% end %>
+ <ul id="alpha_<%= topic %>" class="alpha">
+ <li class="letter"><%= topic %></li>
+ <ul>
+ <% objects.each do |obj| %>
+ <% obj.tags("url").each do |url_tag| %>
+ <li><%= linkify(obj, url_tag.text) %></li>
+ <% end %>
+ <% end %>
+ </ul>
+ </ul>
+ <% end %>
+ </td>
+ </tr>
+ </table>
+ <% end %>
+
</div>
View
8 templates/rest/layout/html/layout.erb
@@ -8,15 +8,15 @@
<script type="text/javascript" charset="utf-8">
if (window.top.frames.main) document.body.className = 'frames';
</script>
-
+
<div id="header">
<%= erb(:search) %>
</div>
-
+
<iframe id="search_frame"></iframe>
-
+
<div id="content"><%= yieldall %></div>
-
+
<%= erb(:footer) %>
</body>
</html>
View
65 templates/rest/layout/html/setup.rb
@@ -1,69 +1,12 @@
-include Helpers::FilterHelper
-
-def init
- @breadcrumb = []
-
- @page_title = options[:title]
-
- if @file
- @contents = File.read_binary(@file)
- @file = File.basename(@file)
- sections :layout, [:diskfile]
- elsif object
- case object
- when '_index.html'
- sections :layout, [:index, [T('class')]]
- when CodeObjects::Base
- type = object.root? ? :module : object.type
- sections :layout, [T(type)]
- end
- else
- sections :layout, [:contents]
- end
-end
-
-def contents
- @contents
-end
+include T('/default/layout/html')
def index
-
- legitimate_objects = index_objects(@objects).reject {|o| o.root? }
+ objects = Registry.all
+ legitimate_objects = index_objects(objects).reject {|o| o.root? }
+ @resources = legitimate_objects
@topics = {}
-
legitimate_objects.each do |object|
object.tags('topic').each { |topic| (@topics[topic.text] ||= []) << object }
end
-
- @resources = legitimate_objects.sort_by {|o| o.tags('url').first.text }
-
- @overall_objects = @objects.find_all {|o| o.has_tag?('overall')}.sort_by {|o| o.tag('overall').text}
-
erb(:index)
-end
-
-def diskfile
- "<div id='filecontents'>" +
- case (File.extname(@file)[1..-1] || '').downcase
- when 'htm', 'html'
- @contents
- when 'txt'
- "<pre>#{@contents}</pre>"
- when 'textile', 'txtile'
- htmlify(@contents, :textile)
- when 'markdown', 'md', 'mdown', 'mkd'
- htmlify(@contents, :markdown)
- else
- htmlify(@contents, diskfile_shebang_or_default)
- end +
- "</div>"
-end
-
-def diskfile_shebang_or_default
- if @contents =~ /\A#!(\S+)\s*$/ # Shebang support
- @contents = $'
- $1.to_sym
- else
- options[:markup]
- end
end
View
29 templates/rest/method_details/html/method_signature.erb
@@ -1,28 +1,11 @@
-<ul class="signature <%= 'first' if @index == 0 %>" id="<%= anchor_for(object) %>">
- <li>
- <% if object.tags(:overload).size == 1 %>
- <%= signature(object.tag(:overload), false) %>
- <% elsif object.tags(:overload).size > 1 %>
- <% object.tags(:overload).each do |overload| %>
- <span class="overload"><%= signature(overload, false) %></span>
- <% end %>
- <% else %>
- <%= signature(object, false) %>
- <% end %>
-
- <% if object.aliases.size > 0 %>
- <span class="aliases">Also known as:
- <span class="names"><%= object.aliases.map {|o|
- "<span id='#{anchor_for(o)}'>" + h(o.name.to_s) + "</span>" }.join(", ") %></span>
- </span>
- <% end %>
- </li>
-</ul>
<% if object.tags(:url).size > 0 %>
-<h3>Url:</h3>
-<ul id="<%= anchor_for(object) %>">
+<ul class="tag-urls" id="<%= anchor_for(object) %>">
<% object.tags(:url).each do |url| %>
- <li><%= url.text %></li>
+ <li>
+ <span class="method <%= url.type.downcase %>"><%= url.type %></span>
+ <span class="path"><%= url.text %></span>
+ </li>
<% end %>
</ul>
+<div class="clear"><!-- --></div>
<% end %>
View
6 yard-rest-plugin.gemspec
@@ -66,12 +66,12 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<yard>, ["~> 0.6.1"])
+ s.add_runtime_dependency(%q<yard>, ["~> 0.7.4"])
else
- s.add_dependency(%q<yard>, ["~> 0.6.1"])
+ s.add_dependency(%q<yard>, ["~> 0.7.4"])
end
else
- s.add_dependency(%q<yard>, ["~> 0.6.1"])
+ s.add_dependency(%q<yard>, ["~> 0.7.4"])
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.