gitlab-rdoc 6.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +133 -0
- data/RI.rdoc +57 -0
- data/Rakefile +101 -0
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/exe/rdoc +44 -0
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +112 -0
- data/lib/rdoc/anon_class.rb +11 -0
- data/lib/rdoc/any_method.rb +361 -0
- data/lib/rdoc/attr.rb +176 -0
- data/lib/rdoc/class_module.rb +802 -0
- data/lib/rdoc/code_object.rb +421 -0
- data/lib/rdoc/code_objects.rb +6 -0
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +187 -0
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +1266 -0
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +136 -0
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +42 -0
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +790 -0
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +160 -0
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +98 -0
- data/lib/rdoc/generator/ri.rb +31 -0
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/brick_link.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bug.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_black.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/date.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/find.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif +0 -0
- data/lib/rdoc/generator/template/darkfish/images/macFFBgHack.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/package.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_text.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/page_white_width.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/plugin.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/ruby.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_green.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/wrench_orange.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/zoom.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +84 -0
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +51 -0
- data/lib/rdoc/ghost_method.rb +7 -0
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +10 -0
- data/lib/rdoc/known_classes.rb +73 -0
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +417 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16685 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +409 -0
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +28 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +165 -0
- data/lib/rdoc/markup/formatter.rb +266 -0
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +79 -0
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +102 -0
- data/lib/rdoc/markup/list_item.rb +100 -0
- data/lib/rdoc/markup/paragraph.rb +29 -0
- data/lib/rdoc/markup/parser.rb +575 -0
- data/lib/rdoc/markup/pre_process.rb +296 -0
- data/lib/rdoc/markup/raw.rb +70 -0
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +21 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +94 -0
- data/lib/rdoc/markup/to_bs.rb +77 -0
- data/lib/rdoc/markup/to_html.rb +444 -0
- data/lib/rdoc/markup/to_html_crossref.rb +176 -0
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +362 -0
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +70 -0
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +84 -0
- data/lib/rdoc/markup.rb +867 -0
- data/lib/rdoc/meta_method.rb +7 -0
- data/lib/rdoc/method_attr.rb +419 -0
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +93 -0
- data/lib/rdoc/normal_module.rb +74 -0
- data/lib/rdoc/options.rb +1285 -0
- data/lib/rdoc/parser/c.rb +1225 -0
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +2327 -0
- data/lib/rdoc/parser/ruby_tools.rb +167 -0
- data/lib/rdoc/parser/simple.rb +61 -0
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +277 -0
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +579 -0
- data/lib/rdoc/require.rb +52 -0
- data/lib/rdoc/ri/driver.rb +1572 -0
- data/lib/rdoc/ri/formatter.rb +6 -0
- data/lib/rdoc/ri/paths.rb +171 -0
- data/lib/rdoc/ri/store.rb +7 -0
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +21 -0
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +26 -0
- data/lib/rdoc/stats/normal.rb +58 -0
- data/lib/rdoc/stats/quiet.rb +60 -0
- data/lib/rdoc/stats/verbose.rb +46 -0
- data/lib/rdoc/stats.rb +462 -0
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +329 -0
- data/lib/rdoc/text.rb +304 -0
- data/lib/rdoc/token_stream.rb +119 -0
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +289 -0
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +201 -0
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +279 -0
@@ -0,0 +1 @@
|
|
1
|
+
# ignore all files in this directory
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/*
|
2
|
+
* Navigation allows movement using the arrow keys through the search results.
|
3
|
+
*
|
4
|
+
* When using this library you will need to set scrollIntoView to the
|
5
|
+
* appropriate function for your layout. Use scrollInWindow if the container
|
6
|
+
* is not scrollable and scrollInElement if the container is a separate
|
7
|
+
* scrolling region.
|
8
|
+
*/
|
9
|
+
Navigation = new function() {
|
10
|
+
this.initNavigation = function() {
|
11
|
+
var _this = this;
|
12
|
+
|
13
|
+
document.addEventListener('keydown', function(e) {
|
14
|
+
_this.onkeydown(e);
|
15
|
+
});
|
16
|
+
|
17
|
+
this.navigationActive = true;
|
18
|
+
}
|
19
|
+
|
20
|
+
this.setNavigationActive = function(state) {
|
21
|
+
this.navigationActive = state;
|
22
|
+
}
|
23
|
+
|
24
|
+
this.onkeydown = function(e) {
|
25
|
+
if (!this.navigationActive) return;
|
26
|
+
switch(e.keyCode) {
|
27
|
+
case 37: //Event.KEY_LEFT:
|
28
|
+
if (this.moveLeft()) e.preventDefault();
|
29
|
+
break;
|
30
|
+
case 38: //Event.KEY_UP:
|
31
|
+
if (e.keyCode == 38 || e.ctrlKey) {
|
32
|
+
if (this.moveUp()) e.preventDefault();
|
33
|
+
}
|
34
|
+
break;
|
35
|
+
case 39: //Event.KEY_RIGHT:
|
36
|
+
if (this.moveRight()) e.preventDefault();
|
37
|
+
break;
|
38
|
+
case 40: //Event.KEY_DOWN:
|
39
|
+
if (e.keyCode == 40 || e.ctrlKey) {
|
40
|
+
if (this.moveDown()) e.preventDefault();
|
41
|
+
}
|
42
|
+
break;
|
43
|
+
case 13: //Event.KEY_RETURN:
|
44
|
+
if (this.current) e.preventDefault();
|
45
|
+
this.select(this.current);
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
if (e.ctrlKey && e.shiftKey) this.select(this.current);
|
49
|
+
}
|
50
|
+
|
51
|
+
this.moveRight = function() {
|
52
|
+
}
|
53
|
+
|
54
|
+
this.moveLeft = function() {
|
55
|
+
}
|
56
|
+
|
57
|
+
this.move = function(isDown) {
|
58
|
+
}
|
59
|
+
|
60
|
+
this.moveUp = function() {
|
61
|
+
return this.move(false);
|
62
|
+
}
|
63
|
+
|
64
|
+
this.moveDown = function() {
|
65
|
+
return this.move(true);
|
66
|
+
}
|
67
|
+
|
68
|
+
/*
|
69
|
+
* Scrolls to the given element in the scrollable element view.
|
70
|
+
*/
|
71
|
+
this.scrollInElement = function(element, view) {
|
72
|
+
var offset, viewHeight, viewScroll, height;
|
73
|
+
offset = element.offsetTop;
|
74
|
+
height = element.offsetHeight;
|
75
|
+
viewHeight = view.offsetHeight;
|
76
|
+
viewScroll = view.scrollTop;
|
77
|
+
|
78
|
+
if (offset - viewScroll + height > viewHeight) {
|
79
|
+
view.scrollTop = offset - viewHeight + height;
|
80
|
+
}
|
81
|
+
if (offset < viewScroll) {
|
82
|
+
view.scrollTop = offset;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
/*
|
87
|
+
* Scrolls to the given element in the window. The second argument is
|
88
|
+
* ignored
|
89
|
+
*/
|
90
|
+
this.scrollInWindow = function(element, ignored) {
|
91
|
+
var offset, viewHeight, viewScroll, height;
|
92
|
+
offset = element.offsetTop;
|
93
|
+
height = element.offsetHeight;
|
94
|
+
viewHeight = window.innerHeight;
|
95
|
+
viewScroll = window.scrollY;
|
96
|
+
|
97
|
+
if (offset - viewScroll + height > viewHeight) {
|
98
|
+
window.scrollTo(window.scrollX, offset - viewHeight + height);
|
99
|
+
}
|
100
|
+
if (offset < viewScroll) {
|
101
|
+
window.scrollTo(window.scrollX, offset);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
@@ -0,0 +1,229 @@
|
|
1
|
+
Searcher = function(data) {
|
2
|
+
this.data = data;
|
3
|
+
this.handlers = [];
|
4
|
+
}
|
5
|
+
|
6
|
+
Searcher.prototype = new function() {
|
7
|
+
// search is performed in chunks of 1000 for non-blocking user input
|
8
|
+
var CHUNK_SIZE = 1000;
|
9
|
+
// do not try to find more than 100 results
|
10
|
+
var MAX_RESULTS = 100;
|
11
|
+
var huid = 1;
|
12
|
+
var suid = 1;
|
13
|
+
var runs = 0;
|
14
|
+
|
15
|
+
this.find = function(query) {
|
16
|
+
var queries = splitQuery(query);
|
17
|
+
var regexps = buildRegexps(queries);
|
18
|
+
var highlighters = buildHilighters(queries);
|
19
|
+
var state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++};
|
20
|
+
var _this = this;
|
21
|
+
|
22
|
+
this.currentSuid = state.n;
|
23
|
+
|
24
|
+
if (!query) return;
|
25
|
+
|
26
|
+
var run = function() {
|
27
|
+
// stop current search thread if new search started
|
28
|
+
if (state.n != _this.currentSuid) return;
|
29
|
+
|
30
|
+
var results =
|
31
|
+
performSearch(_this.data, regexps, queries, highlighters, state);
|
32
|
+
var hasMore = (state.limit > 0 && state.pass < 4);
|
33
|
+
|
34
|
+
triggerResults.call(_this, results, !hasMore);
|
35
|
+
if (hasMore) {
|
36
|
+
setTimeout(run, 2);
|
37
|
+
}
|
38
|
+
runs++;
|
39
|
+
};
|
40
|
+
runs = 0;
|
41
|
+
|
42
|
+
// start search thread
|
43
|
+
run();
|
44
|
+
}
|
45
|
+
|
46
|
+
/* ----- Events ------ */
|
47
|
+
this.ready = function(fn) {
|
48
|
+
fn.huid = huid;
|
49
|
+
this.handlers.push(fn);
|
50
|
+
}
|
51
|
+
|
52
|
+
/* ----- Utilities ------ */
|
53
|
+
function splitQuery(query) {
|
54
|
+
return query.split(/(\s+|::?|\(\)?)/).filter(function(string) {
|
55
|
+
return string.match(/\S/);
|
56
|
+
});
|
57
|
+
}
|
58
|
+
|
59
|
+
function buildRegexps(queries) {
|
60
|
+
return queries.map(function(query) {
|
61
|
+
return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
|
62
|
+
});
|
63
|
+
}
|
64
|
+
|
65
|
+
function buildHilighters(queries) {
|
66
|
+
return queries.map(function(query) {
|
67
|
+
return query.split('').map(function(l, i) {
|
68
|
+
return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2);
|
69
|
+
}).join('');
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
// function longMatchRegexp(index, longIndex, regexps) {
|
74
|
+
// for (var i = regexps.length - 1; i >= 0; i--){
|
75
|
+
// if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
|
76
|
+
// };
|
77
|
+
// return true;
|
78
|
+
// }
|
79
|
+
|
80
|
+
|
81
|
+
/* ----- Mathchers ------ */
|
82
|
+
|
83
|
+
/*
|
84
|
+
* This record matches if the index starts with queries[0] and the record
|
85
|
+
* matches all of the regexps
|
86
|
+
*/
|
87
|
+
function matchPassBeginning(index, longIndex, queries, regexps) {
|
88
|
+
if (index.indexOf(queries[0]) != 0) return false;
|
89
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
90
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
91
|
+
return false;
|
92
|
+
};
|
93
|
+
return true;
|
94
|
+
}
|
95
|
+
|
96
|
+
/*
|
97
|
+
* This record matches if the longIndex starts with queries[0] and the
|
98
|
+
* longIndex matches all of the regexps
|
99
|
+
*/
|
100
|
+
function matchPassLongIndex(index, longIndex, queries, regexps) {
|
101
|
+
if (longIndex.indexOf(queries[0]) != 0) return false;
|
102
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
103
|
+
if (!longIndex.match(regexps[i]))
|
104
|
+
return false;
|
105
|
+
};
|
106
|
+
return true;
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
* This record matches if the index contains queries[0] and the record
|
111
|
+
* matches all of the regexps
|
112
|
+
*/
|
113
|
+
function matchPassContains(index, longIndex, queries, regexps) {
|
114
|
+
if (index.indexOf(queries[0]) == -1) return false;
|
115
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
116
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
117
|
+
return false;
|
118
|
+
};
|
119
|
+
return true;
|
120
|
+
}
|
121
|
+
|
122
|
+
/*
|
123
|
+
* This record matches if regexps[0] matches the index and the record
|
124
|
+
* matches all of the regexps
|
125
|
+
*/
|
126
|
+
function matchPassRegexp(index, longIndex, queries, regexps) {
|
127
|
+
if (!index.match(regexps[0])) return false;
|
128
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
129
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
|
130
|
+
return false;
|
131
|
+
};
|
132
|
+
return true;
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
/* ----- Highlighters ------ */
|
137
|
+
function highlightRegexp(info, queries, regexps, highlighters) {
|
138
|
+
var result = createResult(info);
|
139
|
+
for (var i=0, l = regexps.length; i < l; i++) {
|
140
|
+
result.title = result.title.replace(regexps[i], highlighters[i]);
|
141
|
+
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
142
|
+
};
|
143
|
+
return result;
|
144
|
+
}
|
145
|
+
|
146
|
+
function hltSubstring(string, pos, length) {
|
147
|
+
return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
|
148
|
+
}
|
149
|
+
|
150
|
+
function highlightQuery(info, queries, regexps, highlighters) {
|
151
|
+
var result = createResult(info);
|
152
|
+
var pos = 0;
|
153
|
+
var lcTitle = result.title.toLowerCase();
|
154
|
+
|
155
|
+
pos = lcTitle.indexOf(queries[0]);
|
156
|
+
if (pos != -1) {
|
157
|
+
result.title = hltSubstring(result.title, pos, queries[0].length);
|
158
|
+
}
|
159
|
+
|
160
|
+
result.namespace = result.namespace.replace(regexps[0], highlighters[0]);
|
161
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
162
|
+
result.title = result.title.replace(regexps[i], highlighters[i]);
|
163
|
+
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
164
|
+
};
|
165
|
+
return result;
|
166
|
+
}
|
167
|
+
|
168
|
+
function createResult(info) {
|
169
|
+
var result = {};
|
170
|
+
result.title = info[0];
|
171
|
+
result.namespace = info[1];
|
172
|
+
result.path = info[2];
|
173
|
+
result.params = info[3];
|
174
|
+
result.snippet = info[4];
|
175
|
+
result.badge = info[6];
|
176
|
+
return result;
|
177
|
+
}
|
178
|
+
|
179
|
+
/* ----- Searching ------ */
|
180
|
+
function performSearch(data, regexps, queries, highlighters, state) {
|
181
|
+
var searchIndex = data.searchIndex;
|
182
|
+
var longSearchIndex = data.longSearchIndex;
|
183
|
+
var info = data.info;
|
184
|
+
var result = [];
|
185
|
+
var i = state.from;
|
186
|
+
var l = searchIndex.length;
|
187
|
+
var togo = CHUNK_SIZE;
|
188
|
+
var matchFunc, hltFunc;
|
189
|
+
|
190
|
+
while (state.pass < 4 && state.limit > 0 && togo > 0) {
|
191
|
+
if (state.pass == 0) {
|
192
|
+
matchFunc = matchPassBeginning;
|
193
|
+
hltFunc = highlightQuery;
|
194
|
+
} else if (state.pass == 1) {
|
195
|
+
matchFunc = matchPassLongIndex;
|
196
|
+
hltFunc = highlightQuery;
|
197
|
+
} else if (state.pass == 2) {
|
198
|
+
matchFunc = matchPassContains;
|
199
|
+
hltFunc = highlightQuery;
|
200
|
+
} else if (state.pass == 3) {
|
201
|
+
matchFunc = matchPassRegexp;
|
202
|
+
hltFunc = highlightRegexp;
|
203
|
+
}
|
204
|
+
|
205
|
+
for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
|
206
|
+
if (info[i].n == state.n) continue;
|
207
|
+
if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
|
208
|
+
info[i].n = state.n;
|
209
|
+
result.push(hltFunc(info[i], queries, regexps, highlighters));
|
210
|
+
state.limit--;
|
211
|
+
}
|
212
|
+
};
|
213
|
+
if (searchIndex.length <= i) {
|
214
|
+
state.pass++;
|
215
|
+
i = state.from = 0;
|
216
|
+
} else {
|
217
|
+
state.from = i;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
return result;
|
221
|
+
}
|
222
|
+
|
223
|
+
function triggerResults(results, isLast) {
|
224
|
+
this.handlers.forEach(function(fn) {
|
225
|
+
fn.call(this, results, isLast)
|
226
|
+
});
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# RDoc uses generators to turn parsed source code in the form of an
|
4
|
+
# RDoc::CodeObject tree into some form of output. RDoc comes with the HTML
|
5
|
+
# generator RDoc::Generator::Darkfish and an ri data generator
|
6
|
+
# RDoc::Generator::RI.
|
7
|
+
#
|
8
|
+
# == Registering a Generator
|
9
|
+
#
|
10
|
+
# Generators are registered by calling RDoc::RDoc.add_generator with the class
|
11
|
+
# of the generator:
|
12
|
+
#
|
13
|
+
# class My::Awesome::Generator
|
14
|
+
# RDoc::RDoc.add_generator self
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# == Adding Options to +rdoc+
|
18
|
+
#
|
19
|
+
# Before option processing in +rdoc+, RDoc::Options will call ::setup_options
|
20
|
+
# on the generator class with an RDoc::Options instance. The generator can
|
21
|
+
# use RDoc::Options#option_parser to add command-line options to the +rdoc+
|
22
|
+
# tool. See RDoc::Options@Custom+Options for an example and see OptionParser
|
23
|
+
# for details on how to add options.
|
24
|
+
#
|
25
|
+
# You can extend the RDoc::Options instance with additional accessors for your
|
26
|
+
# generator.
|
27
|
+
#
|
28
|
+
# == Generator Instantiation
|
29
|
+
#
|
30
|
+
# After parsing, RDoc::RDoc will instantiate a generator by calling
|
31
|
+
# #initialize with an RDoc::Store instance and an RDoc::Options instance.
|
32
|
+
#
|
33
|
+
# The RDoc::Store instance holds documentation for parsed source code. In
|
34
|
+
# RDoc 3 and earlier the RDoc::TopLevel class held this data. When upgrading
|
35
|
+
# a generator from RDoc 3 and earlier you should only need to replace
|
36
|
+
# RDoc::TopLevel with the store instance.
|
37
|
+
#
|
38
|
+
# RDoc will then call #generate on the generator instance. You can use the
|
39
|
+
# various methods on RDoc::Store and in the RDoc::CodeObject tree to create
|
40
|
+
# your desired output format.
|
41
|
+
|
42
|
+
module RDoc::Generator
|
43
|
+
|
44
|
+
autoload :Markup, 'rdoc/generator/markup'
|
45
|
+
|
46
|
+
autoload :Darkfish, 'rdoc/generator/darkfish'
|
47
|
+
autoload :JsonIndex, 'rdoc/generator/json_index'
|
48
|
+
autoload :RI, 'rdoc/generator/ri'
|
49
|
+
autoload :POT, 'rdoc/generator/pot'
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# A message container for a locale.
|
4
|
+
#
|
5
|
+
# This object provides the following two features:
|
6
|
+
#
|
7
|
+
# * Loads translated messages from .po file.
|
8
|
+
# * Translates a message into the locale.
|
9
|
+
|
10
|
+
class RDoc::I18n::Locale
|
11
|
+
|
12
|
+
@@locales = {} # :nodoc:
|
13
|
+
|
14
|
+
class << self
|
15
|
+
|
16
|
+
##
|
17
|
+
# Returns the locale object for +locale_name+.
|
18
|
+
|
19
|
+
def [](locale_name)
|
20
|
+
@@locales[locale_name] ||= new(locale_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Sets the locale object for +locale_name+.
|
25
|
+
#
|
26
|
+
# Normally, this method is not used. This method is useful for
|
27
|
+
# testing.
|
28
|
+
|
29
|
+
def []=(locale_name, locale)
|
30
|
+
@@locales[locale_name] = locale
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# The name of the locale. It uses IETF language tag format
|
37
|
+
# +[language[_territory][.codeset][@modifier]]+.
|
38
|
+
#
|
39
|
+
# See also {BCP 47 - Tags for Identifying
|
40
|
+
# Languages}[http://tools.ietf.org/rfc/bcp/bcp47.txt].
|
41
|
+
|
42
|
+
attr_reader :name
|
43
|
+
|
44
|
+
##
|
45
|
+
# Creates a new locale object for +name+ locale. +name+ must
|
46
|
+
# follow IETF language tag format.
|
47
|
+
|
48
|
+
def initialize(name)
|
49
|
+
@name = name
|
50
|
+
@messages = {}
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Loads translation messages from +locale_directory+/+@name+/rdoc.po
|
55
|
+
# or +locale_directory+/+@name+.po. The former has high priority.
|
56
|
+
#
|
57
|
+
# This method requires gettext gem for parsing .po file. If you
|
58
|
+
# don't have gettext gem, this method doesn't load .po file. This
|
59
|
+
# method warns and returns +false+.
|
60
|
+
#
|
61
|
+
# Returns +true+ if succeeded, +false+ otherwise.
|
62
|
+
|
63
|
+
def load(locale_directory)
|
64
|
+
return false if @name.nil?
|
65
|
+
|
66
|
+
po_file_candidates = [
|
67
|
+
File.join(locale_directory, @name, 'rdoc.po'),
|
68
|
+
File.join(locale_directory, "#{@name}.po"),
|
69
|
+
]
|
70
|
+
po_file = po_file_candidates.find do |po_file_candidate|
|
71
|
+
File.exist?(po_file_candidate)
|
72
|
+
end
|
73
|
+
return false unless po_file
|
74
|
+
|
75
|
+
begin
|
76
|
+
require 'gettext/po_parser'
|
77
|
+
require 'gettext/mo'
|
78
|
+
rescue LoadError
|
79
|
+
warn('Need gettext gem for i18n feature:')
|
80
|
+
warn(' gem install gettext')
|
81
|
+
return false
|
82
|
+
end
|
83
|
+
|
84
|
+
po_parser = GetText::POParser.new
|
85
|
+
messages = GetText::MO.new
|
86
|
+
po_parser.report_warning = false
|
87
|
+
po_parser.parse_file(po_file, messages)
|
88
|
+
|
89
|
+
@messages.merge!(messages)
|
90
|
+
|
91
|
+
true
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Translates the +message+ into locale. If there is no translation
|
96
|
+
# messages for +message+ in locale, +message+ itself is returned.
|
97
|
+
|
98
|
+
def translate(message)
|
99
|
+
@messages[message] || message
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|