yard 0.9.28 → 0.9.43

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 (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +139 -1
  3. data/LEGAL +29 -1
  4. data/README.md +29 -25
  5. data/docs/GettingStarted.md +41 -15
  6. data/docs/Parser.md +17 -42
  7. data/docs/Tags.md +6 -6
  8. data/docs/Templates.md +5 -4
  9. data/docs/WhatsNew.md +61 -9
  10. data/docs/templates/default/yard_tags/html/setup.rb +1 -1
  11. data/lib/yard/autoload.rb +20 -1
  12. data/lib/yard/cli/command.rb +1 -1
  13. data/lib/yard/cli/diff.rb +7 -2
  14. data/lib/yard/cli/yardoc.rb +1 -1
  15. data/lib/yard/code_objects/base.rb +6 -2
  16. data/lib/yard/code_objects/extra_file_object.rb +1 -0
  17. data/lib/yard/code_objects/macro_object.rb +0 -1
  18. data/lib/yard/code_objects/proxy.rb +1 -1
  19. data/lib/yard/docstring_parser.rb +1 -2
  20. data/lib/yard/handlers/base.rb +23 -1
  21. data/lib/yard/handlers/processor.rb +1 -1
  22. data/lib/yard/handlers/rbs/attribute_handler.rb +79 -0
  23. data/lib/yard/handlers/rbs/base.rb +38 -0
  24. data/lib/yard/handlers/rbs/constant_handler.rb +18 -0
  25. data/lib/yard/handlers/rbs/method_handler.rb +327 -0
  26. data/lib/yard/handlers/rbs/mixin_handler.rb +20 -0
  27. data/lib/yard/handlers/rbs/namespace_handler.rb +26 -0
  28. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -4
  29. data/lib/yard/handlers/ruby/constant_handler.rb +24 -6
  30. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +1 -1
  31. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
  32. data/lib/yard/handlers/ruby/mixin_handler.rb +13 -6
  33. data/lib/yard/handlers/ruby/visibility_handler.rb +14 -1
  34. data/lib/yard/i18n/locale.rb +2 -2
  35. data/lib/yard/i18n/message.rb +2 -2
  36. data/lib/yard/i18n/messages.rb +1 -1
  37. data/lib/yard/i18n/pot_generator.rb +2 -2
  38. data/lib/yard/logging.rb +116 -61
  39. data/lib/yard/open_struct.rb +67 -0
  40. data/lib/yard/options.rb +1 -1
  41. data/lib/yard/parser/rbs/rbs_parser.rb +325 -0
  42. data/lib/yard/parser/rbs/statement.rb +75 -0
  43. data/lib/yard/parser/ruby/ast_node.rb +5 -4
  44. data/lib/yard/parser/ruby/legacy/irb/slex.rb +19 -1
  45. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +20 -5
  46. data/lib/yard/parser/ruby/ruby_parser.rb +117 -26
  47. data/lib/yard/parser/source_parser.rb +7 -7
  48. data/lib/yard/registry_resolver.rb +9 -1
  49. data/lib/yard/rubygems/specification.rb +1 -1
  50. data/lib/yard/server/commands/base.rb +2 -2
  51. data/lib/yard/server/commands/library_command.rb +8 -8
  52. data/lib/yard/server/commands/static_file_helpers.rb +1 -2
  53. data/lib/yard/server/http_utils.rb +512 -0
  54. data/lib/yard/server/library_version.rb +1 -1
  55. data/lib/yard/server/rack_adapter.rb +13 -5
  56. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +168 -88
  57. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +203 -12
  58. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +1 -17
  59. data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -2
  60. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +3 -3
  61. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +2 -3
  62. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +22 -16
  63. data/lib/yard/tags/default_factory.rb +1 -0
  64. data/lib/yard/tags/directives.rb +7 -1
  65. data/lib/yard/tags/library.rb +3 -3
  66. data/lib/yard/tags/overload_tag.rb +2 -1
  67. data/lib/yard/tags/tag.rb +4 -3
  68. data/lib/yard/tags/types_explainer.rb +6 -5
  69. data/lib/yard/templates/engine.rb +0 -1
  70. data/lib/yard/templates/helpers/base_helper.rb +1 -1
  71. data/lib/yard/templates/helpers/html_helper.rb +21 -6
  72. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +6 -1
  73. data/lib/yard/templates/helpers/markup/hybrid_markdown.rb +2147 -0
  74. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +2 -0
  75. data/lib/yard/templates/helpers/markup_helper.rb +4 -2
  76. data/lib/yard/templates/template_options.rb +0 -1
  77. data/lib/yard/version.rb +1 -1
  78. data/po/ja.po +101 -101
  79. data/templates/default/fulldoc/html/css/common.css +1 -1
  80. data/templates/default/fulldoc/html/css/full_list.css +201 -53
  81. data/templates/default/fulldoc/html/css/style.css +991 -399
  82. data/templates/default/fulldoc/html/frames.erb +9 -4
  83. data/templates/default/fulldoc/html/full_list.erb +8 -5
  84. data/templates/default/fulldoc/html/js/app.js +799 -312
  85. data/templates/default/fulldoc/html/js/full_list.js +332 -214
  86. data/templates/default/fulldoc/html/setup.rb +10 -2
  87. data/templates/default/layout/html/headers.erb +1 -1
  88. data/templates/default/layout/html/layout.erb +3 -1
  89. data/templates/default/method/html/header.erb +3 -3
  90. data/templates/default/module/html/defines.erb +3 -3
  91. data/templates/default/module/html/inherited_methods.erb +1 -0
  92. data/templates/default/module/html/method_summary.erb +8 -0
  93. data/templates/default/module/setup.rb +20 -0
  94. data/templates/default/onefile/html/headers.erb +2 -0
  95. data/templates/default/onefile/html/layout.erb +3 -4
  96. data/templates/default/tags/html/example.erb +2 -2
  97. data/templates/default/tags/html/option.erb +1 -1
  98. data/templates/guide/fulldoc/html/css/style.css +347 -97
  99. data/templates/guide/fulldoc/html/js/app.js +61 -33
  100. data/templates/guide/layout/html/layout.erb +69 -72
  101. metadata +21 -60
  102. data/.dockerignore +0 -2
  103. data/.gitattributes +0 -4
  104. data/.github/FUNDING.yml +0 -3
  105. data/.github/ISSUE_TEMPLATE.md +0 -33
  106. data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
  107. data/.github/workflows/ci.yml +0 -30
  108. data/.github/workflows/gem.yml +0 -19
  109. data/.gitignore +0 -14
  110. data/.rspec +0 -2
  111. data/.rubocop.yml +0 -112
  112. data/CODE_OF_CONDUCT.md +0 -15
  113. data/CONTRIBUTING.md +0 -140
  114. data/Dockerfile.samus +0 -28
  115. data/Gemfile +0 -34
  116. data/Rakefile +0 -36
  117. data/SECURITY.md +0 -26
  118. data/benchmarks/builtins_vs_eval.rb +0 -24
  119. data/benchmarks/concat_vs_join.rb +0 -13
  120. data/benchmarks/erb_vs_erubis.rb +0 -54
  121. data/benchmarks/format_args.rb +0 -47
  122. data/benchmarks/generation.rb +0 -38
  123. data/benchmarks/marshal_vs_dbm.rb +0 -64
  124. data/benchmarks/parsing.rb +0 -46
  125. data/benchmarks/pathname_vs_string.rb +0 -51
  126. data/benchmarks/rdoc_vs_yardoc.rb +0 -11
  127. data/benchmarks/registry_store_types.rb +0 -49
  128. data/benchmarks/ri_vs_yri.rb +0 -19
  129. data/benchmarks/ripper_parser.rb +0 -13
  130. data/benchmarks/splat_vs_flatten.rb +0 -13
  131. data/benchmarks/template_erb.rb +0 -23
  132. data/benchmarks/template_format.rb +0 -7
  133. data/benchmarks/template_profile.rb +0 -18
  134. data/benchmarks/yri_cache.rb +0 -20
  135. data/samus.json +0 -49
  136. data/tasks/prepare_tag.rake +0 -45
  137. data/tasks/update_error_map.rake +0 -53
  138. data/yard.gemspec +0 -25
@@ -1,8 +1,7 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
1
+ <!DOCTYPE html>
2
+ <html lang="en">
4
3
  <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
4
+ <meta charset="<%= charset %>">
6
5
  <title><%= defined?(@title) ? @title : '' %></title>
7
6
  <%= erb(:headers) %>
8
7
  </head>
@@ -1,9 +1,9 @@
1
1
  <% if object.has_tag?(:example) %>
2
2
  <div class="examples">
3
- <p class="tag_title">Examples:</p>
3
+ <h4 class="tag_title">Examples:</h4>
4
4
  <% object.tags(:example).each do |tag| %>
5
5
  <% unless tag.name.empty? %>
6
- <p class="example_title"><%= htmlify_line(tag.name) %></p>
6
+ <h5 class="example_title"><%= htmlify_line(tag.name) %></h5>
7
7
  <% end %>
8
8
  <pre class="example code"><code><%= html_syntax_highlight(tag.text) %></code></pre>
9
9
  <% end %>
@@ -1,4 +1,4 @@
1
- <% if object.has_tag?(:option) %>
1
+ <% if object.has_tag?(:option) && object.respond_to?(:parameters) %>
2
2
  <% object.parameters.each do |param, default| %>
3
3
  <% tags = object.tags(:option).select {|x| x.name.to_s == param.to_s.sub(/^\*+|:$/, '') } %>
4
4
  <% next if tags.empty? %>
@@ -1,108 +1,358 @@
1
- body { color: #3e4349; font-family: Georgia, serif; font-size: 17px; margin: 0; }
2
- h1, h2, h3, h4, h5, h6 { font-weight: normal; color: #000; font-family: Georgia, serif; }
3
- h1 { color: #040; }
4
- h2 { color: #060; }
5
- h3 { color: #070; }
6
- h4 { color: #080; }
7
- h5 { color: #090; }
8
- #sidebar h2 { color: #2f2; }
9
- strong { color: #000; }
10
- .object_link, tt, code { font-family: 'Consolas', 'BitStream Vera Sans Mono', monospace; font-size: 14px; }
11
- .method_header .path, .module_header .path { font-family: 'Consolas', 'BitStream Vera Sans Mono', monospace; }
12
- .method_header .path.space, .module_header .path.space { padding-left: 5px; }
13
- .method_header { font-size: 0.95em; }
14
- .method_body { margin-left: 2em; }
15
- .tags h3, .tags h4 { font-size: 0.9em; font-weight: bold; color: #3e4349; }
16
- .tags .param .name { font-style: italic; }
17
- .tags .option .name { font-family: monospace; color: #000; font-size: 0.8em; }
18
- .tags .option .type, .tags .param .type { font-size: 10px; vertical-align: super; }
19
- .tags .option .type tt, .tags .param .type tt,
20
- .tags .option .type tt .object_link, .tags .param .type tt .object_link { font-size: 10px; }
21
- .module_methods { margin-left: 2em; }
22
- .method_header .since, .module_header .since { font-size: 0.75em; color: #888; vertical-align: super; }
23
- ul { list-style: square; }
24
- .inline { display: inline; }
25
- .inline p:first-child { display: inline; }
26
- .inline p { font-family: Georgia, serif; font-size: 16px; color: #3e4349; }
27
- #filecontents table, .docstring table { border-collapse: collapse; }
28
- #filecontents table th, #filecontents table td,
29
- .docstring table th, .docstring table td { border: 1px solid #ccc; padding: 8px; padding-right: 17px; }
30
- #filecontents table tr:nth-child(odd),
31
- .docstring table tr:nth-child(odd) { background: #eee; }
32
- #filecontents table tr:nth-child(even),
33
- .docstring table tr:nth-child(even) { background: #fff; }
34
- #filecontents table th, .docstring table th { background: #fff; }
35
- .docstring .note { margin: 1em 0; }
36
- .docstring h1, .docstring h2, .docstring h3, .docstring h4 { padding: 0; border: 0; border-bottom: 1px dotted #bbb; }
37
- .docstring h1 { font-size: 1.2em; }
38
- .docstring h2 { font-size: 1.1em; }
39
- .docstring h3 { font-size: 1.1em; }
40
- .docstring h4 { font-size: 1.0em; font-weight: bold; }
41
- .docstring h5 { font-size: 1.0em; font-weight: bold; }
42
- .docstring h6 { font-size: 1.0em; font-weight: bold; }
43
- #filecontents strong { font-weight: normal; color: #000; }
44
- .readonly { font-size: 0.75em; color: #888; vertical-align: super; }
45
- .rdoc-term { padding-right: 25px; font-weight: bold; }
46
- .rdoc-list p { margin: 0; padding: 0; margin-bottom: 4px; }
47
-
48
- #page { width: 940px; margin: 0px auto; }
49
- #top_nav { background: #7d0; padding: 8px 12px; }
50
- #inner_nav { width: 940px; margin: 0px auto; }
51
- #inner_nav a { border: 0; text-decoration: none; color: #777; }
52
- #inner_nav a:hover { color: #222; }
53
- #top_nav .links { display: block; float: right; }
54
- #content { margin-left: 30px; width: 660px; float: left; }
55
- #sidebar { float: left; width: 200px; float: left; padding: 18px 10px; padding-top: 0; }
56
- #sidebar h2 { font-weight: 100; color: #3e4349; font-size: 1.45em; }
57
- #sidebar ol { padding-left: 16px; margin-left: 0; list-style: square; }
58
- #sidebar a { color: #468; text-decoration: none; }
59
- #sidebar a:hover { color: #000; background: #8e0; padding: 4px; }
60
- #sidebar ol.top { padding-left: 0; margin-left: 0; list-style: none; }
61
- #sidebar a { font-size: 0.9em; }
62
- #footer { margin: 0 auto; width: 940px; text-align: center; margin-top: 30px; padding: 20px 0; color: #888; font-size: 0.8em; border-top: 1px dotted #bbb; }
63
- #footer a { color: #444; }
64
- #links strong { font-size: 0.95em; font-weight: normal; color: #000; }
65
-
66
- a { color: #268; text-decoration: none; }
67
- a:hover { color: #6ae; }
1
+ body {
2
+ color: #3e4349;
3
+ font-family: Georgia, serif;
4
+ font-size: 17px;
5
+ margin: 0;
6
+ }
7
+ h1,
8
+ h2,
9
+ h3,
10
+ h4,
11
+ h5,
12
+ h6 {
13
+ font-weight: normal;
14
+ color: #000;
15
+ font-family: Georgia, serif;
16
+ }
17
+ h1 {
18
+ color: #040;
19
+ }
20
+ h2 {
21
+ color: #060;
22
+ }
23
+ h3 {
24
+ color: #070;
25
+ }
26
+ h4 {
27
+ color: #080;
28
+ }
29
+ h5 {
30
+ color: #090;
31
+ }
32
+ #sidebar h2 {
33
+ color: #2f2;
34
+ }
35
+ strong {
36
+ color: #000;
37
+ }
38
+ .object_link,
39
+ tt,
40
+ code {
41
+ font-family: "Consolas", "BitStream Vera Sans Mono", monospace;
42
+ font-size: 14px;
43
+ }
44
+ .method_header .path,
45
+ .module_header .path {
46
+ font-family: "Consolas", "BitStream Vera Sans Mono", monospace;
47
+ }
48
+ .method_header .path.space,
49
+ .module_header .path.space {
50
+ padding-left: 5px;
51
+ }
52
+ .method_header {
53
+ font-size: 0.95em;
54
+ }
55
+ .method_body {
56
+ margin-left: 2em;
57
+ }
58
+ .tags h3,
59
+ .tags h4 {
60
+ font-size: 0.9em;
61
+ font-weight: bold;
62
+ color: #3e4349;
63
+ }
64
+ .tags .param .name {
65
+ font-style: italic;
66
+ }
67
+ .tags .option .name {
68
+ font-family: monospace;
69
+ color: #000;
70
+ font-size: 0.8em;
71
+ }
72
+ .tags .option .type,
73
+ .tags .param .type {
74
+ font-size: 10px;
75
+ vertical-align: super;
76
+ }
77
+ .tags .option .type tt,
78
+ .tags .param .type tt,
79
+ .tags .option .type tt .object_link,
80
+ .tags .param .type tt .object_link {
81
+ font-size: 10px;
82
+ }
83
+ .module_methods {
84
+ margin-left: 2em;
85
+ }
86
+ .method_header .since,
87
+ .module_header .since {
88
+ font-size: 0.75em;
89
+ color: #888;
90
+ vertical-align: super;
91
+ }
92
+ ul {
93
+ list-style: square;
94
+ }
95
+ .inline {
96
+ display: inline;
97
+ }
98
+ .inline p:first-child {
99
+ display: inline;
100
+ }
101
+ .inline p {
102
+ font-family: Georgia, serif;
103
+ font-size: 16px;
104
+ color: #3e4349;
105
+ }
106
+ .docstring table,
107
+ #filecontents table {
108
+ border-collapse: collapse;
109
+ }
110
+ .docstring table th,
111
+ .docstring table td,
112
+ #filecontents table th,
113
+ #filecontents table td {
114
+ border: 1px solid #ccc;
115
+ padding: 8px;
116
+ padding-right: 17px;
117
+ }
118
+ .docstring table tr:nth-child(odd),
119
+ #filecontents table tr:nth-child(odd) {
120
+ background: #eee;
121
+ }
122
+ .docstring table tr:nth-child(even),
123
+ #filecontents table tr:nth-child(even) {
124
+ background: #fff;
125
+ }
126
+ .docstring table th,
127
+ #filecontents table th {
128
+ background: #fff;
129
+ }
130
+ .docstring .note {
131
+ margin: 1em 0;
132
+ }
133
+ .docstring h1,
134
+ .docstring h2,
135
+ .docstring h3,
136
+ .docstring h4 {
137
+ padding: 0;
138
+ border: 0;
139
+ border-bottom: 1px dotted #bbb;
140
+ }
141
+ .docstring h1 {
142
+ font-size: 1.2em;
143
+ }
144
+ .docstring h2 {
145
+ font-size: 1.1em;
146
+ }
147
+ .docstring h3 {
148
+ font-size: 1.1em;
149
+ }
150
+ .docstring h4 {
151
+ font-size: 1em;
152
+ font-weight: bold;
153
+ }
154
+ .docstring h5 {
155
+ font-size: 1em;
156
+ font-weight: bold;
157
+ }
158
+ .docstring h6 {
159
+ font-size: 1em;
160
+ font-weight: bold;
161
+ }
162
+ #filecontents strong {
163
+ font-weight: normal;
164
+ color: #000;
165
+ }
166
+ .readonly {
167
+ font-size: 0.75em;
168
+ color: #888;
169
+ vertical-align: super;
170
+ }
171
+ .rdoc-term {
172
+ padding-right: 25px;
173
+ font-weight: bold;
174
+ }
175
+ .rdoc-list p {
176
+ margin: 0;
177
+ padding: 0;
178
+ margin-bottom: 4px;
179
+ }
68
180
 
181
+ #page {
182
+ width: 940px;
183
+ margin: 0px auto;
184
+ }
185
+ a {
186
+ color: #268;
187
+ text-decoration: none;
188
+ }
189
+ a:hover {
190
+ color: #6ae;
191
+ }
192
+ #top_nav {
193
+ background: #7d0;
194
+ padding: 8px 12px;
195
+ }
196
+ #inner_nav {
197
+ width: 940px;
198
+ margin: 0px auto;
199
+ }
200
+ #inner_nav a {
201
+ border: 0;
202
+ text-decoration: none;
203
+ color: #777;
204
+ }
205
+ #inner_nav a:hover {
206
+ color: #222;
207
+ }
208
+ #top_nav .links {
209
+ display: block;
210
+ float: right;
211
+ }
212
+ #content {
213
+ margin-left: 30px;
214
+ width: 660px;
215
+ float: left;
216
+ }
217
+ #sidebar {
218
+ float: left;
219
+ width: 200px;
220
+ padding: 18px 10px;
221
+ padding-top: 0;
222
+ }
223
+ #sidebar h2 {
224
+ font-weight: 100;
225
+ color: #3e4349;
226
+ font-size: 1.45em;
227
+ }
228
+ #sidebar ol {
229
+ padding-left: 16px;
230
+ margin-left: 0;
231
+ list-style: square;
232
+ }
233
+ #sidebar a {
234
+ color: #468;
235
+ text-decoration: none;
236
+ }
237
+ #sidebar a:hover {
238
+ color: #000;
239
+ background: #8e0;
240
+ padding: 4px;
241
+ }
242
+ #sidebar ol.top {
243
+ padding-left: 0;
244
+ margin-left: 0;
245
+ list-style: none;
246
+ }
247
+ #sidebar a {
248
+ font-size: 0.9em;
249
+ }
250
+ #footer {
251
+ margin: 0 auto;
252
+ width: 940px;
253
+ text-align: center;
254
+ margin-top: 30px;
255
+ padding: 20px 0;
256
+ color: #888;
257
+ font-size: 0.8em;
258
+ border-top: 1px dotted #bbb;
259
+ }
260
+ #footer a {
261
+ color: #444;
262
+ }
69
263
  /* syntax highlighting */
70
- .source_code { display: none; padding: 3px 8px; border-left: 8px solid #ddd; margin-top: 5px; }
71
- #filecontents pre.code, .docstring pre.code, .source_code pre { font-family: monospace; }
72
- #filecontents pre.code, .docstring pre.code { display: block; }
73
- .source_code .lines { padding-right: 12px; color: #555; text-align: right; }
74
- #filecontents pre.code, .docstring pre.code,
264
+ .source_code {
265
+ display: none;
266
+ padding: 3px 8px;
267
+ border-left: 8px solid #ddd;
268
+ margin-top: 5px;
269
+ }
270
+ pre.code {
271
+ color: #3e4349;
272
+ }
273
+ pre.code a {
274
+ border-bottom: 1px dotted #bbf;
275
+ }
276
+ .docstring pre.code,
277
+ #filecontents pre.code,
278
+ .source_code pre {
279
+ font-family: monospace;
280
+ }
281
+ .docstring pre.code,
282
+ #filecontents pre.code {
283
+ display: block;
284
+ }
285
+ .source_code .lines {
286
+ padding-right: 12px;
287
+ color: #555;
288
+ text-align: right;
289
+ }
290
+ .docstring pre.code,
291
+ #filecontents pre.code,
75
292
  .tags pre.example {
76
- font-size: 0.9em;
77
- padding: 7px 30px;
78
- margin: 15px -30px;
79
- margin-left: -30px;
80
- background: #eee;
81
- line-height: 1.3em;
82
- font-family: 'Consolas', 'BitStream Vera Sans Mono', monospace;
83
- }
84
- pre.code { color: #3e4349; }
85
- pre.code .info.file { color: #555; }
86
- pre.code .val { color: #036A07; }
293
+ font-size: 0.9em;
294
+ padding: 7px 30px;
295
+ margin: 15px -30px;
296
+ margin-left: -30px;
297
+ background: #eee;
298
+ line-height: 1.3em;
299
+ font-family: "Consolas", "BitStream Vera Sans Mono", monospace;
300
+ }
301
+ pre.code .info.file {
302
+ color: #555;
303
+ }
304
+ pre.code .val {
305
+ color: #036a07;
306
+ }
87
307
  pre.code .tstring_content,
88
- pre.code .heredoc_beg, pre.code .heredoc_end,
89
- pre.code .qwords_beg, pre.code .qwords_end,
90
- pre.code .tstring, pre.code .dstring { color: #036A07; }
91
- pre.code .fid, pre.code .rubyid_new, pre.code .rubyid_to_s,
92
- pre.code .rubyid_to_sym, pre.code .rubyid_to_f,
308
+ pre.code .heredoc_beg,
309
+ pre.code .heredoc_end,
310
+ pre.code .qwords_beg,
311
+ pre.code .qwords_end,
312
+ pre.code .tstring,
313
+ pre.code .dstring {
314
+ color: #036a07;
315
+ }
316
+ pre.code .fid,
317
+ pre.code .rubyid_new,
318
+ pre.code .rubyid_to_s,
319
+ pre.code .rubyid_to_sym,
320
+ pre.code .rubyid_to_f,
93
321
  pre.code .dot + pre.code .id,
94
- pre.code .rubyid_to_i pre.code .rubyid_each { color: #0085FF; }
95
- pre.code .comment { color: #0066FF; }
96
- pre.code .const, pre.code .constant { color: #585CF6; }
97
- pre.code .symbol { color: #C5060B; }
322
+ pre.code .rubyid_to_i pre.code .rubyid_each {
323
+ color: #0085ff;
324
+ }
325
+ pre.code .comment {
326
+ color: #0066ff;
327
+ }
328
+ pre.code .const,
329
+ pre.code .constant {
330
+ color: #585cf6;
331
+ }
332
+ pre.code .symbol {
333
+ color: #c5060b;
334
+ }
98
335
  pre.code .kw,
99
336
  pre.code .label,
100
337
  pre.code .rubyid_require,
101
338
  pre.code .rubyid_extend,
102
- pre.code .rubyid_include { color: #0000FF; }
103
- pre.code .ivar { color: #318495; }
339
+ pre.code .rubyid_include {
340
+ color: #0000ff;
341
+ }
342
+ pre.code .ivar {
343
+ color: #318495;
344
+ }
104
345
  pre.code .gvar,
105
346
  pre.code .rubyid_backref,
106
- pre.code .rubyid_nth_ref { color: #6D79DE; }
107
- pre.code .regexp, .dregexp { color: #036A07; }
108
- pre.code a { border-bottom: 1px dotted #bbf; }
347
+ pre.code .rubyid_nth_ref {
348
+ color: #6d79de;
349
+ }
350
+ pre.code .regexp,
351
+ .dregexp {
352
+ color: #036a07;
353
+ }
354
+ #links strong {
355
+ font-size: 0.95em;
356
+ font-weight: normal;
357
+ color: #000;
358
+ }
@@ -1,33 +1,61 @@
1
- function generateTOC() {
2
- if ($('#filecontents').length == 0) return;
3
- var _toc = $('<ol class="top"></ol>');
4
- var show = false;
5
- var toc = _toc;
6
- var counter = 0;
7
- var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
8
- for (i in tags) { tags[i] = '#filecontents > ' + tags[i] }
9
- var lastTag = parseInt(tags[0][1]);
10
- $(tags.join(', ')).each(function() {
11
- if (this.id == "filecontents") return;
12
- show = true;
13
- var thisTag = parseInt(this.tagName[1]);
14
- if (this.id.length == 0) {
15
- var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
16
- if ($('#' + proposedId).length > 0) proposedId += counter++;
17
- this.id = proposedId;
18
- }
19
- if (thisTag > lastTag) {
20
- for (var i = 0; i < thisTag - lastTag; i++) {
21
- var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
22
- }
23
- }
24
- if (thisTag < lastTag) {
25
- for (var i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
26
- }
27
- toc.append('<li><a href="#' + this.id + '">' + $(this).text() + '</a></li>');
28
- lastTag = thisTag;
29
- });
30
- if (!show) return;
31
- $('#toc').append()
32
- $('#toc').append(_toc);
33
- }
1
+ window.generateTOC = () => {
2
+ const fileContents = document.getElementById("filecontents");
3
+ const tocRoot = document.getElementById("toc");
4
+ const topLevel = document.createElement("ol");
5
+ let currentList = topLevel;
6
+ let lastLevel = 1;
7
+ let currentItem = null;
8
+ let counter = 0;
9
+ let hasEntries = false;
10
+
11
+ if (!fileContents || !tocRoot) return;
12
+
13
+ topLevel.className = "top";
14
+ const headings = fileContents.querySelectorAll(
15
+ ":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6",
16
+ );
17
+
18
+ Array.prototype.forEach.call(headings, (heading) => {
19
+ let level;
20
+
21
+ if (heading.id === "filecontents") return;
22
+ hasEntries = true;
23
+ level = parseInt(heading.tagName.substring(1), 10);
24
+
25
+ if (!heading.id) {
26
+ let proposedId = heading.textContent.replace(/[^a-z0-9-]/gi, "_");
27
+ if (document.getElementById(proposedId)) proposedId += counter++;
28
+ heading.id = proposedId;
29
+ }
30
+
31
+ if (level > lastLevel) {
32
+ while (level > lastLevel) {
33
+ if (!currentItem) {
34
+ currentItem = document.createElement("li");
35
+ currentList.appendChild(currentItem);
36
+ }
37
+ const nestedList = document.createElement("ol");
38
+ currentItem.appendChild(nestedList);
39
+ currentList = nestedList;
40
+ currentItem = null;
41
+ lastLevel += 1;
42
+ }
43
+ } else if (level < lastLevel) {
44
+ while (level < lastLevel && currentList.parentElement) {
45
+ currentList = currentList.parentElement.parentElement;
46
+ lastLevel -= 1;
47
+ }
48
+ }
49
+
50
+ const item = document.createElement("li");
51
+ const link = document.createElement("a");
52
+ link.href = `#${heading.id}`;
53
+ link.textContent = heading.textContent;
54
+ item.appendChild(link);
55
+ currentList.appendChild(item);
56
+ currentItem = item;
57
+ });
58
+
59
+ if (!hasEntries) return;
60
+ tocRoot.appendChild(topLevel);
61
+ };