rdoc 3.1 → 6.3.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- 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 +129 -0
- data/RI.rdoc +57 -0
- data/Rakefile +84 -81
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/{bin → exe}/rdoc +11 -2
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +1 -2
- data/lib/rdoc/anon_class.rb +3 -2
- data/lib/rdoc/any_method.rb +234 -40
- data/lib/rdoc/attr.rb +79 -11
- data/lib/rdoc/class_module.rb +443 -71
- data/lib/rdoc/code_object.rb +216 -20
- data/lib/rdoc/code_objects.rb +4 -21
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +110 -9
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +392 -172
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +83 -28
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +8 -3
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +507 -84
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +27 -74
- 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 +8 -62
- 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/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
- 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 +24 -13
- data/lib/rdoc/ghost_method.rb +1 -2
- 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 +5 -95
- data/lib/rdoc/known_classes.rb +5 -2
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +416 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16684 -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 +135 -62
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +1 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +96 -9
- data/lib/rdoc/markup/formatter.rb +138 -25
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +61 -2
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +25 -4
- data/lib/rdoc/markup/list_item.rb +18 -4
- data/lib/rdoc/markup/paragraph.rb +15 -0
- data/lib/rdoc/markup/parser.rb +180 -88
- data/lib/rdoc/markup/pre_process.rb +183 -38
- data/lib/rdoc/markup/raw.rb +6 -5
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +17 -7
- data/lib/rdoc/markup/to_bs.rb +5 -8
- data/lib/rdoc/markup/to_html.rb +238 -137
- data/lib/rdoc/markup/to_html_crossref.rb +125 -152
- 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 +85 -15
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +2 -4
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +39 -0
- data/lib/rdoc/markup.rb +388 -110
- data/lib/rdoc/meta_method.rb +1 -2
- data/lib/rdoc/method_attr.rb +87 -21
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +39 -10
- data/lib/rdoc/normal_module.rb +22 -7
- data/lib/rdoc/options.rb +613 -73
- data/lib/rdoc/parser/c.rb +621 -287
- 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 +1368 -762
- data/lib/rdoc/parser/ruby_tools.rb +42 -35
- data/lib/rdoc/parser/simple.rb +23 -11
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +162 -89
- 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 +208 -115
- data/lib/rdoc/require.rb +1 -2
- data/lib/rdoc/ri/driver.rb +734 -239
- data/lib/rdoc/ri/formatter.rb +1 -0
- data/lib/rdoc/ri/paths.rb +91 -48
- data/lib/rdoc/ri/store.rb +3 -261
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +5 -2
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +14 -2
- data/lib/rdoc/stats/normal.rb +19 -12
- data/lib/rdoc/stats/quiet.rb +1 -0
- data/lib/rdoc/stats/verbose.rb +1 -0
- data/lib/rdoc/stats.rb +262 -104
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +84 -44
- data/lib/rdoc/text.rb +117 -72
- data/lib/rdoc/token_stream.rb +73 -4
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +111 -261
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +127 -64
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +171 -291
- data/.autotest +0 -16
- data/.document +0 -5
- data/History.txt +0 -594
- data/LICENSE.txt +0 -57
- data/Manifest.txt +0 -158
- data/README.txt +0 -45
- data/RI.txt +0 -58
- data/bin/ri +0 -5
- data/lib/rdoc/gauntlet.rb +0 -52
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
- data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
- data/lib/rdoc/markup/formatter_test_case.rb +0 -689
- data/lib/rdoc/markup/inline.rb +0 -137
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
- data/lib/rdoc/ruby_lex.rb +0 -1291
- data/lib/rdoc/ruby_token.rb +0 -416
- data/test/README +0 -1
- data/test/binary.dat +0 -0
- data/test/hidden.zip.txt +0 -1
- data/test/test.ja.rdoc +0 -10
- data/test/test.ja.txt +0 -8
- data/test/test.txt +0 -1
- data/test/test_attribute_manager.rb +0 -120
- data/test/test_rdoc_alias.rb +0 -13
- data/test/test_rdoc_any_method.rb +0 -126
- data/test/test_rdoc_attr.rb +0 -61
- data/test/test_rdoc_class_module.rb +0 -233
- data/test/test_rdoc_code_object.rb +0 -165
- data/test/test_rdoc_constant.rb +0 -15
- data/test/test_rdoc_context.rb +0 -370
- data/test/test_rdoc_encoding.rb +0 -166
- data/test/test_rdoc_generator_darkfish.rb +0 -119
- data/test/test_rdoc_generator_ri.rb +0 -76
- data/test/test_rdoc_include.rb +0 -96
- data/test/test_rdoc_markup.rb +0 -37
- data/test/test_rdoc_markup_attribute_manager.rb +0 -240
- data/test/test_rdoc_markup_document.rb +0 -51
- data/test/test_rdoc_markup_paragraph.rb +0 -9
- data/test/test_rdoc_markup_parser.rb +0 -1395
- data/test/test_rdoc_markup_pre_process.rb +0 -185
- data/test/test_rdoc_markup_raw.rb +0 -27
- data/test/test_rdoc_markup_to_ansi.rb +0 -328
- data/test/test_rdoc_markup_to_bs.rb +0 -341
- data/test/test_rdoc_markup_to_html.rb +0 -335
- data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
- data/test/test_rdoc_markup_to_rdoc.rb +0 -327
- data/test/test_rdoc_method_attr.rb +0 -122
- data/test/test_rdoc_normal_class.rb +0 -17
- data/test/test_rdoc_normal_module.rb +0 -31
- data/test/test_rdoc_options.rb +0 -342
- data/test/test_rdoc_parser.rb +0 -83
- data/test/test_rdoc_parser_c.rb +0 -912
- data/test/test_rdoc_parser_ruby.rb +0 -1754
- data/test/test_rdoc_parser_simple.rb +0 -99
- data/test/test_rdoc_rdoc.rb +0 -164
- data/test/test_rdoc_require.rb +0 -25
- data/test/test_rdoc_ri_driver.rb +0 -846
- data/test/test_rdoc_ri_paths.rb +0 -43
- data/test/test_rdoc_ri_store.rb +0 -352
- data/test/test_rdoc_ruby_lex.rb +0 -23
- data/test/test_rdoc_stats.rb +0 -38
- data/test/test_rdoc_task.rb +0 -92
- data/test/test_rdoc_text.rb +0 -251
- data/test/test_rdoc_top_level.rb +0 -120
- data/test/xref_data.rb +0 -62
- data/test/xref_test_case.rb +0 -61
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
@@ -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
|
+
|
data/lib/rdoc/generator.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
3
2
|
##
|
4
3
|
# RDoc uses generators to turn parsed source code in the form of an
|
5
4
|
# RDoc::CodeObject tree into some form of output. RDoc comes with the HTML
|
6
5
|
# generator RDoc::Generator::Darkfish and an ri data generator
|
7
6
|
# RDoc::Generator::RI.
|
8
7
|
#
|
9
|
-
#
|
8
|
+
# == Registering a Generator
|
10
9
|
#
|
11
10
|
# Generators are registered by calling RDoc::RDoc.add_generator with the class
|
12
11
|
# of the generator:
|
@@ -15,26 +14,38 @@ require 'rdoc'
|
|
15
14
|
# RDoc::RDoc.add_generator self
|
16
15
|
# end
|
17
16
|
#
|
18
|
-
#
|
17
|
+
# == Adding Options to +rdoc+
|
19
18
|
#
|
20
19
|
# Before option processing in +rdoc+, RDoc::Options will call ::setup_options
|
21
20
|
# on the generator class with an RDoc::Options instance. The generator can
|
22
21
|
# use RDoc::Options#option_parser to add command-line options to the +rdoc+
|
23
|
-
# tool. See
|
22
|
+
# tool. See RDoc::Options@Custom+Options for an example and see OptionParser
|
23
|
+
# for details on how to add options.
|
24
24
|
#
|
25
|
-
# You can extend the RDoc::Options instance with additional
|
25
|
+
# You can extend the RDoc::Options instance with additional accessors for your
|
26
26
|
# generator.
|
27
27
|
#
|
28
|
-
#
|
28
|
+
# == Generator Instantiation
|
29
29
|
#
|
30
30
|
# After parsing, RDoc::RDoc will instantiate a generator by calling
|
31
|
-
# #initialize with an RDoc::Options instance.
|
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.
|
32
37
|
#
|
33
|
-
# RDoc will then call #generate on the generator instance
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# to create your desired output format.
|
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.
|
37
41
|
|
38
42
|
module RDoc::Generator
|
39
|
-
end
|
40
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
|
data/lib/rdoc/ghost_method.rb
CHANGED
@@ -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
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
##
|
3
|
+
# An i18n supported text.
|
4
|
+
#
|
5
|
+
# This object provides the following two features:
|
6
|
+
#
|
7
|
+
# * Extracts translation messages from wrapped raw text.
|
8
|
+
# * Translates wrapped raw text in specified locale.
|
9
|
+
#
|
10
|
+
# Wrapped raw text is one of String, RDoc::Comment or Array of them.
|
11
|
+
|
12
|
+
class RDoc::I18n::Text
|
13
|
+
|
14
|
+
##
|
15
|
+
# Creates a new i18n supported text for +raw+ text.
|
16
|
+
|
17
|
+
def initialize(raw)
|
18
|
+
@raw = raw
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Extracts translation target messages and yields each message.
|
23
|
+
#
|
24
|
+
# Each yielded message is a Hash. It consists of the followings:
|
25
|
+
#
|
26
|
+
# :type :: :paragraph
|
27
|
+
# :paragraph :: String (The translation target message itself.)
|
28
|
+
# :line_no :: Integer (The line number of the :paragraph is started.)
|
29
|
+
#
|
30
|
+
# The above content may be added in the future.
|
31
|
+
|
32
|
+
def extract_messages
|
33
|
+
parse do |part|
|
34
|
+
case part[:type]
|
35
|
+
when :empty_line
|
36
|
+
# ignore
|
37
|
+
when :paragraph
|
38
|
+
yield(part)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Translates raw text into +locale+.
|
44
|
+
def translate(locale)
|
45
|
+
translated_text = ''
|
46
|
+
parse do |part|
|
47
|
+
case part[:type]
|
48
|
+
when :paragraph
|
49
|
+
translated_text += locale.translate(part[:paragraph])
|
50
|
+
when :empty_line
|
51
|
+
translated_text += part[:line]
|
52
|
+
else
|
53
|
+
raise "should not reach here: unexpected type: #{type}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
translated_text
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def parse(&block)
|
61
|
+
paragraph = ''
|
62
|
+
paragraph_start_line = 0
|
63
|
+
line_no = 0
|
64
|
+
|
65
|
+
each_line(@raw) do |line|
|
66
|
+
line_no += 1
|
67
|
+
case line
|
68
|
+
when /\A\s*\z/
|
69
|
+
if paragraph.empty?
|
70
|
+
emit_empty_line_event(line, line_no, &block)
|
71
|
+
else
|
72
|
+
paragraph += line
|
73
|
+
emit_paragraph_event(paragraph, paragraph_start_line, line_no,
|
74
|
+
&block)
|
75
|
+
paragraph = ''
|
76
|
+
end
|
77
|
+
else
|
78
|
+
paragraph_start_line = line_no if paragraph.empty?
|
79
|
+
paragraph += line
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
unless paragraph.empty?
|
84
|
+
emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def each_line(raw, &block)
|
89
|
+
case raw
|
90
|
+
when RDoc::Comment
|
91
|
+
raw.text.each_line(&block)
|
92
|
+
when Array
|
93
|
+
raw.each do |comment, location|
|
94
|
+
each_line(comment, &block)
|
95
|
+
end
|
96
|
+
else
|
97
|
+
raw.each_line(&block)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def emit_empty_line_event(line, line_no)
|
102
|
+
part = {
|
103
|
+
:type => :empty_line,
|
104
|
+
:line => line,
|
105
|
+
:line_no => line_no,
|
106
|
+
}
|
107
|
+
yield(part)
|
108
|
+
end
|
109
|
+
|
110
|
+
def emit_paragraph_event(paragraph, paragraph_start_line, line_no, &block)
|
111
|
+
paragraph_part = {
|
112
|
+
:type => :paragraph,
|
113
|
+
:line_no => paragraph_start_line,
|
114
|
+
}
|
115
|
+
match_data = /(\s*)\z/.match(paragraph)
|
116
|
+
if match_data
|
117
|
+
paragraph_part[:paragraph] = match_data.pre_match
|
118
|
+
yield(paragraph_part)
|
119
|
+
emit_empty_line_event(match_data[1], line_no, &block)
|
120
|
+
else
|
121
|
+
paragraph_part[:paragraph] = paragraph
|
122
|
+
yield(paragraph_part)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
data/lib/rdoc/i18n.rb
ADDED
data/lib/rdoc/include.rb
CHANGED
@@ -1,100 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
3
2
|
##
|
4
|
-
# A Module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
##
|
9
|
-
# Name of included module
|
10
|
-
|
11
|
-
attr_accessor :name
|
12
|
-
|
13
|
-
##
|
14
|
-
# Creates a new Include for +name+ with +comment+
|
15
|
-
|
16
|
-
def initialize(name, comment)
|
17
|
-
super()
|
18
|
-
@name = name
|
19
|
-
self.comment = comment
|
20
|
-
@module = nil # cache for module if found
|
21
|
-
end
|
22
|
-
|
23
|
-
##
|
24
|
-
# Includes are sorted by name
|
25
|
-
|
26
|
-
def <=> other
|
27
|
-
return unless self.class === other
|
28
|
-
|
29
|
-
name <=> other.name
|
30
|
-
end
|
31
|
-
|
32
|
-
def == other # :nodoc:
|
33
|
-
self.class == other.class and
|
34
|
-
self.name == other.name
|
35
|
-
end
|
36
|
-
|
37
|
-
##
|
38
|
-
# Full name based on #module
|
39
|
-
|
40
|
-
def full_name
|
41
|
-
m = self.module
|
42
|
-
RDoc::ClassModule === m ? m.full_name : @name
|
43
|
-
end
|
44
|
-
|
45
|
-
def inspect # :nodoc:
|
46
|
-
"#<%s:0x%x %s.include %s>" % [
|
47
|
-
self.class,
|
48
|
-
object_id,
|
49
|
-
parent_name, @name,
|
50
|
-
]
|
51
|
-
end
|
52
|
-
|
53
|
-
##
|
54
|
-
# Attempts to locate the included module object. Returns the name if not
|
55
|
-
# known.
|
56
|
-
#
|
57
|
-
# The scoping rules of Ruby to resolve the name of an included module are:
|
58
|
-
# - first look into the children of the current context;
|
59
|
-
# - if not found, look into the children of included modules,
|
60
|
-
# in reverse inclusion order;
|
61
|
-
# - if still not found, go up the hierarchy of names.
|
62
|
-
|
63
|
-
def module
|
64
|
-
return @module if @module
|
65
|
-
|
66
|
-
# search the current context
|
67
|
-
return @name unless parent
|
68
|
-
full_name = parent.child_name(@name)
|
69
|
-
@module = RDoc::TopLevel.modules_hash[full_name]
|
70
|
-
return @module if @module
|
71
|
-
return @name if @name =~ /^::/
|
72
|
-
|
73
|
-
# search the includes before this one, in reverse order
|
74
|
-
searched = parent.includes.take_while { |i| i != self }.reverse
|
75
|
-
searched.each do |i|
|
76
|
-
inc = i.module
|
77
|
-
next if String === inc
|
78
|
-
full_name = inc.child_name(@name)
|
79
|
-
@module = RDoc::TopLevel.modules_hash[full_name]
|
80
|
-
return @module if @module
|
81
|
-
end
|
82
|
-
|
83
|
-
# go up the hierarchy of names
|
84
|
-
p = parent.parent
|
85
|
-
while p
|
86
|
-
full_name = p.child_name(@name)
|
87
|
-
@module = RDoc::TopLevel.modules_hash[full_name]
|
88
|
-
return @module if @module
|
89
|
-
p = p.parent
|
90
|
-
end
|
91
|
-
|
92
|
-
@name
|
93
|
-
end
|
3
|
+
# A Module included in a class with \#include
|
4
|
+
#
|
5
|
+
# RDoc::Include.new 'Enumerable', 'comment ...'
|
94
6
|
|
95
|
-
|
96
|
-
"include #@name in: #{parent}"
|
97
|
-
end
|
7
|
+
class RDoc::Include < RDoc::Mixin
|
98
8
|
|
99
9
|
end
|
100
10
|
|
data/lib/rdoc/known_classes.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module RDoc
|
2
3
|
|
3
4
|
##
|
@@ -26,6 +27,7 @@ module RDoc
|
|
26
27
|
"rb_cRange" => "Range",
|
27
28
|
"rb_cRegexp" => "Regexp",
|
28
29
|
"rb_cRubyVM" => "RubyVM",
|
30
|
+
"rb_cSocket" => "Socket",
|
29
31
|
"rb_cString" => "String",
|
30
32
|
"rb_cStruct" => "Struct",
|
31
33
|
"rb_cSymbol" => "Symbol",
|
@@ -36,7 +38,7 @@ module RDoc
|
|
36
38
|
"rb_eArgError" => "ArgError",
|
37
39
|
"rb_eEOFError" => "EOFError",
|
38
40
|
"rb_eException" => "Exception",
|
39
|
-
"rb_eFatal" => "
|
41
|
+
"rb_eFatal" => "fatal",
|
40
42
|
"rb_eFloatDomainError" => "FloatDomainError",
|
41
43
|
"rb_eIOError" => "IOError",
|
42
44
|
"rb_eIndexError" => "IndexError",
|
@@ -49,7 +51,7 @@ module RDoc
|
|
49
51
|
"rb_eRuntimeError" => "RuntimeError",
|
50
52
|
"rb_eScriptError" => "ScriptError",
|
51
53
|
"rb_eSecurityError" => "SecurityError",
|
52
|
-
"rb_eSignal" => "
|
54
|
+
"rb_eSignal" => "SignalException",
|
53
55
|
"rb_eStandardError" => "StandardError",
|
54
56
|
"rb_eSyntaxError" => "SyntaxError",
|
55
57
|
"rb_eSystemCallError" => "SystemCallError",
|
@@ -60,6 +62,7 @@ module RDoc
|
|
60
62
|
"rb_mComparable" => "Comparable",
|
61
63
|
"rb_mEnumerable" => "Enumerable",
|
62
64
|
"rb_mErrno" => "Errno",
|
65
|
+
"rb_mFConst" => "File::Constants",
|
63
66
|
"rb_mFileTest" => "FileTest",
|
64
67
|
"rb_mGC" => "GC",
|
65
68
|
"rb_mKernel" => "Kernel",
|