rdoc 6.14.2 → 6.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +1 -1
  3. data/README.md +112 -0
  4. data/RI.md +1 -1
  5. data/lib/rdoc/code_object/top_level.rb +18 -25
  6. data/lib/rdoc/comment.rb +190 -8
  7. data/lib/rdoc/cross_reference.rb +1 -1
  8. data/lib/rdoc/generator/aliki.rb +42 -0
  9. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  10. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  11. data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
  12. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  13. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +6 -0
  14. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +5 -0
  15. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +15 -0
  16. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +15 -0
  17. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  18. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +21 -0
  19. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +37 -0
  20. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  21. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +11 -0
  22. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  23. data/lib/rdoc/generator/template/aliki/class.rhtml +219 -0
  24. data/lib/rdoc/generator/template/aliki/css/rdoc.css +1612 -0
  25. data/lib/rdoc/generator/template/aliki/index.rhtml +21 -0
  26. data/lib/rdoc/generator/template/aliki/js/aliki.js +483 -0
  27. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  28. data/lib/rdoc/generator/template/aliki/js/search.js +120 -0
  29. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  30. data/lib/rdoc/generator/template/aliki/page.rhtml +17 -0
  31. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  32. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  33. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  34. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -19
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +19 -19
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
  44. data/lib/rdoc/generator/template/darkfish/class.rhtml +62 -60
  45. data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
  46. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +21 -1
  47. data/lib/rdoc/generator/template/darkfish/js/search.js +11 -1
  48. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
  49. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
  50. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
  51. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
  52. data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
  53. data/lib/rdoc/generator.rb +1 -0
  54. data/lib/rdoc/markdown.kpeg +28 -17
  55. data/lib/rdoc/markdown.rb +365 -544
  56. data/lib/rdoc/markup/pre_process.rb +34 -10
  57. data/lib/rdoc/markup/to_html.rb +162 -14
  58. data/lib/rdoc/markup/to_html_crossref.rb +53 -23
  59. data/lib/rdoc/options.rb +22 -11
  60. data/lib/rdoc/parser/c.rb +15 -46
  61. data/lib/rdoc/parser/prism_ruby.rb +121 -113
  62. data/lib/rdoc/parser/ruby.rb +8 -8
  63. data/lib/rdoc/parser/ruby_tools.rb +5 -7
  64. data/lib/rdoc/parser/simple.rb +4 -21
  65. data/lib/rdoc/rdoc.rb +1 -0
  66. data/lib/rdoc/ri/task.rb +2 -2
  67. data/lib/rdoc/store.rb +2 -2
  68. data/lib/rdoc/task.rb +4 -4
  69. data/lib/rdoc/text.rb +1 -1
  70. data/lib/rdoc/token_stream.rb +13 -1
  71. data/lib/rdoc/tom_doc.rb +1 -1
  72. data/lib/rdoc/version.rb +1 -1
  73. data/rdoc.gemspec +3 -2
  74. metadata +44 -5
  75. data/README.rdoc +0 -144
@@ -20,46 +20,46 @@
20
20
  <h1>Local RDoc Documentation</h1>
21
21
 
22
22
  <p>Here you can browse local documentation from the ruby standard library and
23
- your installed gems.
23
+ your installed gems.</p>
24
24
 
25
- <%- extra_dirs = installed.select { |_, _, _, type,| type == :extra } -%>
26
- <%- unless extra_dirs.empty? -%>
25
+ <%- extra_dirs = installed.select { |_, _, _, type,| type == :extra } %>
26
+ <%- unless extra_dirs.empty? %>
27
27
  <h2>Extra Documentation Directories</h2>
28
28
 
29
29
  <p>The following additional documentation directories are available:</p>
30
30
 
31
31
  <ol>
32
- <%- extra_dirs.each do |name, href, exists, _, path| -%>
32
+ <%- extra_dirs.each do |name, href, exists, _, path| %>
33
33
  <li>
34
- <%- if exists -%>
34
+ <%- if exists %>
35
35
  <a href="<%= href %>"><%= h name %></a> (<%= h path %>)
36
- <%- else -%>
36
+ <%- else %>
37
37
  <%= h name %> (<%= h path %>; <i>not available</i>)
38
- <%- end -%>
38
+ <%- end %>
39
39
  </li>
40
- <%- end -%>
40
+ <%- end %>
41
41
  </ol>
42
- <%- end -%>
42
+ <%- end %>
43
43
 
44
- <%- gems = installed.select { |_, _, _, type,| type == :gem } -%>
45
- <%- missing = gems.reject { |_, _, exists,| exists } -%>
46
- <%- unless missing.empty? then -%>
44
+ <%- gems = installed.select { |_, _, _, type,| type == :gem } %>
45
+ <%- missing = gems.reject { |_, _, exists,| exists } %>
46
+ <%- unless missing.empty? %>
47
47
  <h2>Missing Gem Documentation</h2>
48
48
 
49
49
  <p>You are missing documentation for some of your installed gems.
50
50
  You can install missing documentation for gems by running
51
51
  <kbd>gem rdoc --all</kbd>. After installing the missing documentation you
52
52
  only need to reload this page. The newly created documentation will
53
- automatically appear.
53
+ automatically appear.</p>
54
54
 
55
55
  <p>You can also install documentation for a specific gem by running one of
56
- the following commands.
56
+ the following commands.</p>
57
57
 
58
58
  <ul>
59
- <%- names = missing.map { |name,| name.sub(/-([^-]*)$/, '') }.uniq -%>
60
- <%- names.each do |name| -%>
61
- <li><kbd>gem rdoc <%=h name %></kbd>
62
- <%- end -%>
59
+ <%- missing.map { |name,| name.sub(/-([^-]*)$/, '') }.uniq.each do |name| %>
60
+ <li><kbd>gem rdoc <%= h name %></kbd></li>
61
+ <%- end %>
63
62
  </ul>
64
- <%- end -%>
63
+ <%- end %>
65
64
  </main>
65
+ </body>
@@ -13,11 +13,11 @@
13
13
  <main role="main">
14
14
  <h1 class="class"><%= h @title %></h1>
15
15
 
16
- <%- simple_files = @files.select { |f| f.text? } -%>
17
- <%- unless simple_files.empty? then -%>
16
+ <%- simple_files = @files.select { |f| f.text? } %>
17
+ <%- unless simple_files.empty? then %>
18
18
  <h2 id="pages">Pages</h2>
19
19
  <ul>
20
- <%- simple_files.sort.each do |file| -%>
20
+ <%- simple_files.sort.each do |file| %>
21
21
  <li class="file">
22
22
  <a href="<%= h file.path %>"><%= h file.page_name %></a>
23
23
  <%
@@ -25,19 +25,19 @@
25
25
  table = file.parse(file.comment).table_of_contents
26
26
  unless table.empty? then %>
27
27
  <ul>
28
- <%- table.each do |heading| -%>
29
- <li><a href="<%= h file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a>
30
- <%- end -%>
28
+ <%- table.each do |heading| %>
29
+ <li><a href="<%= h file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a></li>
30
+ <%- end %>
31
31
  </ul>
32
- <%- end -%>
32
+ <%- end %>
33
33
  </li>
34
- <%- end -%>
34
+ <%- end %>
35
35
  </ul>
36
- <%- end -%>
36
+ <%- end %>
37
37
 
38
38
  <h2 id="classes">Classes and Modules</h2>
39
39
  <ul>
40
- <%- @modsort.each do |klass| -%>
40
+ <%- @modsort.each do |klass| %>
41
41
  <li class="<%= klass.type %>">
42
42
  <a href="<%= klass.path %>"><%= klass.full_name %></a>
43
43
  <%- table = []
@@ -46,14 +46,14 @@
46
46
 
47
47
  unless table.empty? then %>
48
48
  <ul>
49
- <%- table.each do |item| -%>
50
- <%- label = item.respond_to?(:label) ? item.label(klass) : item.aref -%>
51
- <li><a href="<%= klass.path %>#<%= label %>"><%= item.plain_html %></a>
52
- <%- end -%>
49
+ <%- table.each do |item| %>
50
+ <%- label = item.respond_to?(:label) ? item.label(klass) : item.aref %>
51
+ <li><a href="<%= klass.path %>#<%= label %>"><%= item.plain_html %></a></li>
52
+ <%- end %>
53
53
  </ul>
54
- <%- end -%>
54
+ <%- end %>
55
55
  </li>
56
- <%- end -%>
56
+ <%- end %>
57
57
  </ul>
58
58
 
59
59
  <h2 id="methods">Methods</h2>
@@ -65,6 +65,8 @@
65
65
  <a href="<%= method.path %>"><%= h method.pretty_name %></a>
66
66
  &mdash;
67
67
  <span class="container"><%= method.parent.full_name %></span>
68
- <%- end -%>
68
+ </li>
69
+ <%- end %>
69
70
  </ul>
70
71
  </main>
72
+ </body>
@@ -29,7 +29,7 @@ Searcher.prototype = new function() {
29
29
 
30
30
  var results =
31
31
  performSearch(_this.data, regexps, queries, highlighters, state);
32
- var hasMore = (state.limit > 0 && state.pass < 4);
32
+ var hasMore = (state.limit > 0 && state.pass < 6);
33
33
 
34
34
  triggerResults.call(_this, results, !hasMore);
35
35
  if (hasMore) {
@@ -57,8 +57,17 @@ Searcher.prototype = new function() {
57
57
  }
58
58
 
59
59
  function buildRegexps(queries) {
60
+ // A small minority of older browsers don't have RegExp.escape
61
+ // but it's not worth including a complex polyfill.
62
+ var escape = RegExp.escape || function(s) { return s };
63
+
60
64
  return queries.map(function(query) {
61
- return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i');
65
+ var pattern = [];
66
+ for (var i = 0; i < query.length; i++) {
67
+ var char = escape(query[i]);
68
+ pattern.push('([' + char + '])([^' + char + ']*?)');
69
+ }
70
+ return new RegExp(pattern.join(''), 'i');
62
71
  });
63
72
  }
64
73
 
@@ -80,6 +89,30 @@ Searcher.prototype = new function() {
80
89
 
81
90
  /* ----- Mathchers ------ */
82
91
 
92
+ /*
93
+ * This record matches if both the index and longIndex exactly equal queries[0]
94
+ * and the record matches all of the regexps. This ensures top-level exact matches
95
+ * like "String" are prioritized over nested classes like "Gem::Module::String".
96
+ */
97
+ function matchPassExact(index, longIndex, queries) {
98
+ return index == queries[0] && longIndex == queries[0];
99
+ }
100
+
101
+ /*
102
+ * This record matches if the index without "()" exactly equals queries[0].
103
+ * This prioritizes methods like "attribute()" when searching for "attribute".
104
+ */
105
+ function matchPassExactMethod(index, longIndex, queries, regexps) {
106
+ var indexWithoutParens = index.replace(/\(\)$/, '');
107
+ if (indexWithoutParens != queries[0]) return false;
108
+ if (index === indexWithoutParens) return false; // Not a method (no parens to remove)
109
+ for (var i=1, l = regexps.length; i < l; i++) {
110
+ if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
111
+ return false;
112
+ };
113
+ return true;
114
+ }
115
+
83
116
  /*
84
117
  * This record matches if the index starts with queries[0] and the record
85
118
  * matches all of the regexps
@@ -187,17 +220,26 @@ Searcher.prototype = new function() {
187
220
  var togo = CHUNK_SIZE;
188
221
  var matchFunc, hltFunc;
189
222
 
190
- while (state.pass < 4 && state.limit > 0 && togo > 0) {
223
+ var isLowercaseQuery = queries[0] === queries[0].toLowerCase();
224
+
225
+ while (state.pass < 6 && state.limit > 0 && togo > 0) {
226
+ // When query is lowercase, prioritize methods over classes
191
227
  if (state.pass == 0) {
192
- matchFunc = matchPassBeginning;
228
+ matchFunc = isLowercaseQuery ? matchPassExactMethod : matchPassExact;
193
229
  hltFunc = highlightQuery;
194
230
  } else if (state.pass == 1) {
195
- matchFunc = matchPassLongIndex;
231
+ matchFunc = isLowercaseQuery ? matchPassExact : matchPassExactMethod;
196
232
  hltFunc = highlightQuery;
197
233
  } else if (state.pass == 2) {
198
- matchFunc = matchPassContains;
234
+ matchFunc = matchPassBeginning;
199
235
  hltFunc = highlightQuery;
200
236
  } else if (state.pass == 3) {
237
+ matchFunc = matchPassLongIndex;
238
+ hltFunc = highlightQuery;
239
+ } else if (state.pass == 4) {
240
+ matchFunc = matchPassContains;
241
+ hltFunc = highlightQuery;
242
+ } else if (state.pass == 5) {
201
243
  matchFunc = matchPassRegexp;
202
244
  hltFunc = highlightRegexp;
203
245
  }
@@ -43,6 +43,7 @@ module RDoc::Generator
43
43
 
44
44
  autoload :Markup, "#{__dir__}/generator/markup"
45
45
 
46
+ autoload :Aliki, "#{__dir__}/generator/aliki"
46
47
  autoload :Darkfish, "#{__dir__}/generator/darkfish"
47
48
  autoload :JsonIndex, "#{__dir__}/generator/json_index"
48
49
  autoload :RI, "#{__dir__}/generator/ri"
@@ -497,6 +497,17 @@
497
497
  end
498
498
  end
499
499
 
500
+ ##
501
+ # Wraps `text` in code markup for rdoc inline formatting
502
+
503
+ def code text
504
+ # trim even spaces
505
+ text = $2 while /\A( +|\t+)(.*)\1\z/ =~ text
506
+ # escape unescaped backslash at the end
507
+ backslash_at_end = "\\" if /(?<!\\)(?:\\\\)*\\\z/.match?(text)
508
+ "<code>#{text}#{backslash_at_end}</code>"
509
+ end
510
+
500
511
  ##
501
512
  # Parses inline markdown in table cells
502
513
 
@@ -1104,32 +1115,32 @@ Ticks3 = "```" !"`"
1104
1115
  Ticks4 = "````" !"`"
1105
1116
  Ticks5 = "`````" !"`"
1106
1117
 
1107
- Code = ( Ticks1 @Sp < (
1118
+ Code = ( Ticks1 < (
1108
1119
  ( !"`" Nonspacechar )+ | !Ticks1 /`+/ |
1109
- !( @Sp Ticks1 ) ( @Spacechar | @Newline !@BlankLine )
1110
- )+ > @Sp Ticks1 |
1111
- Ticks2 @Sp < (
1120
+ !Ticks1 ( @Spacechar | @Newline !@BlankLine )
1121
+ )+ > Ticks1 |
1122
+ Ticks2 < (
1112
1123
  ( !"`" Nonspacechar )+ |
1113
1124
  !Ticks2 /`+/ |
1114
- !( @Sp Ticks2 ) ( @Spacechar | @Newline !@BlankLine )
1115
- )+ > @Sp Ticks2 |
1116
- Ticks3 @Sp < (
1125
+ !Ticks2 ( @Spacechar | @Newline !@BlankLine )
1126
+ )+ > Ticks2 |
1127
+ Ticks3 < (
1117
1128
  ( !"`" Nonspacechar )+ |
1118
1129
  !Ticks3 /`+/ |
1119
- !( @Sp Ticks3 ) ( @Spacechar | @Newline !@BlankLine )
1120
- )+ > @Sp Ticks3 |
1121
- Ticks4 @Sp < (
1130
+ !Ticks3 ( @Spacechar | @Newline !@BlankLine )
1131
+ )+ > Ticks3 |
1132
+ Ticks4 < (
1122
1133
  ( !"`" Nonspacechar )+ |
1123
1134
  !Ticks4 /`+/ |
1124
- !( @Sp Ticks4 ) ( @Spacechar | @Newline !@BlankLine )
1125
- )+ > @Sp Ticks4 |
1126
- Ticks5 @Sp < (
1135
+ !Ticks4 ( @Spacechar | @Newline !@BlankLine )
1136
+ )+ > Ticks4 |
1137
+ Ticks5 < (
1127
1138
  ( !"`" Nonspacechar )+ |
1128
1139
  !Ticks5 /`+/ |
1129
- !( @Sp Ticks5 ) ( @Spacechar | @Newline !@BlankLine )
1130
- )+ > @Sp Ticks5
1140
+ !Ticks5 ( @Spacechar | @Newline !@BlankLine )
1141
+ )+ > Ticks5
1131
1142
  )
1132
- { "<code>#{text}</code>" }
1143
+ { code text }
1133
1144
 
1134
1145
  RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) >
1135
1146
  { if html? then text else '' end }
@@ -1253,7 +1264,7 @@ TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | Tab
1253
1264
  { row }
1254
1265
  TableItem2 = "|" TableItem
1255
1266
  TableItem = < /(?:\\.|[^|\n])+/ >
1256
- { text.strip.gsub(/\\(.)/, '\1') }
1267
+ { text.strip.gsub(/\\([|])/, '\1') }
1257
1268
 
1258
1269
  TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
1259
1270
  { line }