rdoc-babel 1.4.1 → 1.5.0

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: b6ae764381b167bd89156dc785a2a039b9fe66197e26ab1887b565225279c0de
4
- data.tar.gz: 07c955b085e7aa2c195363b40cd0904bcc3a871727f19089d6060546131d9647
3
+ metadata.gz: 8459c975be3bbda71642ce8cdb4b02fa2c91d5fed8882ccce54ec67494141ac7
4
+ data.tar.gz: cbb23203f2df483db114e6aca6f8127152b91d3341ce1aae6cf3483453021b81
5
5
  SHA512:
6
- metadata.gz: 011f9c6d9f66bbf81ae89064b8de0b4973dd397409ba439a8d6b03a8bad2549db5542e4f1d4c607a9c53c672a3d30dcfe152ebd9a055522bad9f70f10aa54402
7
- data.tar.gz: 5aa917b782b26a0e1adc5217168d1eaa16e19d9a447eb664bd5ced9e52f0a3eeff2b12fb83660b61f0af1f8fcf572d8423ba82e74e39ef99cf761bb8441ee8ba
6
+ metadata.gz: 51291ffdffe11249f1afba73b1cf2677c8d77067a5c4361ac8dd0115fa898d26ac8f336993fcf902d3b86a7db92fa02987a6744cea5162550f8b04a74b1043be
7
+ data.tar.gz: d45166d6a503d87e3e294dd702da9d6fc0baf9042127c77c76b4b61770642468c2dade6394532b2e4f39a70bdfa3e120c45c23ffec1bf9159890dfa54d5ec6d7
data/HISTORY.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.5.0
2
+
3
+ * add support for RDoc section directive for instance methods.
4
+
5
+ === 1.4.2
6
+
7
+ * import web fonts in the CSS
8
+
1
9
  === 1.4.1
2
10
 
3
11
  * remove an extra </span> in class HTML
@@ -3,21 +3,21 @@ 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
@@ -33,7 +33,7 @@ class RDoc::Generator::Babel
33
33
 
34
34
  RDoc::RDoc.add_generator(self)
35
35
 
36
- VERSION = '1.4.1'
36
+ VERSION = '1.5.0'
37
37
  DESCRIPTION = 'Alternate HTML documentation'
38
38
 
39
39
  include ERB::Util
@@ -276,6 +276,14 @@ class RDoc::Generator::Babel
276
276
  debug_msg " %s %s" % [klass.type, klass.full_name]
277
277
  outfile = @output_dir + klass.path
278
278
  @class = klass
279
+ @sections = klass.sections
280
+ if @sections.size > 1
281
+ anonymous_section = @sections.find { |s| !s.title }
282
+ if anonymous_section
283
+ @sections.delete anonymous_section
284
+ @sections << anonymous_section
285
+ end
286
+ end
279
287
  self.render_template(template_file, binding(), outfile)
280
288
  end
281
289
  end
@@ -339,23 +347,23 @@ class RDoc::Generator::Babel
339
347
  # with alias information and link to ancestor method/attribute.
340
348
 
341
349
  def description(method)
342
- desc = method.documented? ? method.description.strip : ''
350
+ desc = method.documented? ? method.description.strip : +''
343
351
  if method.is_alias_for
344
- text = method.is_alias_for.documented? ? '<p>' : '<p class="nodoc">'
352
+ text = method.is_alias_for.documented? ? +'<p>' : +'<p class="nodoc">'
345
353
  text << 'Alias for ' << link(method, method.is_alias_for) << '</p>'
346
354
  append_with_nl desc, text
347
355
  end
348
356
  if method.see &&
349
357
  (@see_standard_ancestors ||
350
358
  method.see.parent.full_name !~ /^(Object|Kernel)$/)
351
- text = method.see.documented? ? '<p>' : '<p class="nodoc">'
359
+ text = method.see.documented? ? +'<p>' : +'<p class="nodoc">'
352
360
  text << (desc.empty? ? 'See ' : 'See also ')
353
361
  text << link(method, method.see) << '</p>'
354
362
  append_with_nl desc, text
355
363
  end
356
364
  desc = '<p class="nodoc">(not documented)</p>' if desc.empty?
357
365
  unless method.aliases.empty?
358
- text = '<p>Also aliased as '
366
+ text = +'<p>Also aliased as '
359
367
  text << method.aliases.map { |a| link(method, a) }.join(', ') << '</p>'
360
368
  append_with_nl desc, text
361
369
  end
@@ -465,6 +473,17 @@ class RDoc::Generator::Babel
465
473
  h(text).tr("\001\002\003\004", '&<>"').gsub("\n", '<br/>')
466
474
  end
467
475
 
476
+ # Returns a Hash { section => [methods] } for the current class methods +methods+.
477
+
478
+ def section_methods_hash(methods)
479
+ h = methods.group_by(&:section)
480
+
481
+ @sections.to_h do |section|
482
+ [section, h[section]]
483
+ end
484
+ .compact
485
+ end
486
+
468
487
  protected
469
488
 
470
489
  # Renders the erb template in +template_file+ within the
@@ -553,6 +572,7 @@ protected
553
572
  # and a final trailing newline.
554
573
 
555
574
  def append_with_nl(base, add)
575
+ base = +base
556
576
  base.strip!
557
577
  base.sub!(/\S\z/, "\\&\n")
558
578
  base << add
@@ -4,7 +4,6 @@
4
4
  <meta charset="<%= @options.charset %>">
5
5
  <title><%= @class.full_name %> &ndash; <%= h @options.title %></title>
6
6
  <link href="<%= @stylesheet_url %>" rel="stylesheet">
7
- <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
8
7
  <script src="<%= @rel_prefix %>/scripts/mainFrame.js" type="text/javascript"></script>
9
8
  </head>
10
9
  <body>
@@ -80,13 +79,24 @@
80
79
  <% end %>
81
80
  </ul>
82
81
  <% end %>
83
- <% 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|
86
+ if has_sections %>
87
+ <div class="section-methods">
88
+ <p class="methods-section"><%= section.title || 'Other' %></p>
89
+ <% end %>
84
90
  <ul>
85
- <% @class.instance_methods.sort.each do |m| %>
91
+ <% methods.sort.each do |m| %>
86
92
  <% litag = m.documented? ? '<li>' : '<li class="nodoc">' %>
87
93
  <%= litag %><a href="#<%= m.aref %>"><span class="type"><%= @options.show_hash ? '#' : '' %></span><%= h m.name %></a></li>
88
94
  <% end %>
89
95
  </ul>
96
+ <% if has_sections %>
97
+ </div>
98
+ <% end %>
99
+ <% end %>
90
100
  <% end %>
91
101
  </div>
92
102
  <% end %>
@@ -222,7 +232,13 @@
222
232
  next if methods.empty?
223
233
  %>
224
234
  <h2 id="<%= visibility %>-<%= type %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h2>
225
- <% methods.each do |method| %>
235
+ <% section_hash = section_methods_hash(methods)
236
+ has_sections = section_hash.size > 1 || section_hash.keys.first.title
237
+ section_hash.each do |section, methods|
238
+ if has_sections %>
239
+ <h3><%= section.title || 'Other' %></h3>
240
+ <% end
241
+ methods.each do |method| %>
226
242
  <div id="<%= method.aref %>" class="method-detail<%= method.is_alias_for ? ' method-alias' : '' %>">
227
243
  <div class="method-heading">
228
244
  <% if method.call_seq %>
@@ -250,6 +266,7 @@
250
266
 
251
267
  </div> <!-- #<%= method.aref %> -->
252
268
  <% end # methods.each %>
269
+ <% end # section_hash.each %>
253
270
  <% end # visibilities.each %>
254
271
  <% end # @class.methods_by_type.each %>
255
272
 
@@ -4,7 +4,6 @@
4
4
  <meta charset="<%= @options.charset %>">
5
5
  <title><%= @file.base_name %> &ndash; <%= h @options.title %></title>
6
6
  <link href="<%= @stylesheet_url %>" rel="stylesheet">
7
- <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
8
7
  <script src="<%= @rel_prefix %>/scripts/mainFrame.js" type="text/javascript"></script>
9
8
  </head>
10
9
  <body>
@@ -4,7 +4,6 @@
4
4
  <meta charset="<%= @options.charset %>">
5
5
  <title>Index of <%= @simple_files.empty? ? '' : 'Files, ' %> Classes &amp; Methods in <%= h @options.title %></title>
6
6
  <link href="<%= @stylesheet_url %>" rel="stylesheet">
7
- <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
8
7
  <script src="scripts/quicksearch.js" type="text/javascript"></script>
9
8
  <script src="scripts/indexFrame.js" type="text/javascript"></script>
10
9
  <base target="_parent">
@@ -29,7 +28,7 @@
29
28
  <div class="entries">
30
29
  <% @all_classes_and_modules.each do |k| %>
31
30
  <p class="<%= k.any_content ? k.type : k.type + ' nodoc' %>">
32
- <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>
33
32
  </p>
34
33
  <% end %>
35
34
  </div>
@@ -1,3 +1,4 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');
1
2
 
2
3
  :root {
3
4
  --default-font: "Noto Sans", Verdana, Geneva, Arial, Helvetica, sans-serif;
@@ -543,6 +544,18 @@ p#file-info {
543
544
  #method-list li a {
544
545
  padding: 0 4px 2px 4px; /* TRBL */
545
546
  }
547
+ /* when there are sections: */
548
+ #method-list .section-methods p.methods-section {
549
+ display: inline-block;
550
+ margin-top: 0;
551
+ margin-left: 1.5ex;
552
+ font-size: 9.5pt;
553
+ }
554
+ #method-list .section-methods ul {
555
+ display: inline-block;
556
+ margin-top: 0;
557
+ margin-left: 1ex;
558
+ }
546
559
 
547
560
  /* mixed class/module lists */
548
561
 
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.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thierry Lambert
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-27 00:00:00.000000000 Z
10
+ date: 2025-04-06 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.17
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: []