yard 0.9.36 → 0.9.38

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -0
  3. data/README.md +17 -10
  4. data/docs/Templates.md +5 -4
  5. data/lib/yard/autoload.rb +1 -0
  6. data/lib/yard/code_objects/base.rb +1 -1
  7. data/lib/yard/code_objects/extra_file_object.rb +1 -0
  8. data/lib/yard/code_objects/macro_object.rb +0 -1
  9. data/lib/yard/docstring_parser.rb +0 -1
  10. data/lib/yard/handlers/base.rb +23 -1
  11. data/lib/yard/handlers/processor.rb +0 -1
  12. data/lib/yard/handlers/ruby/constant_handler.rb +23 -6
  13. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +2 -1
  14. data/lib/yard/handlers/ruby/visibility_handler.rb +14 -1
  15. data/lib/yard/logging.rb +116 -61
  16. data/lib/yard/open_struct.rb +67 -0
  17. data/lib/yard/parser/ruby/ast_node.rb +5 -4
  18. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +20 -5
  19. data/lib/yard/parser/ruby/ruby_parser.rb +54 -21
  20. data/lib/yard/parser/source_parser.rb +2 -2
  21. data/lib/yard/tags/default_factory.rb +1 -0
  22. data/lib/yard/tags/directives.rb +0 -1
  23. data/lib/yard/tags/overload_tag.rb +2 -1
  24. data/lib/yard/tags/tag.rb +2 -1
  25. data/lib/yard/tags/types_explainer.rb +3 -3
  26. data/lib/yard/templates/engine.rb +0 -1
  27. data/lib/yard/templates/helpers/html_helper.rb +5 -1
  28. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +2 -0
  29. data/lib/yard/templates/template_options.rb +0 -1
  30. data/lib/yard/version.rb +1 -1
  31. data/templates/default/fulldoc/html/css/full_list.css +3 -3
  32. data/templates/default/fulldoc/html/css/style.css +8 -15
  33. data/templates/default/fulldoc/html/full_list.erb +5 -2
  34. data/templates/default/fulldoc/html/js/app.js +348 -267
  35. data/templates/default/fulldoc/html/js/full_list.js +52 -24
  36. data/templates/default/fulldoc/html/setup.rb +10 -2
  37. data/templates/default/onefile/html/headers.erb +2 -0
  38. data/templates/default/tags/html/example.erb +2 -2
  39. metadata +7 -6
@@ -20,17 +20,6 @@ function escapeShortcut() {
20
20
  });
21
21
  }
22
22
 
23
- function navResizer() {
24
- $(window).mousemove(function(e) {
25
- window.parent.postMessage({
26
- action: 'mousemove', event: {pageX: e.pageX, which: e.which}
27
- }, '*');
28
- }).mouseup(function(e) {
29
- window.parent.postMessage({action: 'mouseup'}, '*');
30
- });
31
- window.parent.postMessage("navReady", "*");
32
- }
33
-
34
23
  function clearSearchTimeout() {
35
24
  clearTimeout(searchTimeout);
36
25
  searchTimeout = null;
@@ -44,14 +33,21 @@ function enableLinks() {
44
33
  $clicked.addClass('clicked');
45
34
  evt.stopPropagation();
46
35
 
47
- if (evt.target.tagName === 'A') return true;
36
+ if (window.origin === "null") {
37
+ if (evt.target.tagName === 'A') return true;
48
38
 
49
- var elem = $clicked.find('> .item .object_link a')[0];
50
- var e = evt.originalEvent;
51
- var newEvent = new MouseEvent(evt.originalEvent.type);
52
- newEvent.initMouseEvent(e.type, e.canBubble, e.cancelable, e.view, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
53
- elem.dispatchEvent(newEvent);
54
- evt.preventDefault();
39
+ var elem = $clicked.find('> .item .object_link a')[0];
40
+ var e = evt.originalEvent;
41
+ var newEvent = new MouseEvent(evt.originalEvent.type);
42
+ newEvent.initMouseEvent(e.type, e.canBubble, e.cancelable, e.view, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
43
+ elem.dispatchEvent(newEvent);
44
+ evt.preventDefault();
45
+ } else {
46
+ window.top.postMessage({
47
+ action: "navigate",
48
+ url: $clicked.find('.object_link a').attr('href'),
49
+ }, "*");
50
+ }
55
51
  return false;
56
52
  });
57
53
  }
@@ -62,8 +58,25 @@ function enableToggles() {
62
58
  evt.stopPropagation();
63
59
  evt.preventDefault();
64
60
  $(this).parent().parent().toggleClass('collapsed');
61
+ $(this).attr('aria-expanded', function (i, attr) {
62
+ return attr == 'true' ? 'false' : 'true'
63
+ });
65
64
  highlight();
66
65
  });
66
+
67
+ // navigation of nested classes using keyboard
68
+ $('#full_list a.toggle').on('keypress',function(evt) {
69
+ // enter key is pressed
70
+ if (evt.which == 13) {
71
+ evt.stopPropagation();
72
+ evt.preventDefault();
73
+ $(this).parent().parent().toggleClass('collapsed');
74
+ $(this).attr('aria-expanded', function (i, attr) {
75
+ return attr == 'true' ? 'false' : 'true'
76
+ });
77
+ highlight();
78
+ }
79
+ });
67
80
  }
68
81
 
69
82
  function populateSearchCache() {
@@ -91,7 +104,7 @@ function enableSearch() {
91
104
  }
92
105
  });
93
106
 
94
- $('#full_list').after("<div id='noresults' style='display:none'></div>");
107
+ $('#full_list').after("<div id='noresults' role='status' style='display: none'></div>");
95
108
  }
96
109
 
97
110
  function ignoredKeyPress(event) {
@@ -154,11 +167,14 @@ function partialSearch(searchString, offset) {
154
167
  function searchDone() {
155
168
  searchTimeout = null;
156
169
  highlight();
157
- if ($('#full_list li:visible').size() === 0) {
158
- $('#noresults').text('No results were found.').hide().fadeIn();
170
+ var found = $('#full_list li:visible').size();
171
+ if (found === 0) {
172
+ $('#noresults').text('No results were found.');
159
173
  } else {
160
- $('#noresults').text('').hide();
174
+ // This is read out to screen readers
175
+ $('#noresults').text('There are ' + found + ' results.');
161
176
  }
177
+ $('#noresults').show();
162
178
  $('#content').removeClass('insearch');
163
179
  }
164
180
 
@@ -179,6 +195,13 @@ function highlight() {
179
195
  });
180
196
  }
181
197
 
198
+ function isInView(element) {
199
+ const rect = element.getBoundingClientRect();
200
+ const windowHeight =
201
+ window.innerHeight || document.documentElement.clientHeight;
202
+ return rect.left >= 0 && rect.bottom <= windowHeight;
203
+ }
204
+
182
205
  /**
183
206
  * Expands the tree to the target element and its immediate
184
207
  * children.
@@ -188,7 +211,13 @@ function expandTo(path) {
188
211
  $target.addClass('clicked');
189
212
  $target.removeClass('collapsed');
190
213
  $target.parentsUntil('#full_list', 'li').removeClass('collapsed');
191
- if($target[0]) {
214
+
215
+ $target.find('a.toggle').attr('aria-expanded', 'true')
216
+ $target.parentsUntil('#full_list', 'li').each(function(i, el) {
217
+ $(el).find('> div > a.toggle').attr('aria-expanded', 'true');
218
+ });
219
+
220
+ if($target[0] && !isInView($target[0])) {
192
221
  window.scrollTo(window.scrollX, $target.offset().top - 250);
193
222
  highlight();
194
223
  }
@@ -206,7 +235,6 @@ window.addEventListener("message", windowEvents, false);
206
235
 
207
236
  $(document).ready(function() {
208
237
  escapeShortcut();
209
- navResizer();
210
238
  enableLinks();
211
239
  enableToggles();
212
240
  populateSearchCache();
@@ -104,6 +104,12 @@ def javascripts_full_list
104
104
  %w(js/jquery.js js/full_list.js)
105
105
  end
106
106
 
107
+ # Sets the HTML language lang="value" where value is the value returned from
108
+ # this method. Defaults to nil which does not set the lang attribute.
109
+ def html_lang
110
+ nil
111
+ end
112
+
107
113
  def menu_lists
108
114
  Object.new.extend(T('layout')).menu_lists
109
115
  end
@@ -225,7 +231,8 @@ def class_list(root = Registry.root, tree = TreeContext.new)
225
231
  has_children = run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
226
232
  out << "<li id='object_#{child.path}' class='#{tree.classes.join(' ')}'>"
227
233
  out << "<div class='item' style='padding-left:#{tree.indent}'>"
228
- out << "<a class='toggle'></a> " if has_children
234
+ accessible_props = "aria-label='#{name} child nodes' aria-expanded='false' aria-controls='object_#{child.path}'"
235
+ out << "<a tabindex='0' class='toggle' role='button' #{accessible_props}></a> " if has_children
229
236
  out << linkify(child, name)
230
237
  out << " &lt; #{child.superclass.name}" if child.is_a?(CodeObjects::ClassObject) && child.superclass
231
238
  out << "<small class='search_info'>"
@@ -233,7 +240,8 @@ def class_list(root = Registry.root, tree = TreeContext.new)
233
240
  out << "</small>"
234
241
  out << "</div>"
235
242
  tree.nest do
236
- out << "<ul>#{class_list(child, tree)}</ul>" if has_children
243
+ labeled_by = "aria-labelledby='object_#{child.path}'"
244
+ out << "<div #{labeled_by}><ul>#{class_list(child, tree)}</ul></div>" if has_children
237
245
  end
238
246
  out << "</li>"
239
247
  end
@@ -1,5 +1,7 @@
1
1
  <style type="text/css">
2
2
  <%= @css_data %>
3
+ html { width: auto; height: auto; }
4
+ body { display: block; margin: 1rem; width: auto; }
3
5
  </style>
4
6
  <script type="text/javascript">
5
7
  <%= @js_data %>
@@ -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 %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.36
4
+ version: 0.9.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loren Segal
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-29 00:00:00.000000000 Z
11
+ date: 2025-12-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  YARD is a documentation generation tool for the Ruby programming language.
@@ -165,6 +165,7 @@ files:
165
165
  - lib/yard/i18n/pot_generator.rb
166
166
  - lib/yard/i18n/text.rb
167
167
  - lib/yard/logging.rb
168
+ - lib/yard/open_struct.rb
168
169
  - lib/yard/options.rb
169
170
  - lib/yard/parser/base.rb
170
171
  - lib/yard/parser/c/c_parser.rb
@@ -397,7 +398,7 @@ licenses:
397
398
  - MIT
398
399
  metadata:
399
400
  yard.run: yri
400
- post_install_message:
401
+ post_install_message:
401
402
  rdoc_options: []
402
403
  require_paths:
403
404
  - lib
@@ -412,8 +413,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
412
413
  - !ruby/object:Gem::Version
413
414
  version: '0'
414
415
  requirements: []
415
- rubygems_version: 3.3.5
416
- signing_key:
416
+ rubygems_version: 3.4.20
417
+ signing_key:
417
418
  specification_version: 4
418
419
  summary: Documentation tool for consistent and usable documentation in Ruby.
419
420
  test_files: []