rdoc 6.4.0 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -2
  3. data/LEGAL.rdoc +1 -1
  4. data/README.rdoc +2 -2
  5. data/TODO.rdoc +1 -1
  6. data/exe/rdoc +0 -1
  7. data/lib/rdoc/alias.rb +0 -1
  8. data/lib/rdoc/anon_class.rb +0 -1
  9. data/lib/rdoc/any_method.rb +17 -2
  10. data/lib/rdoc/attr.rb +0 -1
  11. data/lib/rdoc/class_module.rb +0 -1
  12. data/lib/rdoc/code_objects.rb +1 -2
  13. data/lib/rdoc/comment.rb +20 -41
  14. data/lib/rdoc/constant.rb +0 -1
  15. data/lib/rdoc/context/section.rb +2 -1
  16. data/lib/rdoc/context.rb +1 -3
  17. data/lib/rdoc/cross_reference.rb +17 -2
  18. data/lib/rdoc/encoding.rb +1 -6
  19. data/lib/rdoc/erb_partial.rb +0 -1
  20. data/lib/rdoc/erbio.rb +2 -7
  21. data/lib/rdoc/extend.rb +0 -1
  22. data/lib/rdoc/generator/darkfish.rb +2 -6
  23. data/lib/rdoc/generator/json_index.rb +2 -2
  24. data/lib/rdoc/generator/markup.rb +1 -2
  25. data/lib/rdoc/generator/ri.rb +0 -1
  26. data/lib/rdoc/generator/template/darkfish/_head.rhtml +10 -10
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  31. data/lib/rdoc/generator/template/darkfish/class.rhtml +28 -20
  32. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +44 -7
  33. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  34. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +14 -1
  35. data/lib/rdoc/generator/template/darkfish/js/search.js +4 -4
  36. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +7 -6
  37. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  38. data/lib/rdoc/generator.rb +5 -5
  39. data/lib/rdoc/ghost_method.rb +0 -1
  40. data/lib/rdoc/i18n.rb +1 -1
  41. data/lib/rdoc/include.rb +0 -1
  42. data/lib/rdoc/known_classes.rb +5 -4
  43. data/lib/rdoc/markdown/entities.rb +0 -1
  44. data/lib/rdoc/markdown/literals.rb +98 -40
  45. data/lib/rdoc/markdown.kpeg +26 -19
  46. data/lib/rdoc/markdown.rb +326 -227
  47. data/lib/rdoc/markup/attr_changer.rb +0 -1
  48. data/lib/rdoc/markup/attr_span.rb +0 -1
  49. data/lib/rdoc/markup/attribute_manager.rb +29 -36
  50. data/lib/rdoc/markup/attributes.rb +0 -1
  51. data/lib/rdoc/markup/blank_line.rb +0 -1
  52. data/lib/rdoc/markup/block_quote.rb +0 -1
  53. data/lib/rdoc/markup/document.rb +0 -1
  54. data/lib/rdoc/markup/formatter.rb +0 -1
  55. data/lib/rdoc/markup/hard_break.rb +0 -1
  56. data/lib/rdoc/markup/heading.rb +0 -1
  57. data/lib/rdoc/markup/include.rb +0 -1
  58. data/lib/rdoc/markup/indented_paragraph.rb +0 -1
  59. data/lib/rdoc/markup/list.rb +0 -1
  60. data/lib/rdoc/markup/list_item.rb +0 -1
  61. data/lib/rdoc/markup/paragraph.rb +0 -1
  62. data/lib/rdoc/markup/parser.rb +12 -6
  63. data/lib/rdoc/markup/raw.rb +0 -1
  64. data/lib/rdoc/markup/regexp_handling.rb +0 -1
  65. data/lib/rdoc/markup/rule.rb +0 -1
  66. data/lib/rdoc/markup/to_ansi.rb +0 -1
  67. data/lib/rdoc/markup/to_html.rb +21 -16
  68. data/lib/rdoc/markup/to_html_crossref.rb +0 -1
  69. data/lib/rdoc/markup/to_html_snippet.rb +0 -1
  70. data/lib/rdoc/markup/to_joined_paragraph.rb +2 -3
  71. data/lib/rdoc/markup/to_label.rb +1 -2
  72. data/lib/rdoc/markup/to_markdown.rb +0 -1
  73. data/lib/rdoc/markup/to_rdoc.rb +3 -21
  74. data/lib/rdoc/markup/to_table_of_contents.rb +0 -1
  75. data/lib/rdoc/markup/to_test.rb +0 -1
  76. data/lib/rdoc/markup/to_tt_only.rb +0 -1
  77. data/lib/rdoc/markup/verbatim.rb +0 -1
  78. data/lib/rdoc/markup.rb +35 -667
  79. data/lib/rdoc/meta_method.rb +0 -1
  80. data/lib/rdoc/method_attr.rb +1 -2
  81. data/lib/rdoc/mixin.rb +0 -1
  82. data/lib/rdoc/normal_class.rb +1 -2
  83. data/lib/rdoc/normal_module.rb +1 -2
  84. data/lib/rdoc/options.rb +36 -20
  85. data/lib/rdoc/parser/c.rb +89 -101
  86. data/lib/rdoc/parser/changelog.rb +0 -1
  87. data/lib/rdoc/parser/markdown.rb +0 -2
  88. data/lib/rdoc/parser/rd.rb +0 -1
  89. data/lib/rdoc/parser/ripper_state_lex.rb +1 -1
  90. data/lib/rdoc/parser/ruby.rb +29 -14
  91. data/lib/rdoc/parser/ruby_tools.rb +0 -2
  92. data/lib/rdoc/parser/text.rb +0 -1
  93. data/lib/rdoc/parser.rb +19 -2
  94. data/lib/rdoc/rd/block_parser.rb +666 -12
  95. data/lib/rdoc/rd/block_parser.ry +13 -9
  96. data/lib/rdoc/rd/inline.rb +0 -1
  97. data/lib/rdoc/rd/inline_parser.rb +3 -1
  98. data/lib/rdoc/rd.rb +3 -4
  99. data/lib/rdoc/rdoc.rb +19 -7
  100. data/lib/rdoc/require.rb +0 -1
  101. data/lib/rdoc/ri/driver.rb +20 -86
  102. data/lib/rdoc/ri/store.rb +0 -1
  103. data/lib/rdoc/ri.rb +4 -5
  104. data/lib/rdoc/rubygems_hook.rb +1 -1
  105. data/lib/rdoc/servlet.rb +1 -1
  106. data/lib/rdoc/single_class.rb +5 -1
  107. data/lib/rdoc/stats/quiet.rb +0 -1
  108. data/lib/rdoc/stats/verbose.rb +0 -2
  109. data/lib/rdoc/stats.rb +3 -4
  110. data/lib/rdoc/store.rb +4 -4
  111. data/lib/rdoc/task.rb +31 -5
  112. data/lib/rdoc/token_stream.rb +0 -1
  113. data/lib/rdoc/top_level.rb +0 -1
  114. data/lib/rdoc/version.rb +3 -1
  115. data/lib/rdoc.rb +46 -46
  116. metadata +9 -11
  117. data/Gemfile +0 -12
  118. data/Rakefile +0 -107
  119. data/bin/console +0 -7
  120. data/bin/setup +0 -6
  121. data/rdoc.gemspec +0 -249
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6c9787594ed9d69a7a9177e449d925063acbc6ace0273f7d0b1fc9ca6a31139
4
- data.tar.gz: 5f5afd10a18a1aeabc8319350c191eeaa137e5f715a2e95cbf2443f5dca7f96c
3
+ metadata.gz: 947667e0cc733b38e36c829627ea1cca454420e44124b9536bf7f6ab7c687688
4
+ data.tar.gz: ce0d8a98c383e7c6b03138fbb62a31626bb24a20be3967aefa3c29a302b0d9f6
5
5
  SHA512:
6
- metadata.gz: 94fbc007d81c0cc1774b44d5f174b5e011ef5ae3d998344b981a8b6170f1c630c3c80e45f87bcc4c05f97f51e34e9f3ede791846e0c01e4015c45cc8aab1b05e
7
- data.tar.gz: '068da922a56b61ca85fa7b61d5554cdbe1533c30caae11e7d81894e41fca58157971c18a76c55391538324c168a720c2cbbc8150a12dc276eab033e70fae0217'
6
+ metadata.gz: dd6e321fe810da6ed4b5257df5347474adb514b061c9c5ad981c57feef340544e6e51fe9bfe48ef31bc7eaa87fc179883635d5448f6f2ab669443adcd6e98d46
7
+ data.tar.gz: 1c7d9158ca93ab8a913f282d6a641bc6d2f69eecf779b452d93fb935f6fde8e0e536d186ca8c2eba90a58a31ffd34cffd9af7a220fd5ff0ed63da6cf68ad8ed2
data/CONTRIBUTING.rdoc CHANGED
@@ -34,8 +34,7 @@ RDoc uses bundler for development. To get ready to work on RDoc run:
34
34
  This will install all the necessary dependencies for development with rake,
35
35
  generate documentation and run the tests for the first time.
36
36
 
37
- If the tests don't pass on the first run check the {Travis CI page for
38
- RDoc}[https://travis-ci.org/ruby/rdoc] to see if there are any known failures
37
+ If the tests don't pass on the first run check the {GitHub Actions page}[https://github.com/ruby/rdoc/actions] to see if there are any known failures
39
38
  (there shouldn't be).
40
39
 
41
40
  You can now use `rake` and `autotest` to run the tests.
data/LEGAL.rdoc CHANGED
@@ -5,7 +5,7 @@
5
5
  The files in this distribution are covered by the Ruby license (see LICENSE) except the features mentioned below:
6
6
 
7
7
  Darkfish::
8
- Darkfish was written by Michael Granger and is included under the MIT
8
+ Darkfish was written by Michael Granger and is included under the BSD 3-Clause
9
9
  license. Darkfish contains images from the Silk Icons set by Mark James.
10
10
 
11
11
  See lib/rdoc/generator/darkfish.rb for license information.
data/README.rdoc CHANGED
@@ -3,7 +3,7 @@
3
3
  home :: https://github.com/ruby/rdoc
4
4
  rdoc :: https://ruby.github.io/rdoc
5
5
  bugs :: https://github.com/ruby/rdoc/issues
6
- code quality :: {<img src="https://codeclimate.com/github/ruby/rdoc/badges/gpa.svg" alt="Code Climate">}[https://codeclimate.com/github/ruby/rdoc]
6
+ code quality :: https://codeclimate.com/github/ruby/rdoc
7
7
 
8
8
  == Description
9
9
 
@@ -46,7 +46,7 @@ contain just Markup-style markup (with or without leading '#' comment
46
46
  markers). If directory names are passed to RDoc, they are scanned
47
47
  recursively for C and Ruby source files only.
48
48
 
49
- To generate documentation using +rake+ see RDoc::Task[https://ruby.github.io/rdoc/RDocTask.html].
49
+ To generate documentation using +rake+ see RDoc::Task[https://ruby.github.io/rdoc/RDoc/Task.html].
50
50
 
51
51
  To generate documentation programmatically:
52
52
 
data/TODO.rdoc CHANGED
@@ -26,7 +26,7 @@ Nice to have:
26
26
  * Global variable support
27
27
  * Provide the code_object to directive handlers
28
28
 
29
- === 4
29
+ === More Future
30
30
 
31
31
  API changes to RDoc
32
32
 
data/exe/rdoc CHANGED
@@ -41,4 +41,3 @@ rescue Exception => e
41
41
 
42
42
  exit 1
43
43
  end
44
-
data/lib/rdoc/alias.rb CHANGED
@@ -109,4 +109,3 @@ class RDoc::Alias < RDoc::CodeObject
109
109
  end
110
110
 
111
111
  end
112
-
@@ -8,4 +8,3 @@
8
8
 
9
9
  class RDoc::AnonClass < RDoc::ClassModule
10
10
  end
11
-
@@ -115,6 +115,13 @@ class RDoc::AnyMethod < RDoc::MethodAttr
115
115
  @call_seq = call_seq
116
116
  end
117
117
 
118
+ ##
119
+ # Whether the method has a call-seq.
120
+
121
+ def has_call_seq?
122
+ !!(@call_seq || is_alias_for&._call_seq)
123
+ end
124
+
118
125
  ##
119
126
  # Loads is_alias_for from the internal name. Returns nil if the alias
120
127
  # cannot be found.
@@ -296,6 +303,14 @@ class RDoc::AnyMethod < RDoc::MethodAttr
296
303
  params
297
304
  end
298
305
 
306
+ ##
307
+ # Whether to skip the method description, true for methods that have
308
+ # aliases with a call-seq that doesn't include the method name.
309
+
310
+ def skip_description?
311
+ has_call_seq? && call_seq.nil? && !!(is_alias_for || !aliases.empty?)
312
+ end
313
+
299
314
  ##
300
315
  # Sets the store for this method and its referenced code objects.
301
316
 
@@ -350,12 +365,12 @@ class RDoc::AnyMethod < RDoc::MethodAttr
350
365
  ignore << is_alias_for.name
351
366
  ignore.concat is_alias_for.aliases.map(&:name)
352
367
  end
353
- ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n}
368
+ ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n}
354
369
  ignore.delete(method_name)
355
370
  ignore = Regexp.union(ignore)
356
371
 
357
372
  matching = entries.reject do |entry|
358
- entry =~ /^\w*\.?#{ignore}/ or
373
+ entry =~ /^\w*\.?#{ignore}[$\(\s]/ or
359
374
  entry =~ /\s#{ignore}\s/
360
375
  end
361
376
 
data/lib/rdoc/attr.rb CHANGED
@@ -173,4 +173,3 @@ class RDoc::Attr < RDoc::MethodAttr
173
173
  end
174
174
 
175
175
  end
176
-
@@ -799,4 +799,3 @@ class RDoc::ClassModule < RDoc::Context
799
799
  end
800
800
 
801
801
  end
802
-
@@ -2,5 +2,4 @@
2
2
  # This file was used to load all the RDoc::CodeObject subclasses at once. Now
3
3
  # autoload handles this.
4
4
 
5
- require 'rdoc'
6
-
5
+ require_relative '../rdoc'
data/lib/rdoc/comment.rb CHANGED
@@ -6,8 +6,8 @@
6
6
  # Each comment may have a different markup format set by #format=. By default
7
7
  # 'rdoc' is used. The :markup: directive tells RDoc which format to use.
8
8
  #
9
- # See RDoc::Markup@Other+directives for instructions on adding an alternate
10
- # format.
9
+ # See RDoc::MarkupReference@Directive+for+Specifying+RDoc+Source+Format.
10
+
11
11
 
12
12
  class RDoc::Comment
13
13
 
@@ -97,42 +97,26 @@ class RDoc::Comment
97
97
  # comment. The difficulty is to make sure not to match lines starting
98
98
  # with ARGF at the same indent, but that are after the first description
99
99
  # paragraph.
100
- if @text =~ /^\s*:?call-seq:(.*?(?:\S).*?)^\s*$/m then
100
+ if /^(?<S> ((?!\n)\s)*+ (?# whitespaces except newline))
101
+ :?call-seq:
102
+ (?<B> \g<S>(?<N>\n|\z) (?# trailing spaces))?
103
+ (?<seq>
104
+ (\g<S>(?!\w)\S.*\g<N>)*
105
+ (?>
106
+ (?<H> \g<S>\w+ (?# ' # ARGF' in the example above))
107
+ .*\g<N>)?
108
+ (\g<S>\S.*\g<N> (?# other non-blank line))*+
109
+ (\g<B>+(\k<H>.*\g<N> (?# ARGF.to_a lines))++)*+
110
+ )
111
+ (?m:^\s*$|\z)
112
+ /x =~ @text
113
+ seq = $~[:seq]
114
+
101
115
  all_start, all_stop = $~.offset(0)
102
- seq_start, seq_stop = $~.offset(1)
103
-
104
- # we get the following lines that start with the leading word at the
105
- # same indent, even if they have blank lines before
106
- if $1 =~ /(^\s*\n)+^(\s*\w+)/m then
107
- leading = $2 # ' * ARGF' in the example above
108
- re = %r%
109
- \A(
110
- (^\s*\n)+
111
- (^#{Regexp.escape leading}.*?\n)+
112
- )+
113
- ^\s*$
114
- %xm
115
-
116
- if @text[seq_stop..-1] =~ re then
117
- all_stop = seq_stop + $~.offset(0).last
118
- seq_stop = seq_stop + $~.offset(1).last
119
- end
120
- end
121
-
122
- seq = @text[seq_start..seq_stop]
123
- seq.gsub!(/^\s*(\S|\n)/m, '\1')
124
116
  @text.slice! all_start...all_stop
125
117
 
126
- method.call_seq = seq.chomp
127
-
128
- else
129
- regexp = /^\s*:?call-seq:(.*?)(^\s*$|\z)/m
130
- if regexp =~ @text then
131
- @text = @text.sub(regexp, '')
132
- seq = $1
133
- seq.gsub!(/^\s*/, '')
134
- method.call_seq = seq
135
- end
118
+ seq.gsub!(/^\s*/, '')
119
+ method.call_seq = seq
136
120
  end
137
121
 
138
122
  method
@@ -149,12 +133,7 @@ class RDoc::Comment
149
133
  # HACK dubious
150
134
 
151
135
  def encode! encoding
152
- # TODO: Remove this condition after Ruby 2.2 EOL
153
- if RUBY_VERSION < '2.3.0'
154
- @text = @text.force_encoding encoding
155
- else
156
- @text = String.new @text, encoding: encoding
157
- end
136
+ @text = String.new @text, encoding: encoding
158
137
  self
159
138
  end
160
139
 
data/lib/rdoc/constant.rb CHANGED
@@ -184,4 +184,3 @@ class RDoc::Constant < RDoc::CodeObject
184
184
  end
185
185
 
186
186
  end
187
-
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ require 'cgi/util'
3
+
2
4
  ##
3
5
  # A section of documentation like:
4
6
  #
@@ -229,4 +231,3 @@ class RDoc::Context::Section
229
231
  end
230
232
 
231
233
  end
232
-
data/lib/rdoc/context.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require 'cgi'
3
-
4
2
  ##
5
3
  # A Context is something that can hold modules, classes, methods, attributes,
6
4
  # aliases, requires, and includes. Classes, modules, and files are all
@@ -1261,6 +1259,6 @@ class RDoc::Context < RDoc::CodeObject
1261
1259
  klass
1262
1260
  end
1263
1261
 
1264
- autoload :Section, 'rdoc/context/section'
1262
+ autoload :Section, "#{__dir__}/context/section"
1265
1263
 
1266
1264
  end
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require_relative 'markup/attribute_manager' # for PROTECT_ATTR
4
+
2
5
  ##
3
6
  # RDoc::CrossReference is a reusable way to create cross references for names.
4
7
 
@@ -14,12 +17,25 @@ class RDoc::CrossReference
14
17
 
15
18
  CLASS_REGEXP_STR = '\\\\?((?:\:{2})?[A-Z]\w*(?:\:\:\w+)*)'
16
19
 
20
+ ##
21
+ # Regular expression to match a single method argument.
22
+
23
+ METHOD_ARG_REGEXP_STR = '[\w.+*/=<>-]+'
24
+
25
+ ##
26
+ # Regular expression to match method arguments.
27
+
28
+ METHOD_ARGS_REGEXP_STR = /(?:\((?:#{METHOD_ARG_REGEXP_STR}(?:,\s*#{METHOD_ARG_REGEXP_STR})*)?\))?/.source
29
+
17
30
  ##
18
31
  # Regular expression to match method references.
19
32
  #
20
33
  # See CLASS_REGEXP_STR
21
34
 
22
- METHOD_REGEXP_STR = '([A-Za-z]\w*[!?=]?|%|===?|\[\]=?|<<|>>|\+@|-@|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
35
+ METHOD_REGEXP_STR = /(
36
+ (?!\d)[\w#{RDoc::Markup::AttributeManager::PROTECT_ATTR}]+[!?=]?|
37
+ %|=(?:==?|~)|![=~]|\[\]=?|<(?:<|=>?)?|>[>=]?|[-+!]@?|\*\*?|[\/%\`|&^~]
38
+ )#{METHOD_ARGS_REGEXP_STR}/.source.delete("\n ").freeze
23
39
 
24
40
  ##
25
41
  # Regular expressions matching text that should potentially have
@@ -207,4 +223,3 @@ class RDoc::CrossReference
207
223
  end
208
224
 
209
225
  end
210
-
data/lib/rdoc/encoding.rb CHANGED
@@ -124,12 +124,7 @@ module RDoc::Encoding
124
124
  if text.kind_of? RDoc::Comment
125
125
  text.encode! encoding
126
126
  else
127
- # TODO: Remove this condition after Ruby 2.2 EOL
128
- if RUBY_VERSION < '2.3.0'
129
- text.force_encoding encoding
130
- else
131
- String.new text, encoding: encoding
132
- end
127
+ String.new text, encoding: encoding
133
128
  end
134
129
  end
135
130
 
@@ -16,4 +16,3 @@ class RDoc::ERBPartial < ERB
16
16
  end
17
17
 
18
18
  end
19
-
data/lib/rdoc/erbio.rb CHANGED
@@ -20,12 +20,8 @@ class RDoc::ERBIO < ERB
20
20
  ##
21
21
  # Defaults +eoutvar+ to 'io', otherwise is identical to ERB's initialize
22
22
 
23
- def initialize str, safe_level = nil, legacy_trim_mode = nil, legacy_eoutvar = 'io', trim_mode: nil, eoutvar: 'io'
24
- if RUBY_VERSION >= '2.6'
25
- super(str, trim_mode: trim_mode, eoutvar: eoutvar)
26
- else
27
- super(str, safe_level, legacy_trim_mode, legacy_eoutvar)
28
- end
23
+ def initialize str, trim_mode: nil, eoutvar: 'io'
24
+ super(str, trim_mode: trim_mode, eoutvar: eoutvar)
29
25
  end
30
26
 
31
27
  ##
@@ -39,4 +35,3 @@ class RDoc::ERBIO < ERB
39
35
  end
40
36
 
41
37
  end
42
-
data/lib/rdoc/extend.rb CHANGED
@@ -7,4 +7,3 @@
7
7
  class RDoc::Extend < RDoc::Mixin
8
8
 
9
9
  end
10
-
@@ -610,7 +610,7 @@ class RDoc::Generator::Darkfish
610
610
 
611
611
  @classes = @store.all_classes_and_modules.sort
612
612
  @files = @store.all_files.sort
613
- @methods = @classes.map { |m| m.method_list }.flatten.sort
613
+ @methods = @classes.flat_map { |m| m.method_list }.sort
614
614
  @modsort = get_sorted_module_list @classes
615
615
  end
616
616
 
@@ -778,11 +778,7 @@ class RDoc::Generator::Darkfish
778
778
  erbout = "_erbout_#{file_var}"
779
779
  end
780
780
 
781
- if RUBY_VERSION >= '2.6'
782
- template = klass.new template, trim_mode: '-', eoutvar: erbout
783
- else
784
- template = klass.new template, nil, '-', erbout
785
- end
781
+ template = klass.new template, trim_mode: '-', eoutvar: erbout
786
782
  @template_cache[file] = template
787
783
  template
788
784
  end
@@ -230,9 +230,9 @@ class RDoc::Generator::JsonIndex
230
230
  def index_methods
231
231
  debug_msg " generating method search index"
232
232
 
233
- list = @classes.uniq.map do |klass|
233
+ list = @classes.uniq.flat_map do |klass|
234
234
  klass.method_list
235
- end.flatten.sort_by do |method|
235
+ end.sort_by do |method|
236
236
  [method.name, method.parent.full_name]
237
237
  end
238
238
 
@@ -109,7 +109,7 @@ class RDoc::MethodAttr
109
109
  lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment
110
110
  lines.each do |line|
111
111
  if line =~ /^ *(?=\S)/
112
- n = $&.length
112
+ n = $~.end(0)
113
113
  indent = n if n < indent
114
114
  break if n == 0
115
115
  end
@@ -157,4 +157,3 @@ class RDoc::TopLevel
157
157
  end
158
158
 
159
159
  end
160
-
@@ -28,4 +28,3 @@ class RDoc::Generator::RI
28
28
  end
29
29
 
30
30
  end
31
-
@@ -3,18 +3,18 @@
3
3
  <title><%= h @title %></title>
4
4
 
5
5
  <script type="text/javascript">
6
- var rdoc_rel_prefix = "<%= asset_rel_prefix %>/";
7
- var index_rel_prefix = "<%= rel_prefix %>/";
6
+ var rdoc_rel_prefix = "<%= h asset_rel_prefix %>/";
7
+ var index_rel_prefix = "<%= h rel_prefix %>/";
8
8
  </script>
9
9
 
10
- <script src="<%= asset_rel_prefix %>/js/navigation.js" defer></script>
11
- <script src="<%= asset_rel_prefix %>/js/search.js" defer></script>
12
- <script src="<%= asset_rel_prefix %>/js/search_index.js" defer></script>
13
- <script src="<%= asset_rel_prefix %>/js/searcher.js" defer></script>
14
- <script src="<%= asset_rel_prefix %>/js/darkfish.js" defer></script>
10
+ <script src="<%= h asset_rel_prefix %>/js/navigation.js" defer></script>
11
+ <script src="<%= h asset_rel_prefix %>/js/search.js" defer></script>
12
+ <script src="<%= h asset_rel_prefix %>/js/search_index.js" defer></script>
13
+ <script src="<%= h asset_rel_prefix %>/js/searcher.js" defer></script>
14
+ <script src="<%= h asset_rel_prefix %>/js/darkfish.js" defer></script>
15
15
 
16
- <link href="<%= asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
17
- <link href="<%= asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
16
+ <link href="<%= h asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
17
+ <link href="<%= h asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
18
18
  <%- @options.template_stylesheets.each do |stylesheet| -%>
19
- <link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
19
+ <link href="<%= h asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
20
20
  <%- end -%>
@@ -1,9 +1,33 @@
1
1
  <div id="classindex-section" class="nav-section">
2
2
  <h3>Class and Module Index</h3>
3
3
 
4
+ <%-
5
+ all_classes = @classes.group_by do |klass|
6
+ klass.full_name[/\A[^:]++(?:::[^:]++(?=::))*+(?=::[^:]*+\z)/]
7
+ end.delete_if do |_, klasses|
8
+ !klasses.any?(&:display?)
9
+ end
10
+ link = proc do |index_klass, display = index_klass.display?|
11
+ if display
12
+ -%><code><a href="<%= rel_prefix %>/<%= index_klass.path %>"><%= index_klass.name %></a></code><%-
13
+ else
14
+ -%><code><%= index_klass.name %></code><%-
15
+ end
16
+ end
17
+ if top = all_classes[nil]
18
+ solo = top.one? {|klass| klass.display?}
19
+ traverse = proc do |klasses| -%>
4
20
  <ul class="link-list">
5
- <%- @modsort.each do |index_klass| -%>
6
- <li><a href="<%= rel_prefix %>/<%= index_klass.path %>"><%= index_klass.full_name %></a>
21
+ <%- klasses.each do |index_klass| -%>
22
+ <%- if children = all_classes[index_klass.full_name] -%>
23
+ <li><details<% if solo; solo = false %> open<% end %>><summary><% link.call(index_klass) %></summary>
24
+ <%- traverse.call(children) -%>
25
+ </ul></details>
26
+ <%- elsif index_klass.display? -%>
27
+ <li><% link.call(index_klass, true) %>
28
+ <%- end -%>
29
+ <%- end -%>
30
+ <%- end -%>
31
+ <%- traverse.call(top) -%>
7
32
  <%- end -%>
8
- </ul>
9
33
  </div>
@@ -1,11 +1,31 @@
1
1
  <%- simple_files = @files.select { |f| f.text? } %>
2
+ <%- if defined?(current) -%>
3
+ <%- dir = current.full_name[%r{\A[^/]+(?=/)}] || current.page_name -%>
4
+ <%- end -%>
2
5
  <%- unless simple_files.empty? then -%>
3
6
  <div id="fileindex-section" class="nav-section">
4
7
  <h3>Pages</h3>
5
8
 
6
9
  <ul class="link-list">
7
- <%- simple_files.each do |f| -%>
8
- <li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
10
+ <%- simple_files.group_by do |f| -%>
11
+ <%- f.full_name[%r{\A[^/]+(?=/)}] || f.page_name -%>
12
+ <%- end.each do |n, files| -%>
13
+ <%- f = files.shift -%>
14
+ <%- if files.empty? -%>
15
+ <li><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h f.page_name %></a>
16
+ <%- next -%>
17
+ <%- end -%>
18
+ <li><details<% if dir == n %> open<% end %>><summary><%
19
+ if n == f.page_name
20
+ %><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h n %></a><%
21
+ else
22
+ %><%= h n %><% files.unshift(f)
23
+ end %></summary>
24
+ <ul class="link-list">
25
+ <%- files.each do |f| -%>
26
+ <li><a href="<%= rel_prefix %>/<%= h f.path %>"><%= h f.page_name %></a>
27
+ <%- end -%>
28
+ </ul></details>
9
29
  <%- end -%>
10
30
  </ul>
11
31
  </div>
@@ -3,7 +3,7 @@
3
3
  <div id="search-field-wrapper">
4
4
  <input id="search-field" role="combobox" aria-label="Search"
5
5
  aria-autocomplete="list" aria-controls="search-results"
6
- type="text" name="search" placeholder="Search" spellcheck="false"
6
+ type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
7
7
  title="Type to search, Up and Down to navigate, Enter to load">
8
8
  </div>
9
9
 
@@ -3,16 +3,37 @@
3
3
  else
4
4
  current.comment
5
5
  end
6
- table = current.parse(comment).table_of_contents
6
+ table = current.parse(comment).table_of_contents.dup
7
7
 
8
8
  if table.length > 1 then %>
9
9
  <div class="nav-section">
10
10
  <h3>Table of Contents</h3>
11
11
 
12
+ <%- display_link = proc do |heading| -%>
13
+ <a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
14
+ <%- end -%>
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 -%>
23
+ <li>
24
+ <details open>
25
+ <summary><%- display_link.call heading -%></summary>
26
+ <ul class="link-list" role="directory">
27
+ <% list_siblings.call %>
28
+ </ul>
29
+ </details>
30
+ </li>
31
+ <%- end -%>
32
+ <%- end -%>
33
+ <%- end -%>
34
+
12
35
  <ul class="link-list" role="directory">
13
- <%- table.each do |heading| -%>
14
- <li><a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
15
- <%- end -%>
36
+ <% list_siblings.call %>
16
37
  </ul>
17
38
  </div>
18
39
  <%- end -%>
@@ -98,29 +98,36 @@
98
98
 
99
99
  <%- methods.each do |method| -%>
100
100
  <div id="<%= method.aref %>" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
101
- <%- if (call_seq = method.call_seq) then -%>
102
- <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
103
- <div class="method-heading">
104
- <span class="method-callseq">
105
- <%= h(call_seq.strip.
106
- gsub( /^\w+\./m, '')).
107
- gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
108
- </span>
109
- <%- if i == 0 and method.token_stream then -%>
110
- <span class="method-click-advice">click to toggle source</span>
111
- <%- end -%>
112
- </div>
113
- <%- end -%>
114
- <%- else -%>
115
- <div class="method-heading">
116
- <span class="method-name"><%= h method.name %></span><span
117
- class="method-args"><%= h method.param_seq %></span>
118
- <%- if method.token_stream then -%>
119
- <span class="method-click-advice">click to toggle source</span>
101
+ <div class="method-header">
102
+ <%- if (call_seq = method.call_seq) then -%>
103
+ <%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
104
+ <div class="method-heading">
105
+ <span class="method-callseq">
106
+ <%= h(call_seq.strip.
107
+ gsub( /^\w+\./m, '')).
108
+ gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
109
+ </span>
110
+ <%- if i == 0 and method.token_stream then -%>
111
+ <span class="method-click-advice">click to toggle source</span>
112
+ <%- end -%>
113
+ </div>
114
+ <%- end -%>
115
+ <%- elsif method.has_call_seq? then -%>
116
+ <div class="method-heading">
117
+ <span class="method-name"><%= h method.name %></span>
118
+ </div>
119
+ <%- else -%>
120
+ <div class="method-heading">
121
+ <span class="method-name"><%= h method.name %></span><span
122
+ class="method-args"><%= h method.param_seq %></span>
123
+ <%- if method.token_stream then -%>
124
+ <span class="method-click-advice">click to toggle source</span>
125
+ <%- end -%>
126
+ </div>
120
127
  <%- end -%>
121
128
  </div>
122
- <%- end -%>
123
129
 
130
+ <%- unless method.skip_description? then -%>
124
131
  <div class="method-description">
125
132
  <%- if method.comment then -%>
126
133
  <%= method.description.strip %>
@@ -143,6 +150,7 @@
143
150
  </div>
144
151
  <%- end -%>
145
152
  </div>
153
+ <%- end -%>
146
154
 
147
155
  <%- unless method.aliases.empty? then -%>
148
156
  <div class="aliases">