rdoc-babel 1.4.2 → 1.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53cc17d95591f5bea0a8af8d5402d76b8dd27b63649ba5d6eb97a4a245d2d4fa
4
- data.tar.gz: 2da4547f70be3f03c84addfba2169c58d22e0d63772464430c4acc013244e7b5
3
+ metadata.gz: 6ae80737f13f1a0c60e44a540d27f66ee883e91c8bc0a5a40f09bc7edbe1d380
4
+ data.tar.gz: d962f2bdc15e62a2f4c5438e00b0ff4dbda17bce472b152c0f17bf3622daa3f1
5
5
  SHA512:
6
- metadata.gz: 848d78b3cc6a7e26f268cbac815fb90b0a9e459c28178debf30209e6bf59b0fed0bc30ab582a7b0df84b997f880d9c603d7d588ae25916c2ee2cd05d4e023116
7
- data.tar.gz: d4983d175a5ab88b46b7da22de74e11bf59bf4fb036ecc2653bb16ef2a725a4c5fccf543aa1be62ae56b8d21a013fe3429a36eb315d2050e0e7c4eab02d232bf
6
+ metadata.gz: 04124b697a014c2026f4b0cb6869c6803534fa14f5e499a373735b982254ec6c8c23146109ab371493cf56750496dba4a734ce101e47614ba0bce0ed5dac4013
7
+ data.tar.gz: c39012b02bd7f6c54f7a6f8102b9ee5ef9823ee75a844bea4b36f7364952ffc23ddd9cb6fbf5a6106667d5edea0fb80ed470411bda6ec8f1e3fa58d423080413
data/HISTORY.rdoc CHANGED
@@ -1,3 +1,12 @@
1
+ === 1.5.1
2
+
3
+ * tune the HTML & CSS
4
+ * support RDoc 6.13.1
5
+
6
+ === 1.5.0
7
+
8
+ * add support for RDoc <tt>:section:</tt> directive (instance methods only).
9
+
1
10
  === 1.4.2
2
11
 
3
12
  * import web fonts in the CSS
@@ -3,26 +3,35 @@ require 'fileutils'
3
3
  require 'erb'
4
4
 
5
5
  # :stopdoc:
6
- # remove junk <span> at the end
7
6
  class RDoc::Markup::ToHtml
8
7
 
8
+ # remove junk <span> at the end
9
9
  undef accept_heading
10
-
11
10
  def accept_heading heading
12
11
  level = [6, heading.level].min
13
12
 
14
13
  label = heading.label @code_object
15
14
 
16
- @res << if @options.output_decoration
17
- "\n<h#{level} id=\"#{label}\">"
18
- else
19
- "\n<h#{level}>"
20
- end
15
+ @res <<
16
+ if @options.output_decoration
17
+ "\n<h#{level} id=\"#{label}\">"
18
+ else
19
+ "\n<h#{level}>"
20
+ end
21
21
  @res << to_html(heading.text)
22
22
  @res << "</h#{level}>\n"
23
23
  end
24
24
 
25
25
  end
26
+
27
+ class RDoc::Alias
28
+ # restore full_old_name (RDoc >= 6.13)
29
+ unless instance_methods.include?(:full_old_name)
30
+ def full_old_name
31
+ @full_name || "#{parent.name}#{pretty_old_name}"
32
+ end
33
+ end
34
+ end
26
35
  # :startdoc:
27
36
 
28
37
  ##
@@ -33,7 +42,7 @@ class RDoc::Generator::Babel
33
42
 
34
43
  RDoc::RDoc.add_generator(self)
35
44
 
36
- VERSION = '1.4.2'
45
+ VERSION = '1.5.1'
37
46
  DESCRIPTION = 'Alternate HTML documentation'
38
47
 
39
48
  include ERB::Util
@@ -276,6 +285,14 @@ class RDoc::Generator::Babel
276
285
  debug_msg " %s %s" % [klass.type, klass.full_name]
277
286
  outfile = @output_dir + klass.path
278
287
  @class = klass
288
+ @sections = klass.sections
289
+ if @sections.size > 1
290
+ anonymous_section = @sections.find { |s| !s.title }
291
+ if anonymous_section
292
+ @sections.delete anonymous_section
293
+ @sections << anonymous_section
294
+ end
295
+ end
279
296
  self.render_template(template_file, binding(), outfile)
280
297
  end
281
298
  end
@@ -339,23 +356,23 @@ class RDoc::Generator::Babel
339
356
  # with alias information and link to ancestor method/attribute.
340
357
 
341
358
  def description(method)
342
- desc = method.documented? ? method.description.strip : ''
359
+ desc = method.documented? ? method.description.strip : +''
343
360
  if method.is_alias_for
344
- text = method.is_alias_for.documented? ? '<p>' : '<p class="nodoc">'
361
+ text = method.is_alias_for.documented? ? +'<p>' : +'<p class="nodoc">'
345
362
  text << 'Alias for ' << link(method, method.is_alias_for) << '</p>'
346
363
  append_with_nl desc, text
347
364
  end
348
365
  if method.see &&
349
366
  (@see_standard_ancestors ||
350
367
  method.see.parent.full_name !~ /^(Object|Kernel)$/)
351
- text = method.see.documented? ? '<p>' : '<p class="nodoc">'
368
+ text = method.see.documented? ? +'<p>' : +'<p class="nodoc">'
352
369
  text << (desc.empty? ? 'See ' : 'See also ')
353
370
  text << link(method, method.see) << '</p>'
354
371
  append_with_nl desc, text
355
372
  end
356
373
  desc = '<p class="nodoc">(not documented)</p>' if desc.empty?
357
374
  unless method.aliases.empty?
358
- text = '<p>Also aliased as '
375
+ text = +'<p>Also aliased as '
359
376
  text << method.aliases.map { |a| link(method, a) }.join(', ') << '</p>'
360
377
  append_with_nl desc, text
361
378
  end
@@ -465,6 +482,17 @@ class RDoc::Generator::Babel
465
482
  h(text).tr("\001\002\003\004", '&<>"').gsub("\n", '<br/>')
466
483
  end
467
484
 
485
+ # Returns a Hash { section => [methods] } for the current class methods +methods+.
486
+
487
+ def section_methods_hash(methods)
488
+ h = methods.group_by(&:section)
489
+
490
+ @sections.to_h do |section|
491
+ [section, h[section]]
492
+ end
493
+ .compact
494
+ end
495
+
468
496
  protected
469
497
 
470
498
  # Renders the erb template in +template_file+ within the
@@ -553,6 +581,7 @@ protected
553
581
  # and a final trailing newline.
554
582
 
555
583
  def append_with_nl(base, add)
584
+ base = +base
556
585
  base.strip!
557
586
  base.sub!(/\S\z/, "\\&\n")
558
587
  base << add
@@ -79,13 +79,20 @@
79
79
  <% end %>
80
80
  </ul>
81
81
  <% end %>
82
- <% unless @class.instance_methods.empty? %>
82
+ <% unless @class.instance_methods.empty?
83
+ section_hash = section_methods_hash(@class.instance_methods)
84
+ has_sections = section_hash.size > 1 || section_hash.keys.first.title
85
+ section_hash.each do |section, methods| %>
83
86
  <ul>
84
- <% @class.instance_methods.sort.each do |m| %>
87
+ <% if has_sections %>
88
+ <li class="section-title"><%= section.title || 'Other' %></li>
89
+ <% end %>
90
+ <% methods.sort.each do |m| %>
85
91
  <% litag = m.documented? ? '<li>' : '<li class="nodoc">' %>
86
92
  <%= litag %><a href="#<%= m.aref %>"><span class="type"><%= @options.show_hash ? '#' : '' %></span><%= h m.name %></a></li>
87
93
  <% end %>
88
94
  </ul>
95
+ <% end %>
89
96
  <% end %>
90
97
  </div>
91
98
  <% end %>
@@ -221,7 +228,13 @@
221
228
  next if methods.empty?
222
229
  %>
223
230
  <h2 id="<%= visibility %>-<%= type %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h2>
224
- <% methods.each do |method| %>
231
+ <% section_hash = section_methods_hash(methods)
232
+ has_sections = section_hash.size > 1 || section_hash.keys.first.title
233
+ section_hash.each do |section, methods|
234
+ if has_sections %>
235
+ <h3><%= section.title || 'Other' %></h3>
236
+ <% end
237
+ methods.each do |method| %>
225
238
  <div id="<%= method.aref %>" class="method-detail<%= method.is_alias_for ? ' method-alias' : '' %>">
226
239
  <div class="method-heading">
227
240
  <% if method.call_seq %>
@@ -249,6 +262,7 @@
249
262
 
250
263
  </div> <!-- #<%= method.aref %> -->
251
264
  <% end # methods.each %>
265
+ <% end # section_hash.each %>
252
266
  <% end # visibilities.each %>
253
267
  <% end # @class.methods_by_type.each %>
254
268
 
@@ -28,7 +28,7 @@
28
28
  <div class="entries">
29
29
  <% @all_classes_and_modules.each do |k| %>
30
30
  <p class="<%= k.any_content ? k.type : k.type + ' nodoc' %>">
31
- <span class="type"><%= k.type[0..0].upcase %></span><a href="<%= k.path %>"><%= k.full_name + (k.is_alias_for ? ' &rarr; ' << k.is_alias_for.full_name : '') %></a>
31
+ <span class="type"><%= k.type[0..0].upcase %></span><a href="<%= k.path %>"><%= k.full_name + (k.is_alias_for ? +' &rarr; ' << k.is_alias_for.full_name : '') %></a>
32
32
  </p>
33
33
  <% end %>
34
34
  </div>
@@ -266,9 +266,11 @@ h4, h5, h6 {
266
266
  border: none;
267
267
  }
268
268
 
269
+ /* links inside headings: keep blue
269
270
  h1 a, h2 a, h3 a {
270
- color: #e62020; /* not the best, but no other idea */
271
+ color: #e62020;
271
272
  }
273
+ */
272
274
 
273
275
  h1 { font-size: 230%; }
274
276
  h2 { font-size: 180%; }
@@ -544,6 +546,12 @@ p#file-info {
544
546
  #method-list li a {
545
547
  padding: 0 4px 2px 4px; /* TRBL */
546
548
  }
549
+ /* when there are sections: */
550
+ #method-list li.section-title {
551
+ font-family: var(--default-font);
552
+ font-size: 9.5pt;
553
+ margin-right: 1ex;
554
+ }
547
555
 
548
556
  /* mixed class/module lists */
549
557
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-babel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thierry Lambert
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-09-10 00:00:00.000000000 Z
10
+ date: 2025-04-14 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rdoc
@@ -98,7 +97,6 @@ homepage: https://github.com/thyresias/rdoc-babel
98
97
  licenses:
99
98
  - MIT
100
99
  metadata: {}
101
- post_install_message:
102
100
  rdoc_options:
103
101
  - "--title"
104
102
  - RDoc Babel
@@ -117,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
115
  - !ruby/object:Gem::Version
118
116
  version: '0'
119
117
  requirements: []
120
- rubygems_version: 3.5.16
121
- signing_key:
118
+ rubygems_version: 3.6.6
122
119
  specification_version: 4
123
120
  summary: An RDoc formatter producing HTML documentation.
124
121
  test_files: []