Generate docs using YARD

This commit is contained in:
Elliot Winkler 2014-06-19 22:44:06 -06:00
parent c22d7c89e0
commit 4d8faed1c4
41 changed files with 7300 additions and 1 deletions

8
.yardopts Normal file
View File

@ -0,0 +1,8 @@
--no-private
--protected
--readme README.md
--files lib/**/*.rb
--markup markdown
--hide-tag return
--hide-tag param
-e ./doc_config/yard/setup.rb

View File

@ -12,6 +12,12 @@ gem 'rails', '~> 3.0'
gem 'rake', '>= 0.9.2'
gem 'rspec-rails', '>= 2.13.1', '< 3'
# YARD
gem 'yard'
gem 'redcarpet'
gem 'pygments.rb'
gem 'watchr'
# For test Rails application
gem 'shoulda-context', '~> 1.2.0'
gem 'sqlite3', :platform => :ruby

View File

@ -75,10 +75,14 @@ GEM
multi_json (1.8.4)
multi_test (0.0.3)
polyglot (0.3.3)
posix-spawn (0.3.8)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.3.7)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
@ -104,6 +108,7 @@ GEM
rake (10.1.1)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.0.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
@ -130,6 +135,9 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -145,10 +153,14 @@ DEPENDENCIES
jdbc-sqlite3
jruby-openssl
pry
pygments.rb
rails (~> 3.0)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
shoulda-context (~> 1.2.0)
shoulda-matchers!
sqlite3
therubyrhino
watchr
yard

View File

@ -131,6 +131,21 @@ gem 'shoulda-matchers'
gem 'activemodel'
```
## Generating documentation
YARD is used to generate documentation, which can be viewed online at
<http://thoughtbot.github.com/shoulda-matchers>. You can preview changes you
make to the documentation locally by running
yard doc
from this directory. Then, open `doc/index.html` in your browser.
If you want to see a live preview as you work without having to run `yard` over
and over again, keep this command running in a separate terminal session:
watchr yard.watchr
## Versioning
shoulda-matchers follows Semantic Versioning 2.0 as defined at

22
doc_config/yard/setup.rb Normal file
View File

@ -0,0 +1,22 @@
YARD::Templates::Engine.register_template_path(File.dirname(__FILE__) + '/templates')
require 'pygments.rb'
module YARD
module Templates
module Helpers
module HtmlSyntaxHighlightHelper
def html_syntax_highlight_ruby(source)
highlight_with_pygments(:ruby, source)
end
private
def highlight_with_pygments(language, source)
html = Pygments.highlight(source, lexer: language.to_s)
html.sub(%r{\A<div class="highlight">\s*<pre>}, '').sub(%r{</pre>\s*</div>\Z}, '')
end
end
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
body {
font-size: 14px;
padding: 20px;
}
h1 {
font-size: 1.5em;
}
.search_info, .toggle {
display: none;
}

View File

@ -0,0 +1,45 @@
@import "http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300italic,400,600,600italic,800|Droid+Sans+Mono";
body {
font-size: 16px;
line-height: 1.5;
}
a, a:hover {
color: #136cc6;
}
h1, h2, h3, h4, h5, h6, p, pre {
margin-bottom: 1em;
margin-top: 0;
}
h1, h2, h3, h4, h5, h6, body {
font-family: "Source Sans Pro", sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 800;
}
pre, tt, code {
background: #FFFBF4;
border-radius: 3px;
border: 1px solid rgba(0,0,0,0.1);
font-family: "Droid Sans Mono", monospace;
font-size: 13px;
}
pre code {
border: none;
}
tt, code {
color: black;
padding: 0 4px;
}
ul, ol {
margin-left: 1em;
padding-left: 1em;
}

View File

@ -0,0 +1,69 @@
pre, code { background-color: #fdf6e3; color: #586e75 }
pre .c { color: #93a1a1 } /* Comment */
pre .err { color: #586e75 } /* Error */
pre .g { color: #586e75 } /* Generic */
pre .k { color: #859900 } /* Keyword */
pre .l { color: #586e75 } /* Literal */
pre .n { color: #586e75 } /* Name */
pre .o { color: #859900 } /* Operator */
pre .x { color: #cb4b16 } /* Other */
pre .p { color: #586e75 } /* Punctuation */
pre .cm { color: #93a1a1 } /* Comment.Multiline */
pre .cp { color: #859900 } /* Comment.Preproc */
pre .c1 { color: #93a1a1 } /* Comment.Single */
pre .cs { color: #859900 } /* Comment.Special */
pre .gd { color: #2aa198 } /* Generic.Deleted */
pre .ge { color: #586e75; font-style: italic } /* Generic.Emph */
pre .gr { color: #dc322f } /* Generic.Error */
pre .gh { color: #cb4b16 } /* Generic.Heading */
pre .gi { color: #859900 } /* Generic.Inserted */
pre .go { color: #586e75 } /* Generic.Output */
pre .gp { color: #586e75 } /* Generic.Prompt */
pre .gs { color: #586e75; font-weight: bold } /* Generic.Strong */
pre .gu { color: #cb4b16 } /* Generic.Subheading */
pre .gt { color: #586e75 } /* Generic.Traceback */
pre .kc { color: #cb4b16 } /* Keyword.Constant */
pre .kd { color: #268bd2 } /* Keyword.Declaration */
pre .kn { color: #859900 } /* Keyword.Namespace */
pre .kp { color: #859900 } /* Keyword.Pseudo */
pre .kr { color: #268bd2 } /* Keyword.Reserved */
pre .kt { color: #dc322f } /* Keyword.Type */
pre .ld { color: #586e75 } /* Literal.Date */
pre .m { color: #2aa198 } /* Literal.Number */
pre .s { color: #2aa198 } /* Literal.String */
pre .na { color: #586e75 } /* Name.Attribute */
pre .nb { color: #B58900 } /* Name.Builtin */
pre .nc { color: #268bd2 } /* Name.Class */
pre .no { color: #cb4b16 } /* Name.Constant */
pre .nd { color: #268bd2 } /* Name.Decorator */
pre .ni { color: #cb4b16 } /* Name.Entity */
pre .ne { color: #cb4b16 } /* Name.Exception */
pre .nf { color: #268bd2 } /* Name.Function */
pre .nl { color: #586e75 } /* Name.Label */
pre .nn { color: #586e75 } /* Name.Namespace */
pre .nx { color: #586e75 } /* Name.Other */
pre .py { color: #586e75 } /* Name.Property */
pre .nt { color: #268bd2 } /* Name.Tag */
pre .nv { color: #268bd2 } /* Name.Variable */
pre .ow { color: #859900 } /* Operator.Word */
pre .w { color: #586e75 } /* Text.Whitespace */
pre .mf { color: #2aa198 } /* Literal.Number.Float */
pre .mh { color: #2aa198 } /* Literal.Number.Hex */
pre .mi { color: #2aa198 } /* Literal.Number.Integer */
pre .mo { color: #2aa198 } /* Literal.Number.Oct */
pre .sb { color: #93a1a1 } /* Literal.String.Backtick */
pre .sc { color: #2aa198 } /* Literal.String.Char */
pre .sd { color: #586e75 } /* Literal.String.Doc */
pre .s2 { color: #2aa198 } /* Literal.String.Double */
pre .se { color: #cb4b16 } /* Literal.String.Escape */
pre .sh { color: #586e75 } /* Literal.String.Heredoc */
pre .si { color: #2aa198 } /* Literal.String.Interpol */
pre .sx { color: #2aa198 } /* Literal.String.Other */
pre .sr { color: #dc322f } /* Literal.String.Regex */
pre .s1 { color: #2aa198 } /* Literal.String.Single */
pre .ss { color: #2aa198 } /* Literal.String.Symbol */
pre .bp { color: #268bd2 } /* Name.Builtin.Pseudo */
pre .vc { color: #268bd2 } /* Name.Variable.Class */
pre .vg { color: #268bd2 } /* Name.Variable.Global */
pre .vi { color: #268bd2 } /* Name.Variable.Instance */
pre .il { color: #2aa198 } /* Literal.Number.Integer.Long */

View File

@ -0,0 +1,283 @@
/******** LAYOUT *********/
h1 {
font-size: 2.2em;
margin-top: 1em;
}
h2 {
font-size: 2em;
}
h2, h3 {
margin-top: 1em;
padding-top: 0.5em;
}
h4, h5 {
margin-top: 1em;
}
h1 + h2,
h2 + h3,
h2 + .method_details h3,
h4 + h5 {
margin-top: 0;
}
#main h3 tt,
#sticky-header tt {
background: transparent;
border: none;
font-family: "Source Sans Pro", sans-serif;
font-size: 1em;
font-style: italic;
font-weight: normal;
padding: 0;
}
#main h2,
#main h3,
#sticky-header h2,
#sticky-header h3 {
border: none;
padding-bottom: 0;
}
#main h2,
#sticky-header h2 {
font-size: 1.8em;
}
#main h3,
#sticky-header h3 {
font-size: 1.5em;
font-style: italic;
}
#main h4,
#sticky-header h4 {
border-bottom: 1px solid rgba(0,0,0,0.3);
font-size: 1.4em;
font-style: italic;
padding-bottom: 2px;
}
#main h5,
#sticky-header h5 {
font-size: 1.1em;
}
#sticky-header h2,
#sticky-header h3,
#sticky-header h4 {
line-height: inherit;
margin: 0;
padding: 0;
}
/* Header */
#header, #main {
position: absolute;
}
#header {
left: 0;
right: 0;
top: 0;
}
#menu, #search {
height: 6rem;
line-height: 6rem;
text-transform: uppercase;
}
#main {
top: 6rem;
}
#menu {
float: left;
letter-spacing: 1px;
padding-left: 2em;
position: relative;
width: 30em;
}
#menu .noframes {
display: inline;
}
#search {
float: right;
font-size: 0.9em;
}
#search ul {
list-style: none;
}
#search ul, #search li {
margin: 0;
padding: 0;
display: inline;
}
#search a {
border-left: 1px solid rgba(0,0,0,0.3);
float: left;
padding: 0 2em;
text-align: center;
text-decoration: none;
-webkit-transition: 0.1s background-color, 0.1s color;
-moz-transition: 0.1s background-color, 0.1s color;
transition: 0.1s background-color, 0.1s color;
}
#search a:hover {
background-color: #f0f8ff;
}
#search .active a {
background-color: #136cc6;
border-left-color: #136cc6;
color: white;
}
#search .active + li a {
border-left-color: #136cc6;
}
#search_frame {
background: white;
border: 1px solid rgba(0,0,0,0.2);
box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.3);
height: 0;
opacity: 0;
position: absolute;
right: 0;
top: 100%;
-webkit-transition: 0.1s height ease-in-out, 0.1s opacity 0.05s;
-moz-transition: 0.1s height ease-in-out, 0.1s opacity 0.05s;
transition: 0.1s height ease-in-out, 0.1s opacity 0.05s;
width: 500px;
z-index: 9999;
}
#search_frame.open {
height: 500px;
opacity: 1;
-webkit-transition: 0.1s height ease-in-out, 0.1s opacity;
-moz-transition: 0.1s height ease-in-out, 0.1s opacity;
transition: 0.1s height ease-in-out, 0.1s opacity;
}
/* Main */
#main {
border-top: 1px solid rgba(0,0,0,0.2);
bottom: 0;
left: 0;
overflow-y: auto;
right: 0;
}
#content {
padding-bottom: 1.5em;
padding-left: 2em;
padding-right: 2em;
}
#toc {
display: none;
}
/* Footer */
#footer {
background-color: rgba(0,0,0,0.3);
color: white;
font-weight: 100;
padding: 10px;
text-align: center;
text-shadow: 0 1px 1px rgba(0,0,0,0.4);
}
#footer a {
color: #ffedd5;
}
/* Class/Module */
.method_details {}
.method_details td {
padding: 10px;
}
.method_details .showSource {
display: block;
margin-bottom: 1em;
}
.method_details .source_code {
border: 1px solid rgba(0,0,0,0.1);
display: none;
overflow: auto;
width: 100%;
}
.method_details .source_code pre {
background-color: transparent;
border-radius: 0;
border: none;
color: inherit;
margin-bottom: 0;
padding: 0;
}
.method_details .source_code td {
border: 1px solid rgba(0,0,0,0.1);
}
.method_details .source_code td.lines {
background-color: #f0f0f0;
color: #93a1a1;
width: 50px;
}
.method_details .source_code td.code {
background-color: #f8f8f8;
}
.method_details .source_code td.code pre .info {
color: #93a1a1 /* Comment */
}
.docstring, .method_details .showSource, .method_details .source_code {
margin-left: 1em;
}
#sticky-header {
background-color: rgba(255,255,255,0.8);
border-bottom: 1px solid rgba(0,0,0,0.2);
height: 3em;
line-height: 3em;
opacity: 0;
padding-left: 2em; /* same as content padding */
padding-right: 2em; /* same as content padding */
position: fixed;
text-align: right;
top: 6.1rem;
-webkit-transition: 0.1s opacity ease-in-out;
-moz-transition: 0.1s opacity ease-in-out;
transition: 0.1s opacity ease-in-out;
width: 100%;
z-index: 999;
}
#sticky-header.show {
opacity: 1;
}
.clear {
clear: both;
}

View File

@ -0,0 +1,32 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
<% stylesheets_full_list.each do |stylesheet| %>
<link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" media="screen" charset="utf-8" />
<% end %>
<% javascripts_full_list.each do |javascript| %>
<script type="text/javascript" charset="utf-8" src="<%= url_for(javascript) %>"></script>
<% end %>
<title><%= @list_title %></title>
<base id="base_target" target="_parent" />
</head>
<body>
<script type="text/javascript" charset="utf-8">
if (window.top.frames.main) {
document.getElementById('base_target').target = 'main';
document.body.className = 'frames';
}
</script>
<div id="content">
<h1 id="full_list_header"><%= @list_title %></h1>
<ul id="full_list" class="<%= @list_class || @list_type %>">
<%= erb "full_list_#{@list_type}" %>
</ul>
</div>
</body>
</html>

View File

@ -0,0 +1 @@
<%= class_list %>

View File

@ -0,0 +1,8 @@
<% n = 1 %>
<% @items.each do |item| %>
<li class="r<%= n %> <%= item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
<%= linkify item, h(item.name(true)) %>
<small>(<%= item.namespace.title %>)</small>
</li>
<% n = n == 2 ? 1 : 2 %>
<% end %>

View File

@ -0,0 +1,298 @@
function createSourceLinks() {
$('.method_details_list .source_code').
before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
$('.toggleSource').toggle(function() {
$(this).parent().nextAll('.source_code').show();
$(this).text("Hide source");
StickyHeaders.update();
},
function() {
$(this).parent().nextAll('.source_code').hide();
$(this).text("View source");
StickyHeaders.update();
});
}
function createDefineLinks() {
var tHeight = 0;
$('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
$('.toggleDefines').toggle(function() {
tHeight = $(this).parent().prev().height();
$(this).prev().show();
$(this).parent().prev().height($(this).parent().height());
$(this).text("(less)");
StickyHeaders.update();
},
function() {
$(this).prev().hide();
$(this).parent().prev().height(tHeight);
$(this).text("more...");
StickyHeaders.update();
});
}
function createFullTreeLinks() {
var tHeight = 0;
$('.inheritanceTree').toggle(function() {
tHeight = $(this).parent().prev().height();
$(this).parent().toggleClass('showAll');
$(this).text("(hide)");
$(this).parent().prev().height($(this).parent().height());
StickyHeaders.update();
},
function() {
$(this).parent().toggleClass('showAll');
$(this).parent().prev().height(tHeight);
$(this).text("show all");
StickyHeaders.update();
});
}
function hideSearchFrameOnBlur() {
$(document.body).on('click', hideSearchFrame);
}
function initSearchFrameLinks() {
var search = $('.js-search');
var items = search.find('li');
var links = search.find('a');
var frame = $('.js-search-frame');
function listen() {
links.on('click', function (event) {
event.preventDefault();
event.stopPropagation();
toggle(this, this.href);
});
$(document).on('keydown', function (event) {
if (event.which == 27) {
close();
}
})
$(document).on('click', function (event) {
close();
})
}
function toggle(link, frameSrc) {
if (isOpen() && clickedOnSameLink(frameSrc)) {
close();
} else {
open(link, frameSrc);
}
}
function isOpen() {
return frame.hasClass('open');
}
function clickedOnSameLink(location) {
return frame.attr('src') === location;
}
function reset() {
items.removeClass('active');
}
function open(link, location) {
reset();
$(link).parent().addClass('active');
frame.attr('src', location).one('load', function () {
frame.addClass('open');
})
}
function close() {
reset();
frame.removeClass('open');
}
listen();
}
function linkSummaries() {
$('.summary_signature').click(function() {
document.location = $(this).find('a').attr('href');
});
}
function framesInit() {
if (hasFrames) {
document.body.className = 'frames';
$('#menu .noframes a').attr('href', document.location);
try {
window.top.document.title = $('html head title').text();
} catch(error) {
// some browsers will not allow this when serving from file://
// but we don't want to stop the world.
}
}
else {
$('#menu .noframes a').text('frames').attr('href', framesUrl);
}
}
function keyboardShortcuts() {
if (window.top.frames.main) return;
$(document).keypress(function(evt) {
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
if (
typeof evt.target !== "undefined" &&
(evt.target.nodeName == "INPUT" || evt.target.nodeName == "TEXTAREA")
) return;
switch (evt.charCode) {
case 67: case 99: $('#class_list_link').click(); break; // 'c'
case 77: case 109: $('#method_list_link').click(); break; // 'm'
case 70: case 102: $('#file_list_link').click(); break; // 'f'
default: break;
}
});
}
function summaryToggle() {
$('.summary_toggle').click(function() {
if (localStorage) {
localStorage.summaryCollapsed = $(this).text();
}
$('.summary_toggle').each(function() {
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
var next = $(this).parent().parent().nextAll('ul.summary').first();
if (next.hasClass('compact')) {
next.toggle();
next.nextAll('ul.summary').first().toggle();
}
else if (next.hasClass('summary')) {
var list = $('<ul class="summary compact" />');
list.html(next.html());
list.find('.summary_desc, .note').remove();
list.find('a').each(function() {
$(this).html($(this).find('strong').html());
$(this).parent().html($(this)[0].outerHTML);
});
next.before(list);
next.toggle();
}
});
StickyHeaders.update();
return false;
});
if (localStorage) {
if (localStorage.summaryCollapsed == "collapse") {
$('.summary_toggle').first().click();
}
else localStorage.summaryCollapsed = "expand";
}
}
function fixOutsideWorldLinks() {
$('a').each(function() {
if (window.location.host != this.host) this.target = '_parent';
});
}
function generateTOC() {
if ($('#filecontents').length === 0) return;
var _toc = $('<ol class="top"></ol>');
var show = false;
var toc = _toc;
var counter = 0;
var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
var i;
if ($('#filecontents h1').length > 1) tags.unshift('h1');
for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
var lastTag = parseInt(tags[0][1], 10);
$(tags.join(', ')).each(function() {
if ($(this).parents('.method_details .docstring').length != 0) return;
if (this.id == "filecontents") return;
show = true;
var thisTag = parseInt(this.tagName[1], 10);
if (this.id.length === 0) {
var proposedId = $(this).attr('toc-id');
if (typeof(proposedId) != "undefined") this.id = proposedId;
else {
var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
this.id = proposedId;
}
}
if (thisTag > lastTag) {
for (i = 0; i < thisTag - lastTag; i++) {
var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
}
}
if (thisTag < lastTag) {
for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
}
var title = $(this).attr('toc-title');
if (typeof(title) == "undefined") title = $(this).text();
toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
lastTag = thisTag;
});
if (!show) return;
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>';
$('#content').prepend(html);
$('#toc').append(_toc);
$('#toc .hide_toc').toggle(function() {
$('#toc .top').slideUp('fast');
$('#toc').toggleClass('hidden');
$('#toc .title small').toggle();
}, function() {
$('#toc .top').slideDown('fast');
$('#toc').toggleClass('hidden');
$('#toc .title small').toggle();
});
$('#toc .float_toc').toggle(function() {
$(this).text('float');
$('#toc').toggleClass('nofloat');
}, function() {
$(this).text('left');
$('#toc').toggleClass('nofloat');
});
}
function removeDlBoxIfEmpty() {
var $box = $('dl.box')
if (!$box.text().trim()) {
$box.remove();
}
}
function makeHeadersSticky() {
StickyHeaders
.set({
contentContainer: '#main',
stickyHeaderContainer: '#header',
switchOnCollisionWith: 'top',
fillHeadersWith: function (node) {
return $('<h3>').text(node.find('strong').text());
}
})
.add('.method_details > h3')
.activate();
}
function updateStickyHeaders() {
setTimeout(function () {
StickyHeaders.update()
}, 100)
}
$(makeHeadersSticky);
$(framesInit);
$(createSourceLinks);
$(createDefineLinks);
$(createFullTreeLinks);
$(initSearchFrameLinks);
$(linkSummaries);
$(keyboardShortcuts);
$(summaryToggle);
$(fixOutsideWorldLinks);
$(generateTOC);
$(removeDlBoxIfEmpty);
$(updateStickyHeaders);

View File

@ -0,0 +1 @@
// Override with nothing

View File

@ -0,0 +1,289 @@
window.StickyHeaders = (function ($) {
var me = {},
body, config, contentContainer, currentHeaderRangeIndex,
currentScrollOffset, elem, headerRanges, headers, isScrolling,
lastScrollOffset, selectors, stickyHeaderContainer;
function init() {
config = {
switchOnCollisionWith: 'top',
copy: 'element'
};
selectors = [];
headers = [];
headerRanges = [];
currentHeaderRangeIndex = -1;
currentScrollOffset = 0;
lastScrollOffset = 0;
isScrolling = false;
createStickyHeader();
}
function createStickyHeader() {
elem = $('<div>').attr('id', 'sticky-header');
}
function setHeaders() {
var elements = [],
stickyHeaderLineHeight = parseCssValue(elem.css('line-height')),
stickyHeaderTopPadding;
headers = [];
$.each(selectors, function (_, selector) {
contentContainer.find(selector).each(function (_, element) {
var $element = $(element),
fontSize = parseCssValue($element.css('font-size')),
topOffset = (
element.offsetTop +
parseFloat($element.css('padding-top'), 10) +
(- ((stickyHeaderLineHeight - fontSize) / 2))
),
height = Math.round($element.height()),
outerHeight = Math.round($element.outerHeight(true)),
bottomOffset = topOffset + outerHeight;
headers.push({
element: element,
$element: $element,
topOffset: topOffset,
bottomOffset: bottomOffset
});
})
})
}
function setHeaderRanges() {
var offsetProp = config.switchOnCollisionWith + 'Offset',
start, end;
headerRanges = [];
for (var i = 0, len = headers.length; i < len; i++) {
start = headers[i][offsetProp];
if (headers[i+1]) {
end = headers[i+1][offsetProp];
} else {
end = null;
}
headerRanges.push({
start: start,
end: end,
element: headers[i].element
});
}
//debugHeaderRanges();
}
function debugHeaderRanges() {
contentContainer.find('.header-range-debug').remove();
$.each(headerRanges, function (i, range) {
var color = 'hsla('+(20*i)+', 100%, 50%, 0.15)',
debug = $('<div>')
.addClass('header-range-debug')
.css({
width: '100%',
position: 'absolute',
top: range.start + 'px',
height: (range.end === null ? '1px' : (range.end - range.start) + 'px'),
backgroundColor: color,
borderTop: '1px solid black'
})
.appendTo(contentContainer)
debug.append(
$('<div>')
.css({
position: 'absolute',
top: 0,
right: 0,
height: '2em',
lineHeight: '2em',
width: '40em',
fontSize: '13px',
backgroundColor: 'black',
color: 'white',
padding: '0 5px'
})
.text(headers[i].$element.text() + ' (#' + i + ')')
)
})
}
function setCurrentHeaderIndex() {
var scrollTop = contentContainer.scrollTop();
for (var i = 0, len = headers.length; i < len; i++) {
if (scrollTop < headers[i].bottomOffset) {
break;
}
currentHeaderIndex = i;
}
}
function render() {
var clonedHeader;
if (currentHeaderRangeIndex < 0 || currentHeaderRangeIndex > headerRanges.length-1) {
elem.removeClass('show');
body.removeClass('has-sticky-header');
}
else {
var realHeader = $(headerRanges[currentHeaderRangeIndex].element);
if (typeof config.fillHeadersWith === 'function') {
elem.html(config.fillHeadersWith(realHeader));
} else if (config.fillHeadersWith === 'content') {
elem.html(realHeader.clone().html());
} else {
elem.html(realHeader.clone());
}
elem.addClass('show');
body.addClass('has-sticky-header');
}
return me;
}
function determineCurrentHeaderRangeIndex(startIndex, direction) {
var index = startIndex;
while (true) {
currentHeaderRange = headerRanges[index];
if (!currentHeaderRange || isWithinRange(currentScrollOffset, currentHeaderRange)) {
break;
} else {
index += direction;
}
}
return index;
}
function onScroll() {
if (!headerRanges.length) {
return;
}
currentScrollOffset = contentContainer.scrollTop();
if (currentScrollOffset > headerRanges[0].start) {
var newCurrentHeaderRangeIndex = currentHeaderRangeIndex;
var currentHeaderRange = headerRanges[newCurrentHeaderRangeIndex];
if (newCurrentHeaderRangeIndex < 0) {
newCurrentHeaderRangeIndex = 0;
}
if (currentScrollOffset < lastScrollOffset) {
// scrolling up
newCurrentHeaderRangeIndex = determineCurrentHeaderRangeIndex(newCurrentHeaderRangeIndex, -1);
} else {
// scrolling down
newCurrentHeaderRangeIndex = determineCurrentHeaderRangeIndex(newCurrentHeaderRangeIndex, +1);
}
} else {
newCurrentHeaderRangeIndex = -1;
}
// only re-render when necessary
if (newCurrentHeaderRangeIndex !== undefined && currentHeaderRangeIndex !== newCurrentHeaderRangeIndex) {
currentHeaderRangeIndex = newCurrentHeaderRangeIndex;
render();
}
lastScrollOffset = currentScrollOffset;
}
function listenToScroll(element, callback, options) {
options = options || {};
if (options.every) {
element.on('scroll', function () {
isScrolling = true;
})
setInterval(function () {
if (isScrolling) {
callback();
isScrolling = false;
}
}, options.every);
}
else {
element.on('scroll', callback);
}
}
function isWithinRange(number, range) {
return (
number >= range.start &&
(
range.end === undefined ||
range.end === null ||
number <= range.end
)
);
}
function parseCssValue(value) {
if (value === null || value === undefined) {
return 0;
} else {
return parseInt(value, 10);
}
}
me.setHeaders = setHeaders;
me.setHeaderRanges = setHeaderRanges;
me.set = function (/* key, value | config */) {
if ($.isPlainObject(arguments[0])) {
$.extend(config, arguments[0]);
} else {
config[arguments[0]] = arguments[1];
}
return me;
}
me.add = function (/* selectors... */) {
selectors.push.apply(selectors, arguments);
return me;
}
me.activate = function () {
body = $('body');
contentContainer = config.contentContainer ? $(config.contentContainer) : body;
stickyHeaderContainer = config.stickyHeaderContainer ? $(config.stickyHeaderContainer) : contentContainer;
stickyHeaderContainer.append(elem);
setHeaders();
setHeaderRanges();
setCurrentHeaderIndex();
return me;
}
me.update = function () {
setHeaders();
setHeaderRanges();
render();
listenToScroll(contentContainer, onScroll);
}
me.getHeaders = function () {
return headers;
}
me.getHeaderRanges = function () {
return headerRanges;
}
init();
return me;
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
def stylesheets_full_list
%w(css/solarized.css css/bootstrap.css css/global.css) + super
end
def javascripts
javascripts = super
javascripts.insert 1, 'js/jquery.stickyheaders.js'
end

View File

@ -0,0 +1,14 @@
<div id="menu">
<% unless @file && @file.filename == 'README.md' %>
<span class="title">
<%= linkify('file:README.md', 'Home') %>
</span> &raquo;
<% end %>
<% if @contents || @file %>
<span class="title"><%= @breadcrumb_title %></span>
<% elsif object.is_a?(CodeObjects::Base) %>
<%= @breadcrumb.map {|obj| "<span class='title'>" + linkify(obj, obj.name) + "</span>" }.join(" &raquo; ") %>
<%= @breadcrumb.size > 0 ? " &raquo; " : "" %>
<span class="title"><%= object.root? ? "Top Level Namespace" : object.name(true) %></span>
<% end %>
</div>

View File

@ -0,0 +1 @@
<!-- Fonts go here -->

View File

@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<%= erb(:headers) %>
</head>
<body>
<div id="header">
<div class="header-row">
<%= erb(:breadcrumb) %>
<%= erb(:search) %>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><%= yieldall %></div>
<%= erb(:footer) %>
</div>
</body>
</html>

View File

@ -0,0 +1,13 @@
<div id="search" class="js-search">
<ul>
<% menu_lists.each do |field| %>
<li>
<a href="<%= url_for_list(field[:type]) %>">
<%= field[:search_title] %>
</a>
</li>
<% end %>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>

View File

@ -0,0 +1,8 @@
def stylesheets
%w(css/solarized.css css/bootstrap.css css/global.css) + super
end
def javascripts
javascripts = super
javascripts.insert 1, 'js/jquery.stickyheaders.js', 'js/underscore.min.js'
end

View File

@ -0,0 +1,10 @@
<table class="source_code">
<tr>
<td class="lines">
<pre><%= "\n\n\n" %><%= h format_lines(object) %></pre>
</td>
<td class="code">
<pre><span class="info file"># File '<%= h object.file %>'<% if object.line %>, line <%= object.line %><% end %></span><%= "\n\n" %><%= html_syntax_highlight object.source %></pre>
</td>
</tr>
</table>

View File

@ -0,0 +1,31 @@
<% n = 1 %>
<dl class="box">
<% if CodeObjects::ClassObject === object && object.superclass %>
<dt class="r<%=n%>">Inherits:</dt>
<dd class="r<%=n%>">
<span class="inheritName"><%= linkify object.superclass %></span>
<% if object.superclass.name != :BasicObject %>
<ul class="fullTree">
<li><%= linkify P(:Object) %></li>
<% object.inheritance_tree.reverse.each_with_index do |obj, i| %>
<li class="next"><%= obj == object ? obj.path : linkify(obj) %></li>
<% end %>
</ul>
<a href="#" class="inheritanceTree">show all</a>
<% end %>
</dd>
<% n = 2 %>
<% end %>
<% [[:class, "Extended by"], [:instance, "Includes"]].each do |scope, name| %>
<% if (mix = run_verifier(object.mixins(scope))).size > 0 %>
<dt class="r<%=n%>"><%= name %>:</dt>
<dd class="r<%=n%>"><%= mix.sort_by {|o| o.path }.map {|o| linkify(o) }.join(", ") %></dd>
<% n = n == 2 ? 1 : 2 %>
<% end %>
<% end %>
<% if (mixed_into = mixed_into(object)).size > 0 %>
<dt class="r<%=n%>">Included in:</dt>
<dd class="r<%=n%>"><%= mixed_into.sort_by {|o| o.path }.map {|o| linkify(o) }.join(", ") %></dd>
<% n = n == 2 ? 1 : 2 %>
<% end %>
</dl>

View File

@ -10,6 +10,10 @@ gem "cucumber", "~> 1.1"
gem "pry"
gem "rake", ">= 0.9.2"
gem "rspec-rails", ">= 2.13.1", "< 3"
gem "yard"
gem "redcarpet"
gem "pygments.rb"
gem "watchr"
gem "shoulda-context", "~> 1.2.0"
gem "sqlite3", :platform=>:ruby
gem "activerecord-jdbc-adapter", :platform=>:jruby

View File

@ -74,10 +74,14 @@ GEM
metaclass (~> 0.0.1)
multi_json (1.7.1)
polyglot (0.3.3)
posix-spawn (0.3.8)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.2.8)
rack-mount (0.6.14)
rack (>= 1.0.0)
@ -100,6 +104,7 @@ GEM
rake (10.0.3)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.1.2)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
@ -123,6 +128,9 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -138,11 +146,15 @@ DEPENDENCIES
jdbc-sqlite3
jruby-openssl
pry
pygments.rb
rails (~> 3.0.17)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
shoulda-context (~> 1.2.0)
shoulda-matchers!
sqlite3
strong_parameters
therubyrhino
watchr
yard

View File

@ -10,6 +10,10 @@ gem "cucumber", "~> 1.1"
gem "pry"
gem "rake", ">= 0.9.2"
gem "rspec-rails", ">= 2.13.1", "< 3"
gem "yard"
gem "redcarpet"
gem "pygments.rb"
gem "watchr"
gem "shoulda-context", "~> 1.2.0"
gem "sqlite3", :platform=>:ruby
gem "activerecord-jdbc-adapter", :platform=>:jruby

View File

@ -87,10 +87,14 @@ GEM
metaclass (~> 0.0.1)
multi_json (1.7.1)
polyglot (0.3.3)
posix-spawn (0.3.8)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.3.10)
rack-cache (1.2)
rack (>= 0.4)
@ -118,6 +122,7 @@ GEM
rake (10.0.3)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.1.2)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
@ -157,6 +162,9 @@ GEM
uglifier (2.2.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -175,8 +183,10 @@ DEPENDENCIES
jquery-rails
jruby-openssl
pry
pygments.rb
rails (~> 3.1.8)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
sass-rails (~> 3.1.5)
shoulda-context (~> 1.2.0)
@ -186,3 +196,5 @@ DEPENDENCIES
therubyrhino
turn (~> 0.8.3)
uglifier (>= 1.0.3)
watchr
yard

View File

@ -10,6 +10,10 @@ gem "cucumber", "~> 1.1"
gem "pry"
gem "rake", ">= 0.9.2"
gem "rspec-rails", ">= 2.13.1", "< 3"
gem "yard"
gem "redcarpet"
gem "pygments.rb"
gem "watchr"
gem "shoulda-context", "~> 1.2.0"
gem "sqlite3", :platform=>:ruby
gem "activerecord-jdbc-adapter", :platform=>:jruby

View File

@ -89,10 +89,14 @@ GEM
multi_json (1.8.4)
multi_test (0.0.3)
polyglot (0.3.3)
posix-spawn (0.3.8)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.3.10)
rack-cache (1.2)
rack (>= 0.4)
@ -120,6 +124,7 @@ GEM
rake (10.1.1)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.1.2)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
@ -160,6 +165,9 @@ GEM
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -178,8 +186,10 @@ DEPENDENCIES
jquery-rails
jruby-openssl
pry
pygments.rb
rails (~> 3.1.8)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
sass-rails (~> 3.1.5)
shoulda-context (~> 1.2.0)
@ -189,3 +199,5 @@ DEPENDENCIES
therubyrhino
turn (= 0.8.2)
uglifier (>= 1.0.3)
watchr
yard

View File

@ -10,6 +10,10 @@ gem "cucumber", "~> 1.1"
gem "pry"
gem "rake", ">= 0.9.2"
gem "rspec-rails", ">= 2.13.1", "< 3"
gem "yard"
gem "redcarpet"
gem "pygments.rb"
gem "watchr"
gem "shoulda-context", "~> 1.2.0"
gem "sqlite3", :platform=>:ruby
gem "activerecord-jdbc-adapter", :platform=>:jruby

View File

@ -86,10 +86,14 @@ GEM
metaclass (~> 0.0.1)
multi_json (1.7.1)
polyglot (0.3.3)
posix-spawn (0.3.8)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
@ -115,6 +119,7 @@ GEM
rake (10.1.1)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (3.1.2)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
@ -152,6 +157,9 @@ GEM
uglifier (2.2.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -170,8 +178,10 @@ DEPENDENCIES
jquery-rails
jruby-openssl
pry
pygments.rb
rails (~> 3.2.13)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
sass-rails (~> 3.2.3)
shoulda-context (~> 1.2.0)
@ -180,3 +190,5 @@ DEPENDENCIES
strong_parameters
therubyrhino
uglifier (>= 1.0.3)
watchr
yard

View File

@ -10,6 +10,10 @@ gem "cucumber", "~> 1.1"
gem "pry"
gem "rake", ">= 0.9.2"
gem "rspec-rails", ">= 2.13.1", "< 3"
gem "yard"
gem "redcarpet"
gem "pygments.rb"
gem "watchr"
gem "shoulda-context", "~> 1.2.0"
gem "sqlite3", :platform=>:ruby
gem "activerecord-jdbc-adapter", :platform=>:jruby

View File

@ -92,12 +92,16 @@ GEM
multi_json (1.8.2)
multi_test (0.0.2)
polyglot (0.3.3)
posix-spawn (0.3.8)
protected_attributes (1.0.3)
activemodel (>= 4.0.0, < 5.0)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
@ -119,6 +123,7 @@ GEM
rake (10.1.1)
rdoc (4.1.1)
json (~> 1.4)
redcarpet (3.1.2)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
@ -163,6 +168,9 @@ GEM
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -184,8 +192,10 @@ DEPENDENCIES
jruby-openssl
protected_attributes
pry
pygments.rb
rails (= 4.0.0)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
sass-rails (~> 4.0.0)
sdoc
@ -195,3 +205,5 @@ DEPENDENCIES
therubyrhino
turbolinks
uglifier (>= 1.3.0)
watchr
yard

View File

@ -10,6 +10,10 @@ gem "cucumber", "~> 1.1"
gem "pry"
gem "rake", ">= 0.9.2"
gem "rspec-rails", ">= 2.13.1", "< 3"
gem "yard"
gem "redcarpet"
gem "pygments.rb"
gem "watchr"
gem "shoulda-context", "~> 1.2.0"
gem "sqlite3", :platform=>:ruby
gem "activerecord-jdbc-adapter", :platform=>:jruby

View File

@ -92,12 +92,16 @@ GEM
multi_json (1.8.2)
multi_test (0.0.2)
polyglot (0.3.3)
posix-spawn (0.3.8)
protected_attributes (1.0.5)
activemodel (>= 4.0.1, < 5.0)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
@ -119,6 +123,7 @@ GEM
rake (10.1.1)
rdoc (4.1.1)
json (~> 1.4)
redcarpet (3.1.2)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
@ -163,6 +168,9 @@ GEM
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -184,8 +192,10 @@ DEPENDENCIES
jruby-openssl
protected_attributes
pry
pygments.rb
rails (= 4.0.1)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
sass-rails (~> 4.0.0)
sdoc
@ -195,3 +205,5 @@ DEPENDENCIES
therubyrhino
turbolinks
uglifier (>= 1.3.0)
watchr
yard

View File

@ -10,6 +10,10 @@ gem "cucumber", "~> 1.1"
gem "pry"
gem "rake", ">= 0.9.2"
gem "rspec-rails", ">= 2.13.1", "< 3"
gem "yard"
gem "redcarpet"
gem "pygments.rb"
gem "watchr"
gem "shoulda-context", "~> 1.2.0"
gem "sqlite3", :platform=>:ruby
gem "activerecord-jdbc-adapter", :platform=>:jruby

View File

@ -93,12 +93,16 @@ GEM
multi_json (1.9.2)
multi_test (0.0.3)
polyglot (0.3.4)
posix-spawn (0.3.8)
protected_attributes (1.0.7)
activemodel (>= 4.0.1, < 5.0)
pry (0.9.12.6)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.6.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
@ -122,6 +126,7 @@ GEM
rake (10.2.2)
rdoc (4.1.1)
json (~> 1.4)
redcarpet (3.1.2)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
@ -169,6 +174,9 @@ GEM
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
watchr (0.7)
yajl-ruby (1.1.0)
yard (0.8.7.3)
PLATFORMS
ruby
@ -190,8 +198,10 @@ DEPENDENCIES
jruby-openssl
protected_attributes (~> 1.0.6)
pry
pygments.rb
rails (~> 4.1.0)
rake (>= 0.9.2)
redcarpet
rspec-rails (>= 2.13.1, < 3)
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)
@ -202,3 +212,5 @@ DEPENDENCIES
therubyrhino
turbolinks
uglifier (>= 1.3.0)
watchr
yard

View File

@ -3,7 +3,7 @@ module Shoulda
module ActiveModel
module NumericalityMatchers
# @private
class OnlyIntegerMatcher
class OnlyIntegerMatcher < NumericTypeMatcher
NON_INTEGER_VALUE = 0.1
def initialize(attribute)
@attribute = attribute

5
yard.watchr Normal file
View File

@ -0,0 +1,5 @@
watch('README.md') { system('bundle exec yard doc') }
watch('doc_config/yard/.*') { system('bundle exec yard doc') }
watch('lib/.*\.rb') { system('bundle exec yard doc') }
# vi: ft=ruby