rdoc 6.15.0 → 7.0.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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +187 -0
  3. data/History.rdoc +1 -1
  4. data/LEGAL.rdoc +6 -0
  5. data/README.md +20 -3
  6. data/lib/rdoc/code_object/any_method.rb +15 -7
  7. data/lib/rdoc/code_object/class_module.rb +13 -0
  8. data/lib/rdoc/code_object/constant.rb +9 -0
  9. data/lib/rdoc/code_object/method_attr.rb +13 -1
  10. data/lib/rdoc/code_object/top_level.rb +31 -18
  11. data/lib/rdoc/comment.rb +190 -8
  12. data/lib/rdoc/generator/aliki.rb +183 -0
  13. data/lib/rdoc/generator/darkfish.rb +5 -1
  14. data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
  15. data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
  16. data/lib/rdoc/generator/template/aliki/_head.rhtml +158 -0
  17. data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
  18. data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
  19. data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
  20. data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
  21. data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +25 -0
  22. data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +25 -0
  23. data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
  24. data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
  25. data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
  26. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
  27. data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
  28. data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
  29. data/lib/rdoc/generator/template/aliki/class.rhtml +218 -0
  30. data/lib/rdoc/generator/template/aliki/css/rdoc.css +1944 -0
  31. data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
  32. data/lib/rdoc/generator/template/aliki/js/aliki.js +498 -0
  33. data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
  34. data/lib/rdoc/generator/template/aliki/js/search_controller.js +120 -0
  35. data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
  36. data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
  37. data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
  38. data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
  39. data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
  40. data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
  41. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
  42. data/lib/rdoc/generator/template/darkfish/_head.rhtml +14 -19
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +19 -19
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
  52. data/lib/rdoc/generator/template/darkfish/class.rhtml +62 -62
  53. data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
  54. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
  55. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
  56. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
  57. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
  58. data/lib/rdoc/generator/template/json_index/js/searcher.js +43 -6
  59. data/lib/rdoc/generator.rb +1 -0
  60. data/lib/rdoc/markup/pre_process.rb +34 -10
  61. data/lib/rdoc/markup/to_ansi.rb +4 -0
  62. data/lib/rdoc/markup/to_bs.rb +4 -0
  63. data/lib/rdoc/markup/to_html.rb +6 -4
  64. data/lib/rdoc/markup/to_rdoc.rb +11 -3
  65. data/lib/rdoc/options.rb +21 -10
  66. data/lib/rdoc/parser/c.rb +15 -46
  67. data/lib/rdoc/parser/prism_ruby.rb +121 -113
  68. data/lib/rdoc/parser/ruby.rb +8 -8
  69. data/lib/rdoc/parser/ruby_tools.rb +5 -7
  70. data/lib/rdoc/parser/simple.rb +4 -21
  71. data/lib/rdoc/rdoc.rb +1 -0
  72. data/lib/rdoc/rubygems_hook.rb +3 -3
  73. data/lib/rdoc/text.rb +1 -1
  74. data/lib/rdoc/token_stream.rb +13 -1
  75. data/lib/rdoc/tom_doc.rb +1 -1
  76. data/lib/rdoc/version.rb +1 -1
  77. data/rdoc.gemspec +1 -1
  78. metadata +33 -5
  79. data/CONTRIBUTING.rdoc +0 -219
@@ -4,6 +4,7 @@
4
4
  <input id="search-field" role="combobox" aria-label="Search"
5
5
  aria-autocomplete="list" aria-controls="search-results"
6
6
  type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
7
+ autocomplete="off"
7
8
  title="Type to search, Up and Down to navigate, Enter to load">
8
9
  </div>
9
10
 
@@ -3,9 +3,9 @@
3
3
  <h3>Sections</h3>
4
4
 
5
5
  <ul class="link-list" role="directory">
6
- <%- klass.sort_sections.each do |section| -%>
6
+ <%- klass.sort_sections.each do |section| %>
7
7
  <li><a href="#<%= section.aref %>"><%= h section.title %></a></li>
8
- <%- end -%>
8
+ <%- end %>
9
9
  </ul>
10
10
  </div>
11
- <%- end -%>
11
+ <%- end %>
@@ -9,31 +9,31 @@
9
9
  <div class="nav-section">
10
10
  <h3>Table of Contents</h3>
11
11
 
12
- <%- display_link = proc do |heading| -%>
12
+ <%- display_link = proc do |heading| %>
13
13
  <a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
14
- <%- end -%>
14
+ <%- end %>
15
15
 
16
- <%- list_siblings = proc do -%>
17
- <%- level = table.first&.level -%>
18
- <%- while table.first && table.first.level >= level -%>
19
- <%- heading = table.shift -%>
20
- <%- if table.first.nil? || table.first.level <= heading.level -%>
21
- <li><% display_link.call heading -%>
22
- <%- else -%>
16
+ <%- list_siblings = proc do %>
17
+ <%- level = table.first&.level %>
18
+ <%- while table.first && table.first.level >= level %>
19
+ <%- heading = table.shift %>
20
+ <%- if table.first.nil? || table.first.level <= heading.level %>
21
+ <li><% display_link.call heading %></li>
22
+ <%- else %>
23
23
  <li>
24
24
  <details open>
25
- <summary><%- display_link.call heading -%></summary>
25
+ <summary><%- display_link.call heading %></summary>
26
26
  <ul class="link-list" role="directory">
27
27
  <% list_siblings.call %>
28
28
  </ul>
29
29
  </details>
30
30
  </li>
31
- <%- end -%>
32
- <%- end -%>
33
- <%- end -%>
31
+ <%- end %>
32
+ <%- end %>
33
+ <%- end %>
34
34
 
35
35
  <ul class="link-list" role="directory">
36
36
  <% list_siblings.call %>
37
37
  </ul>
38
38
  </div>
39
- <%- end -%>
39
+ <%- end %>
@@ -17,10 +17,10 @@
17
17
  <%= render '_footer.rhtml' %>
18
18
  </nav>
19
19
 
20
- <main role="main" aria-labelledby="<%=h klass.aref %>">
20
+ <main role="main" aria-labelledby="<%= h klass.aref %>">
21
21
  <%# If nesting level is 1, breadcrumb list is not needed %>
22
22
  <% if breadcrumb.size > 1 %>
23
- <ol role="navigation" aria-label="breadcrumb" class="breadcrumb">
23
+ <ol role="navigation" aria-label="Breadcrumb navigation" class="breadcrumb">
24
24
  <% breadcrumb.each do |namespace| %>
25
25
  <li>
26
26
  <% if namespace[:self] %>
@@ -33,7 +33,7 @@
33
33
  </ol>
34
34
  <% end %>
35
35
 
36
- <h1 id="<%=h klass.aref %>" class="anchor-link <%= klass.type %>">
36
+ <h1 id="<%= h klass.aref %>" class="anchor-link <%= klass.type %>">
37
37
  <%= klass.type %> <%= klass.full_name %>
38
38
  </h1>
39
39
 
@@ -41,9 +41,9 @@
41
41
  <%= klass.description %>
42
42
  </section>
43
43
 
44
- <%- klass.each_section do |section, constants, attributes| -%>
44
+ <%- klass.each_section do |section, constants, attributes| %>
45
45
  <section id="<%= section.aref %>" class="documentation-section anchor-link">
46
- <%- if section.title then -%>
46
+ <%- if section.title then %>
47
47
  <header class="documentation-section-title">
48
48
  <h2>
49
49
  <%= section.title %>
@@ -52,45 +52,46 @@
52
52
  <a href="#top">&uarr; top</a>
53
53
  </span>
54
54
  </header>
55
- <%- end -%>
55
+ <%- end %>
56
56
 
57
- <%- if section.comment then -%>
57
+ <%- if section.comment then %>
58
58
  <div>
59
59
  <%= section.description %>
60
60
  </div>
61
- <%- end -%>
61
+ <%- end %>
62
62
 
63
- <%- unless constants.empty? then -%>
63
+ <%- unless constants.empty? then %>
64
64
  <section class="constants-list">
65
65
  <header>
66
66
  <h3>Constants</h3>
67
67
  </header>
68
68
  <dl>
69
- <%- constants.each do |const| -%>
70
- <dt id="<%= const.name %>"><%= const.name %>
71
- <%- if const.comment then -%>
69
+ <%- constants.each do |const| %>
70
+ <dt id="<%= const.name %>"><%= const.name %></dt>
71
+ <%- if const.comment then %>
72
72
  <dd>
73
- <%- if const.mixin_from then -%>
73
+ <%- if const.mixin_from then %>
74
74
  <div class="mixin-from">
75
- Included from <a href="<%= klass.aref_to(const.mixin_from.path)%>"><%= const.mixin_from.full_name %></a>
75
+ Included from <a href="<%= klass.aref_to(const.mixin_from.path) %>"><%= const.mixin_from.full_name %></a>
76
76
  </div>
77
- <%- end -%>
77
+ <%- end %>
78
78
  <%= const.description.strip %>
79
- <%- else -%>
80
- <dd class="missing-docs">(Not documented)
81
- <%- end -%>
82
- <%- end -%>
79
+ </dd>
80
+ <%- else %>
81
+ <dd class="missing-docs">(Not documented)</dd>
82
+ <%- end %>
83
+ <%- end %>
83
84
  </dl>
84
85
  </section>
85
- <%- end -%>
86
+ <%- end %>
86
87
 
87
- <%- unless attributes.empty? then -%>
88
- <section class="attribute-method-details" class="method-section">
88
+ <%- unless attributes.empty? then %>
89
+ <section class="attribute-method-details method-section">
89
90
  <header>
90
91
  <h3>Attributes</h3>
91
92
  </header>
92
93
 
93
- <%- attributes.each do |attrib| -%>
94
+ <%- attributes.each do |attrib| %>
94
95
  <div id="<%= attrib.aref %>" class="method-detail anchor-link">
95
96
  <div class="method-heading attribute-method-heading">
96
97
  <a href="#<%= attrib.aref %>" title="Link to this attribute">
@@ -100,21 +101,21 @@
100
101
  </div>
101
102
 
102
103
  <div class="method-description">
103
- <%- if attrib.mixin_from then -%>
104
+ <%- if attrib.mixin_from then %>
104
105
  <div class="mixin-from">
105
- <%= attrib.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(attrib.mixin_from.path)%>"><%= attrib.mixin_from.full_name %></a>
106
+ <%= attrib.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(attrib.mixin_from.path) %>"><%= attrib.mixin_from.full_name %></a>
106
107
  </div>
107
- <%- end -%>
108
- <%- if attrib.comment then -%>
108
+ <%- end %>
109
+ <%- if attrib.comment then %>
109
110
  <%= attrib.description.strip %>
110
- <%- else -%>
111
- <p class="missing-docs">(Not documented)
112
- <%- end -%>
111
+ <%- else %>
112
+ <p class="missing-docs">(Not documented)</p>
113
+ <%- end %>
113
114
  </div>
114
115
  </div>
115
- <%- end -%>
116
+ <%- end %>
116
117
  </section>
117
- <%- end -%>
118
+ <%- end %>
118
119
 
119
120
  <%- klass.methods_by_type(section).each do |type, visibilities|
120
121
  next if visibilities.empty?
@@ -125,11 +126,11 @@
125
126
  <h3><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
126
127
  </header>
127
128
 
128
- <%- methods.each do |method| -%>
129
+ <%- methods.each do |method| %>
129
130
  <div id="<%= method.aref %>" class="method-detail anchor-link <%= method.is_alias_for ? "method-alias" : '' %>">
130
131
  <div class="method-header">
131
- <%- if (call_seq = method.call_seq) then -%>
132
- <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
132
+ <%- if (call_seq = method.call_seq) then %>
133
+ <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| %>
133
134
  <div class="method-heading">
134
135
  <a href="#<%= method.aref %>" title="Link to this method">
135
136
  <span class="method-callseq">
@@ -139,49 +140,47 @@
139
140
  </span>
140
141
  </a>
141
142
  </div>
142
- <%- end -%>
143
- <%- elsif method.has_call_seq? then -%>
143
+ <%- end %>
144
+ <%- elsif method.has_call_seq? then %>
144
145
  <div class="method-heading">
145
146
  <a href="#<%= method.aref %>" title="Link to this method">
146
147
  <span class="method-name"><%= h method.name %></span>
147
148
  </a>
148
149
  </div>
149
- <%- else -%>
150
+ <%- else %>
150
151
  <div class="method-heading">
151
152
  <a href="#<%= method.aref %>" title="Link to this method">
152
153
  <span class="method-name"><%= h method.name %></span>
153
154
  <span class="method-args"><%= h method.param_seq %></span>
154
155
  </a>
155
156
  </div>
156
- <%- end -%>
157
+ <%- end %>
157
158
  </div>
158
159
 
159
- <%- if method.token_stream -%>
160
+ <%- if method.token_stream %>
160
161
  <div class="method-controls">
161
162
  <details class="method-source-toggle">
162
163
  <summary>Source</summary>
163
164
  </details>
164
165
  </div>
165
- <%- end -%>
166
-
167
- <%- unless method.skip_description? then -%>
168
- <div class="method-description">
169
- <%- if method.token_stream then -%>
170
166
  <div class="method-source-code" id="<%= method.html_name %>-source">
171
167
  <pre><%= method.markup_code %></pre>
172
168
  </div>
173
- <%- end -%>
174
- <%- if method.mixin_from then -%>
169
+ <%- end %>
170
+
171
+ <%- unless method.skip_description? then %>
172
+ <div class="method-description">
173
+ <%- if method.mixin_from then %>
175
174
  <div class="mixin-from">
176
- <%= method.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(method.mixin_from.path)%>"><%= method.mixin_from.full_name %></a>
175
+ <%= method.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(method.mixin_from.path) %>"><%= method.mixin_from.full_name %></a>
177
176
  </div>
178
- <%- end -%>
179
- <%- if method.comment then -%>
177
+ <%- end %>
178
+ <%- if method.comment then %>
180
179
  <%= method.description.strip %>
181
- <%- else -%>
182
- <p class="missing-docs">(Not documented)
183
- <%- end -%>
184
- <%- if method.calls_super then -%>
180
+ <%- else %>
181
+ <p class="missing-docs">(Not documented)</p>
182
+ <%- end %>
183
+ <%- if method.calls_super then %>
185
184
  <div class="method-calls-super">
186
185
  Calls superclass method
187
186
  <%=
@@ -189,11 +188,11 @@
189
188
  method.formatter.link(method.superclass_method.full_name, method.superclass_method.full_name) : nil
190
189
  %>
191
190
  </div>
192
- <%- end -%>
191
+ <%- end %>
193
192
  </div>
194
- <%- end -%>
193
+ <%- end %>
195
194
 
196
- <%- unless method.aliases.empty? then -%>
195
+ <%- unless method.aliases.empty? then %>
197
196
  <div class="aliases">
198
197
  Also aliased as: <%= method.aliases.map do |aka|
199
198
  if aka.parent then # HACK lib/rexml/encodings
@@ -203,19 +202,20 @@
203
202
  end
204
203
  end.join ", " %>
205
204
  </div>
206
- <%- end -%>
205
+ <%- end %>
207
206
 
208
- <%- if method.is_alias_for then -%>
207
+ <%- if method.is_alias_for then %>
209
208
  <div class="aliases">
210
209
  Alias for: <a href="<%= klass.aref_to method.is_alias_for.path %>"><%= h method.is_alias_for.name %></a>
211
210
  </div>
212
- <%- end -%>
211
+ <%- end %>
213
212
  </div>
214
213
 
215
- <%- end -%>
214
+ <%- end %>
216
215
  </section>
217
216
  <%- end
218
217
  end %>
219
218
  </section>
220
- <%- end -%>
219
+ <%- end %>
221
220
  </main>
221
+ </body>
@@ -17,7 +17,8 @@
17
17
  <main role="main">
18
18
  <%- if @main_page %>
19
19
  <%= @main_page.description %>
20
- <%- else -%>
21
- <p>This is the API documentation for <%= h @title %>.
22
- <%- end -%>
20
+ <%- else %>
21
+ <p>This is the API documentation for <%= h @title %>.</p>
22
+ <%- end %>
23
23
  </main>
24
+ </body>
@@ -13,6 +13,7 @@
13
13
  <%= render '_footer.rhtml' %>
14
14
  </nav>
15
15
 
16
- <main role="main" aria-label="Page <%=h file.full_name%>">
16
+ <main role="main" aria-label="Page <%= h file.full_name %>">
17
17
  <%= file.description %>
18
18
  </main>
19
+ </body>
@@ -16,5 +16,6 @@
16
16
  <main role="main">
17
17
  <h1>Not Found</h1>
18
18
 
19
- <p><%= message %>
19
+ <p><%= message %></p>
20
20
  </main>
21
+ </body>
@@ -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,10 +57,14 @@ 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
65
  var pattern = [];
62
66
  for (var i = 0; i < query.length; i++) {
63
- var char = RegExp.escape(query[i]);
67
+ var char = escape(query[i]);
64
68
  pattern.push('([' + char + '])([^' + char + ']*?)');
65
69
  }
66
70
  return new RegExp(pattern.join(''), 'i');
@@ -85,6 +89,30 @@ Searcher.prototype = new function() {
85
89
 
86
90
  /* ----- Mathchers ------ */
87
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
+
88
116
  /*
89
117
  * This record matches if the index starts with queries[0] and the record
90
118
  * matches all of the regexps
@@ -192,17 +220,26 @@ Searcher.prototype = new function() {
192
220
  var togo = CHUNK_SIZE;
193
221
  var matchFunc, hltFunc;
194
222
 
195
- 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
196
227
  if (state.pass == 0) {
197
- matchFunc = matchPassBeginning;
228
+ matchFunc = isLowercaseQuery ? matchPassExactMethod : matchPassExact;
198
229
  hltFunc = highlightQuery;
199
230
  } else if (state.pass == 1) {
200
- matchFunc = matchPassLongIndex;
231
+ matchFunc = isLowercaseQuery ? matchPassExact : matchPassExactMethod;
201
232
  hltFunc = highlightQuery;
202
233
  } else if (state.pass == 2) {
203
- matchFunc = matchPassContains;
234
+ matchFunc = matchPassBeginning;
204
235
  hltFunc = highlightQuery;
205
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) {
206
243
  matchFunc = matchPassRegexp;
207
244
  hltFunc = highlightRegexp;
208
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"