prawn-dev 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,317 @@
1
+ (function() {
2
+
3
+ class StorageStub {
4
+ key(name) { return false };
5
+ setItem(name, value) {};
6
+ getItem(name) {};
7
+ removeItem(name) {};
8
+ clear() {};
9
+ }
10
+
11
+ var localStorage = new StorageStub(),
12
+ sessionStorage = new StorageStub();;
13
+ try { localStorage = window.localStorage; } catch (e) { }
14
+ try { sessionStorage = window.sessionStorage; } catch (e) { }
15
+
16
+ function createDefineLinks() {
17
+ var tHeight = 0;
18
+ $('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
19
+ $('.toggleDefines').toggle(function() {
20
+ tHeight = $(this).parent().prev().height();
21
+ $(this).prev().css('display', 'inline');
22
+ $(this).parent().prev().height($(this).parent().height());
23
+ $(this).text("(less)");
24
+ },
25
+ function() {
26
+ $(this).prev().hide();
27
+ $(this).parent().prev().height(tHeight);
28
+ $(this).text("more...");
29
+ });
30
+ }
31
+
32
+ function createFullTreeLinks() {
33
+ var tHeight = 0;
34
+ $('.inheritanceTree').toggle(function() {
35
+ tHeight = $(this).parent().prev().height();
36
+ $(this).parent().toggleClass('showAll');
37
+ $(this).text("(hide)");
38
+ $(this).parent().prev().height($(this).parent().height());
39
+ },
40
+ function() {
41
+ $(this).parent().toggleClass('showAll');
42
+ $(this).parent().prev().height(tHeight);
43
+ $(this).text("show all");
44
+ });
45
+ }
46
+
47
+ function searchFrameButtons() {
48
+ $('.full_list_link').click(function() {
49
+ toggleSearchFrame(this, $(this).attr('href'));
50
+ return false;
51
+ });
52
+ window.addEventListener('message', function(e) {
53
+ if (e.data === 'navEscape') {
54
+ $('#nav').slideUp(100);
55
+ $('#search a').removeClass('active inactive');
56
+ $(window).focus();
57
+ }
58
+ });
59
+
60
+ $(window).resize(function() {
61
+ if ($('#search:visible').length === 0) {
62
+ $('#nav').removeAttr('style');
63
+ $('#search a').removeClass('active inactive');
64
+ $(window).focus();
65
+ }
66
+ });
67
+ }
68
+
69
+ function toggleSearchFrame(id, link) {
70
+ var frame = $('#nav');
71
+ $('#search a').removeClass('active').addClass('inactive');
72
+ if (frame.attr('src') === link && frame.css('display') !== "none") {
73
+ frame.slideUp(100);
74
+ $('#search a').removeClass('active inactive');
75
+ }
76
+ else {
77
+ $(id).addClass('active').removeClass('inactive');
78
+ if (frame.attr('src') !== link) frame.attr('src', link);
79
+ frame.slideDown(100);
80
+ }
81
+ }
82
+
83
+ function linkSummaries() {
84
+ $('.summary_signature').click(function() {
85
+ document.location = $(this).find('a').attr('href');
86
+ });
87
+ }
88
+
89
+ function summaryToggle() {
90
+ document.querySelectorAll('.summary_toggle').forEach(function(toggle) {
91
+ let section = toggle.parentElement.parentElement.parentElement;
92
+
93
+ toggle.addEventListener('click', function(e) {
94
+ e.preventDefault();
95
+ localStorage.setItem(section.getAttribute('id'), this.textContent);
96
+ let summary = section.querySelector('ul.summary');
97
+ if (!summary.classList.contains('compact')) {
98
+ let list = document.createElement('ul')
99
+ list.classList.add('summary', 'compact');
100
+ list.innerHTML = summary.innerHTML;
101
+ list.querySelectorAll('.summary_desc, .note').forEach((el) => el.remove());
102
+ list.querySelectorAll('a').forEach(function(el) {
103
+ el.innerHTML = el.querySelector('strong').innerHTML;
104
+ el.parentElement.innerHTML = el.outerHTML;
105
+ });
106
+ summary.insertAdjacentElement('beforebegin', list);
107
+ }
108
+
109
+ if (this.textContent === 'collapse') {
110
+ this.textContent = 'expand';
111
+ section.querySelector('.summary.compact').style.removeProperty('display');
112
+ section.querySelector('.summary.compact + .summary').style.display = 'none';
113
+ } else {
114
+ this.textContent = 'collapse';
115
+ section.querySelector('.summary.compact').style.display = 'none';
116
+ section.querySelector('.summary.compact + .summary').style.removeProperty('display');
117
+ }
118
+ });
119
+
120
+ if (localStorage.getItem(section.getAttribute('id')) == 'collapse') {
121
+ toggle.dispatchEvent(new Event('click'));
122
+ }
123
+ });
124
+ }
125
+
126
+ function constantSummaryToggle() {
127
+ $('.constants_summary_toggle').click(function(e) {
128
+ e.preventDefault();
129
+ localStorage.setItem('summaryCollapsed', $(this).text());
130
+ //$('.constants_summary_toggle').each(function() {
131
+ $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
132
+ var next = $(this).parent().parent().nextAll('dl.constants').first();
133
+ if (next.hasClass('compact')) {
134
+ next.toggle();
135
+ next.nextAll('dl.constants').first().toggle();
136
+ }
137
+ else if (next.hasClass('constants')) {
138
+ var list = $('<dl class="constants compact" />');
139
+ list.html(next.html());
140
+ list.find('dt').each(function() {
141
+ $(this).addClass('summary_signature');
142
+ $(this).text( $(this).text().split('=')[0]);
143
+ if ($(this).has(".deprecated").length) {
144
+ $(this).addClass('deprecated');
145
+ };
146
+ });
147
+ // Add the value of the constant as "Tooltip" to the summary object
148
+ list.find('pre.code').each(function() {
149
+ console.log($(this).parent());
150
+ var dt_element = $(this).parent().prev();
151
+ var tooltip = $(this).text();
152
+ if (dt_element.hasClass("deprecated")) {
153
+ tooltip = 'Deprecated. ' + tooltip;
154
+ };
155
+ dt_element.attr('title', tooltip);
156
+ });
157
+ list.find('.docstring, .tags, dd').remove();
158
+ next.before(list);
159
+ next.toggle();
160
+ }
161
+ //});
162
+ return false;
163
+ });
164
+ if (localStorage.setItem('summaryCollapsed', "collapse")) {
165
+ $('.constants_summary_toggle').first().click();
166
+ } else { localStorage.setItem('summaryCollapsed', "expand"); }
167
+ }
168
+
169
+ function generateTOC() {
170
+ if (!document.getElementById('filecontents')) return;
171
+
172
+ var _toc = $('<ol class="top"></ol>');
173
+ var show = false;
174
+ var toc = _toc;
175
+ var counter = 0;
176
+ var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
177
+ var i;
178
+ var curli;
179
+ if ($('#filecontents h1').length > 1) tags.unshift('h1');
180
+ for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
181
+ var lastTag = parseInt(tags[0][1], 10);
182
+ $(tags.join(', ')).each(function() {
183
+ if ($(this).parents('.method_details .docstring').length != 0) return;
184
+ if (this.id == "filecontents") return;
185
+ show = true;
186
+ var thisTag = parseInt(this.tagName[1], 10);
187
+ if (this.id.length === 0) {
188
+ var proposedId = $(this).attr('toc-id');
189
+ if (typeof(proposedId) != "undefined") this.id = proposedId;
190
+ else {
191
+ var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
192
+ if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
193
+ this.id = proposedId;
194
+ }
195
+ }
196
+ if (thisTag > lastTag) {
197
+ for (i = 0; i < thisTag - lastTag; i++) {
198
+ if ( typeof(curli) == "undefined" ) {
199
+ curli = $('<li/>');
200
+ toc.append(curli);
201
+ }
202
+ toc = $('<ol/>');
203
+ curli.append(toc);
204
+ curli = undefined;
205
+ }
206
+ }
207
+ if (thisTag < lastTag) {
208
+ for (i = 0; i < lastTag - thisTag; i++) {
209
+ toc = toc.parent();
210
+ toc = toc.parent();
211
+ }
212
+ }
213
+ var title = $(this).attr('toc-title');
214
+ if (typeof(title) == "undefined") title = $(this).text();
215
+ curli =$('<li><a href="#' + this.id + '">' + title + '</a></li>');
216
+ toc.append(curli);
217
+ lastTag = thisTag;
218
+ });
219
+ if (!show) return;
220
+ html = '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
221
+ $('#content').prepend(html);
222
+ $('#toc').append(_toc);
223
+ $('#toc .hide_toc').toggle(function() {
224
+ $('#toc .top').slideUp('fast');
225
+ $('#toc').toggleClass('hidden');
226
+ $('#toc .title small').toggle();
227
+ }, function() {
228
+ $('#toc .top').slideDown('fast');
229
+ $('#toc').toggleClass('hidden');
230
+ $('#toc .title small').toggle();
231
+ });
232
+ }
233
+
234
+ function navResizeFn(e) {
235
+ if (e.which !== 1) {
236
+ navResizeFnStop();
237
+ return;
238
+ }
239
+
240
+ sessionStorage.setItem('navWidth', e.pageX.toString());
241
+ $('.nav_wrap').css('width', e.pageX);
242
+ $('.nav_wrap').css('-ms-flex', 'inherit');
243
+ }
244
+
245
+ function navResizeFnStop() {
246
+ $(window).unbind('mousemove', navResizeFn);
247
+ window.removeEventListener('message', navMessageFn, false);
248
+ }
249
+
250
+ function navMessageFn(e) {
251
+ if (e.data.action === 'mousemove') navResizeFn(e.data.event);
252
+ if (e.data.action === 'mouseup') navResizeFnStop();
253
+ }
254
+
255
+ function navResizer() {
256
+ $('#resizer').mousedown(function(e) {
257
+ e.preventDefault();
258
+ $(window).mousemove(navResizeFn);
259
+ window.addEventListener('message', navMessageFn, false);
260
+ });
261
+ $(window).mouseup(navResizeFnStop);
262
+
263
+ if (sessionStorage.key('navWidth')) {
264
+ navResizeFn({which: 1, pageX: parseInt(sessionStorage.getItem('navWidth'), 10)});
265
+ }
266
+ }
267
+
268
+ function navExpander() {
269
+ var done = false, timer = setTimeout(postMessage, 500);
270
+ function postMessage() {
271
+ if (done) return;
272
+ clearTimeout(timer);
273
+ var opts = { action: 'expand', path: pathId };
274
+ document.getElementById('nav').contentWindow.postMessage(opts, '*');
275
+ done = true;
276
+ }
277
+
278
+ window.addEventListener('message', function(event) {
279
+ if (event.data === 'navReady') postMessage();
280
+ return false;
281
+ }, false);
282
+ }
283
+
284
+ function mainFocus() {
285
+ var hash = window.location.hash;
286
+ if (hash !== '' && $(hash)[0]) {
287
+ $(hash)[0].scrollIntoView();
288
+ }
289
+
290
+ setTimeout(function() { $('#main').focus(); }, 10);
291
+ }
292
+
293
+ function navigationChange() {
294
+ // This works around the broken anchor navigation with the YARD template.
295
+ window.onpopstate = function() {
296
+ var hash = window.location.hash;
297
+ if (hash !== '' && $(hash)[0]) {
298
+ $(hash)[0].scrollIntoView();
299
+ }
300
+ };
301
+ }
302
+
303
+ $(document).ready(function() {
304
+ navResizer();
305
+ navExpander();
306
+ createDefineLinks();
307
+ createFullTreeLinks();
308
+ searchFrameButtons();
309
+ linkSummaries();
310
+ summaryToggle();
311
+ constantSummaryToggle();
312
+ generateTOC();
313
+ mainFocus();
314
+ navigationChange();
315
+ });
316
+
317
+ })();
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ def stylesheets_full_list
4
+ super + %w[css/syntax-highlight.css]
5
+ end
6
+
7
+ def file(basename, allow_inherited = false)
8
+ if basename == 'css/syntax-highlight.css'
9
+ require('rouge')
10
+ Rouge::Theme.find('magritte').render
11
+ [
12
+ '.highlighter-rouge',
13
+ ].map { |scope|
14
+ Rouge::Theme.find('github.light').render(scope: scope)
15
+ }.join("\n")
16
+ else
17
+ super
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ def stylesheets
4
+ super + %w[css/syntax-highlight.css]
5
+ end
6
+
7
+ def file(basename, allow_inherited = false)
8
+ puts " >> #{basename}"
9
+ if basename == 'css/syntax-highlight.css'
10
+ return 'body { background: yellow; }'
11
+ end
12
+
13
+ super
14
+ end
@@ -0,0 +1,17 @@
1
+ <%
2
+ lang = {
3
+ '.rb' => 'ruby'
4
+ }[File.extname(object.file)] || 'guess'
5
+ lexer = ::Rouge::Lexer.find_fancy(lang, object.source)
6
+ formatter = ::Rouge::Formatters::HTMLLineTable.new(
7
+ Rouge::Formatters::HTML.new,
8
+ start_line: object.line || 1,
9
+ table_class: 'highlight highlighter-rouge'
10
+ )
11
+
12
+ %>
13
+ <details class="source-code">
14
+ <summary><span>Source Code</span></summary>
15
+ <div class="info file"><%= h object.file %><% if object.line %>, line <%= object.line %><% end %></div>
16
+ <%= formatter.format(lexer.lex(object.source)) %>
17
+ </details>
@@ -0,0 +1,11 @@
1
+ <% require 'zlib' %>
2
+ <% groups(attr_listing, "Attribute") do |list, name| %>
3
+ <section id="attribute-summary-<%= Zlib.crc32(name).to_s(36) %>">
4
+ <h2><%= name %> <small><a href="#" class="summary_toggle">collapse</a></small></h2>
5
+ <ul class="summary">
6
+ <% list.each do |meth| %>
7
+ <%= yieldall :item => meth %>
8
+ <% end %>
9
+ </ul>
10
+ </section>
11
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <% if constant_listing.size > 0 %>
2
+ <% require 'zlib' %>
3
+ <% groups(constant_listing, "Constant") do |list, name| %>
4
+ <section id="constant-summary-<%= Zlib.crc32(name).to_s(36) %>">
5
+ <h2>
6
+ <%= name %>
7
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
8
+ </h2>
9
+
10
+ <dl class="constants">
11
+ <% list.each do |cnst| %>
12
+ <dt id="<%= anchor_for(cnst) %>" class="<%= cnst.has_tag?(:deprecated) ? 'deprecated' : '' %>"><%= cnst.name %> =
13
+ <%= yieldall :object => cnst %>
14
+ </dt>
15
+ <dd><pre class="code"><%= format_constant cnst.value %></pre></dd>
16
+ <% end %>
17
+ </dl>
18
+ </section>
19
+ <% end %>
20
+ <% end %>
@@ -0,0 +1,46 @@
1
+ <li class="<%= @item.visibility %> <%= @item.has_tag?(:deprecated) ? 'deprecated' : '' %>">
2
+ <span class="summary_signature">
3
+ <% if @item.tags(:overload).size == 1 %>
4
+ <%= signature(@item.tag(:overload), true, false, !@item.attr_info) %>
5
+ <% elsif @item.tags(:overload).size > 1 %>
6
+ <a href="<%= url_for(object, @item) %>">
7
+ <% @item.tags(:overload).each do |overload| %>
8
+ <span class="overload"><%= signature(overload, false, false, !@item.attr_info).strip %></span>
9
+ <% end %>
10
+ </a>
11
+ <% else %>
12
+ <%= signature(@item, true, false, !@item.attr_info) %>
13
+ <% end %>
14
+
15
+ <% if @item.aliases.size > 0 %>
16
+ (also: <%= @item.aliases.map {|o| h(o.name(true)) }.join(", ") %>)
17
+ <% end %>
18
+ </span>
19
+ <% if object != @item.namespace %>
20
+ <span class="note title not_defined_here">
21
+ <%= @item.namespace.type == :class ? 'inherited' : (@item.scope == :class ? 'extended' : 'included') %>
22
+ from <%= linkify @item, object.relative_path(@item.namespace) %>
23
+ </span>
24
+ <% end %>
25
+ <% if @item.constructor? %>
26
+ <span class="note title constructor">constructor</span>
27
+ <% end %>
28
+ <% if rw = @item.attr_info %>
29
+ <% if !run_verifier([rw[:read]].compact).empty? && run_verifier([rw[:write]].compact).empty? %>
30
+ <span class="note title readonly">readonly</span>
31
+ <% end %>
32
+ <% if !run_verifier([rw[:write]].compact).empty? && run_verifier([rw[:read]].compact).empty? %>
33
+ <span class="note title writeonly">writeonly</span>
34
+ <% end %>
35
+ <% end %>
36
+ <% if @item.visibility != :public %><span class="note title <%= @item.visibility %>"><%= @item.visibility %></span><% end %>
37
+ <% if @item.has_tag?(:abstract) %><span class="abstract note title">abstract</span><% end %>
38
+ <% if @item.has_tag?(:deprecated) %><span class="deprecated note title">deprecated</span><% end %>
39
+ <% if @item.has_tag?(:api) && @item.tag(:api).text == 'private' %><span class="private note title">private</span><% end %>
40
+
41
+ <% if @item.has_tag?(:deprecated) %>
42
+ <span class="summary_desc"><strong>Deprecated.</strong> <%= htmlify_line @item.tag(:deprecated).text %></span>
43
+ <% else %>
44
+ <span class="summary_desc"><%= htmlify_line docstring_summary(@item) %></span>
45
+ <% end %>
46
+ </li>
@@ -0,0 +1,17 @@
1
+ <% if method_listing.size > 0 %>
2
+ <% require 'zlib' %>
3
+ <% groups(method_listing) do |list, name| %>
4
+ <section id="method-summary-<%= Zlib.crc32(name).to_s(36) %>">
5
+ <h2>
6
+ <%= name %>
7
+ <small><a href="#" class="summary_toggle">collapse</a></small>
8
+ </h2>
9
+
10
+ <ul class="summary">
11
+ <% list.each do |meth| %>
12
+ <%= yieldall :item => meth %>
13
+ <% end %>
14
+ </ul>
15
+ </section>
16
+ <% end %>
17
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <% if object.has_tag?(:example) %>
2
+ <div class="examples">
3
+ <p class="tag_title">Examples:</p>
4
+ <% object.tags(:example).each do |tag| %>
5
+ <% unless tag.name.empty? %>
6
+ <p class="example_title"><%= htmlify_line(tag.name) %></p>
7
+ <% end %>
8
+ <%= html_syntax_highlight(tag.text) %>
9
+ <% end %>
10
+ </div>
11
+ <% end %>
data.tar.gz.sig CHANGED
Binary file