rdoc 6.3.3 → 6.6.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) 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 +21 -3
  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 +45 -19
  18. data/lib/rdoc/encoding.rb +1 -17
  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 +4 -8
  23. data/lib/rdoc/generator/json_index.rb +2 -2
  24. data/lib/rdoc/generator/markup.rb +1 -2
  25. data/lib/rdoc/generator/pot.rb +1 -0
  26. data/lib/rdoc/generator/ri.rb +0 -1
  27. data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -13
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  32. data/lib/rdoc/generator/template/darkfish/class.rhtml +28 -20
  33. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -7
  34. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  35. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  36. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +14 -1
  38. data/lib/rdoc/generator/template/darkfish/js/search.js +4 -4
  39. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +7 -6
  40. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  41. data/lib/rdoc/generator.rb +5 -5
  42. data/lib/rdoc/ghost_method.rb +0 -1
  43. data/lib/rdoc/i18n.rb +1 -1
  44. data/lib/rdoc/include.rb +0 -1
  45. data/lib/rdoc/known_classes.rb +5 -4
  46. data/lib/rdoc/markdown/entities.rb +0 -1
  47. data/lib/rdoc/markdown/literals.kpeg +0 -2
  48. data/lib/rdoc/markdown/literals.rb +73 -35
  49. data/lib/rdoc/markdown.kpeg +26 -19
  50. data/lib/rdoc/markdown.rb +326 -227
  51. data/lib/rdoc/markup/attr_changer.rb +0 -1
  52. data/lib/rdoc/markup/attr_span.rb +0 -1
  53. data/lib/rdoc/markup/attribute_manager.rb +32 -36
  54. data/lib/rdoc/markup/attributes.rb +0 -1
  55. data/lib/rdoc/markup/blank_line.rb +0 -1
  56. data/lib/rdoc/markup/block_quote.rb +0 -1
  57. data/lib/rdoc/markup/document.rb +0 -1
  58. data/lib/rdoc/markup/formatter.rb +1 -2
  59. data/lib/rdoc/markup/hard_break.rb +0 -1
  60. data/lib/rdoc/markup/heading.rb +0 -1
  61. data/lib/rdoc/markup/include.rb +0 -1
  62. data/lib/rdoc/markup/indented_paragraph.rb +0 -1
  63. data/lib/rdoc/markup/list.rb +0 -1
  64. data/lib/rdoc/markup/list_item.rb +0 -1
  65. data/lib/rdoc/markup/paragraph.rb +0 -1
  66. data/lib/rdoc/markup/parser.rb +17 -7
  67. data/lib/rdoc/markup/pre_process.rb +2 -0
  68. data/lib/rdoc/markup/raw.rb +0 -1
  69. data/lib/rdoc/markup/regexp_handling.rb +0 -1
  70. data/lib/rdoc/markup/rule.rb +0 -1
  71. data/lib/rdoc/markup/table.rb +11 -2
  72. data/lib/rdoc/markup/to_ansi.rb +0 -1
  73. data/lib/rdoc/markup/to_html.rb +27 -19
  74. data/lib/rdoc/markup/to_html_crossref.rb +1 -1
  75. data/lib/rdoc/markup/to_html_snippet.rb +3 -1
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +2 -3
  77. data/lib/rdoc/markup/to_label.rb +1 -2
  78. data/lib/rdoc/markup/to_markdown.rb +0 -1
  79. data/lib/rdoc/markup/to_rdoc.rb +3 -21
  80. data/lib/rdoc/markup/to_table_of_contents.rb +0 -1
  81. data/lib/rdoc/markup/to_test.rb +0 -1
  82. data/lib/rdoc/markup/to_tt_only.rb +0 -1
  83. data/lib/rdoc/markup/verbatim.rb +0 -1
  84. data/lib/rdoc/markup.rb +35 -667
  85. data/lib/rdoc/meta_method.rb +0 -1
  86. data/lib/rdoc/method_attr.rb +1 -2
  87. data/lib/rdoc/mixin.rb +0 -1
  88. data/lib/rdoc/normal_class.rb +1 -2
  89. data/lib/rdoc/normal_module.rb +1 -2
  90. data/lib/rdoc/options.rb +66 -21
  91. data/lib/rdoc/parser/c.rb +125 -124
  92. data/lib/rdoc/parser/changelog.rb +15 -1
  93. data/lib/rdoc/parser/markdown.rb +0 -2
  94. data/lib/rdoc/parser/rd.rb +0 -1
  95. data/lib/rdoc/parser/ripper_state_lex.rb +11 -1
  96. data/lib/rdoc/parser/ruby.rb +50 -14
  97. data/lib/rdoc/parser/ruby_tools.rb +0 -2
  98. data/lib/rdoc/parser/text.rb +0 -1
  99. data/lib/rdoc/parser.rb +19 -2
  100. data/lib/rdoc/rd/block_parser.rb +666 -12
  101. data/lib/rdoc/rd/block_parser.ry +13 -9
  102. data/lib/rdoc/rd/inline.rb +0 -1
  103. data/lib/rdoc/rd/inline_parser.rb +653 -3
  104. data/lib/rdoc/rd.rb +3 -4
  105. data/lib/rdoc/rdoc.rb +21 -37
  106. data/lib/rdoc/require.rb +0 -1
  107. data/lib/rdoc/ri/driver.rb +31 -90
  108. data/lib/rdoc/ri/store.rb +0 -1
  109. data/lib/rdoc/ri.rb +4 -5
  110. data/lib/rdoc/rubygems_hook.rb +4 -2
  111. data/lib/rdoc/servlet.rb +1 -1
  112. data/lib/rdoc/single_class.rb +5 -1
  113. data/lib/rdoc/stats/quiet.rb +0 -1
  114. data/lib/rdoc/stats/verbose.rb +0 -2
  115. data/lib/rdoc/stats.rb +3 -4
  116. data/lib/rdoc/store.rb +29 -19
  117. data/lib/rdoc/task.rb +31 -5
  118. data/lib/rdoc/text.rb +22 -4
  119. data/lib/rdoc/token_stream.rb +1 -2
  120. data/lib/rdoc/top_level.rb +3 -1
  121. data/lib/rdoc/version.rb +3 -1
  122. data/lib/rdoc.rb +58 -46
  123. metadata +13 -18
  124. data/Gemfile +0 -12
  125. data/Rakefile +0 -101
  126. data/bin/console +0 -7
  127. data/bin/setup +0 -6
  128. data/rdoc.gemspec +0 -249
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 120ff1fdb58f0543a2a49d1e4fffc2ebaf3f1bcd9f3cd2006f4130b6a4caa330
4
- data.tar.gz: 7c8dabbb3b1256e4bca4b2a14dfb216d43f9bb3acb26d5277b7acbbf6212f5eb
3
+ metadata.gz: febf92bf44319e2f1332649bd680816b7fba107c9b4cbf57f490e6f1d1a72a9f
4
+ data.tar.gz: 35fe427a44b35e1321cd9be4a5d23234643cbceb9ca79937e2f47081e9875012
5
5
  SHA512:
6
- metadata.gz: 38fa507c6bf06b2697642b7a133fcb42ed256aa7b788c7ca6eaba7545d92e071325e2b175020716fca082864efff9e2702aa05f5e5b758e06aa3c3947c972449
7
- data.tar.gz: 655ceb71a41d8e17202c9ecab7dd41af87f30fd16a5be757778f3671563f8779f82982b223b68610c9a7e37899e5311a9614fbbb7df8f80c9533358a4db480cf
6
+ metadata.gz: 10f7cd4ec5f7c90aa2214615ebc635680e120ce1eca0b2f8d4b4f77cac3ebdbe87102c3564542ca2e13fc06501478354dda3b443c1a0883f82d50f0092e25a7e
7
+ data.tar.gz: 01530b6cd051f153e33e4a3981f29b4ba5ecdf00ac3c67541de37aeadec0991983697a3a094a3a1d3f8ad85a978e631aaa1507e4091a3b96ca031ea9a60bb548
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
-
@@ -26,6 +26,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
26
26
 
27
27
  attr_accessor :c_function
28
28
 
29
+ # The section title of the method (if defined in a C file via +:category:+)
30
+ attr_accessor :section_title
31
+
29
32
  # Parameters for this method
30
33
 
31
34
  attr_accessor :params
@@ -112,6 +115,13 @@ class RDoc::AnyMethod < RDoc::MethodAttr
112
115
  @call_seq = call_seq
113
116
  end
114
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
+
115
125
  ##
116
126
  # Loads is_alias_for from the internal name. Returns nil if the alias
117
127
  # cannot be found.
@@ -293,6 +303,14 @@ class RDoc::AnyMethod < RDoc::MethodAttr
293
303
  params
294
304
  end
295
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
+
296
314
  ##
297
315
  # Sets the store for this method and its referenced code objects.
298
316
 
@@ -347,15 +365,15 @@ class RDoc::AnyMethod < RDoc::MethodAttr
347
365
  ignore << is_alias_for.name
348
366
  ignore.concat is_alias_for.aliases.map(&:name)
349
367
  end
350
- ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n}
368
+ ignore.map! { |n| n =~ /\A\[/ ? /\[.*\]/ : n}
351
369
  ignore.delete(method_name)
352
370
  ignore = Regexp.union(ignore)
353
371
 
354
372
  matching = entries.reject do |entry|
355
- entry =~ /^\w*\.?#{ignore}/ or
373
+ entry =~ /^\w*\.?#{ignore}[$\(\s]/ or
356
374
  entry =~ /\s#{ignore}\s/
357
375
  end
358
376
 
359
- matching.join "\n"
377
+ matching.empty? ? nil : matching.join("\n")
360
378
  end
361
379
  end
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-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
@@ -34,12 +50,6 @@ class RDoc::CrossReference
34
50
  # A::B::C.meth
35
51
  #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
36
52
 
37
- # Stand-alone method (preceded by a #)
38
- | \\?\##{METHOD_REGEXP_STR}
39
-
40
- # Stand-alone method (preceded by ::)
41
- | ::#{METHOD_REGEXP_STR}
42
-
43
53
  # A::B::C
44
54
  # The stuff after CLASS_REGEXP_STR is a
45
55
  # nasty hack. CLASS_REGEXP_STR unfortunately matches
@@ -56,6 +66,12 @@ class RDoc::CrossReference
56
66
  # marker.
57
67
  | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
58
68
 
69
+ # Stand-alone method (preceded by a #)
70
+ | \\?\##{METHOD_REGEXP_STR}
71
+
72
+ # Stand-alone method (preceded by ::)
73
+ | ::#{METHOD_REGEXP_STR}
74
+
59
75
  # Things that look like filenames
60
76
  # The key thing is that there must be at least
61
77
  # one special character (period, slash, or
@@ -82,12 +98,12 @@ class RDoc::CrossReference
82
98
  # A::B::C.meth
83
99
  #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
84
100
 
85
- # Stand-alone method
86
- | \\?#{METHOD_REGEXP_STR}
87
-
88
101
  # A::B::C
89
102
  | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
90
103
 
104
+ # Stand-alone method
105
+ | \\?#{METHOD_REGEXP_STR}
106
+
91
107
  # Things that look like filenames
92
108
  | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
93
109
 
@@ -116,14 +132,10 @@ class RDoc::CrossReference
116
132
  end
117
133
 
118
134
  ##
119
- # Returns a reference to +name+.
120
- #
121
- # If the reference is found and +name+ is not documented +text+ will be
122
- # returned. If +name+ is escaped +name+ is returned. If +name+ is not
123
- # found +text+ is returned.
135
+ # Returns a method reference to +name+.
124
136
 
125
- def resolve name, text
126
- return @seen[name] if @seen.include? name
137
+ def resolve_method name
138
+ ref = nil
127
139
 
128
140
  if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/o =~ name then
129
141
  type = $2
@@ -165,12 +177,27 @@ class RDoc::CrossReference
165
177
  end
166
178
  end
167
179
 
180
+ ref
181
+ end
182
+
183
+ ##
184
+ # Returns a reference to +name+.
185
+ #
186
+ # If the reference is found and +name+ is not documented +text+ will be
187
+ # returned. If +name+ is escaped +name+ is returned. If +name+ is not
188
+ # found +text+ is returned.
189
+
190
+ def resolve name, text
191
+ return @seen[name] if @seen.include? name
192
+
168
193
  ref = case name
169
194
  when /^\\(#{CLASS_REGEXP_STR})$/o then
170
195
  @context.find_symbol $1
171
196
  else
172
197
  @context.find_symbol name
173
- end unless ref
198
+ end
199
+
200
+ ref = resolve_method name unless ref
174
201
 
175
202
  # Try a page name
176
203
  ref = @store.page name if not ref and name =~ /^[\w.]+$/
@@ -199,4 +226,3 @@ class RDoc::CrossReference
199
226
  end
200
227
 
201
228
  end
202
-
data/lib/rdoc/encoding.rb CHANGED
@@ -86,17 +86,6 @@ module RDoc::Encoding
86
86
  nil
87
87
  end
88
88
 
89
- def self.remove_frozen_string_literal string
90
- string =~ /\A(?:#!.*\n)?(.*\n)/
91
- first_line = $1
92
-
93
- if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i
94
- string = string.sub first_line, ''
95
- end
96
-
97
- string
98
- end
99
-
100
89
  ##
101
90
  # Detects the encoding of +string+ based on the magic comment
102
91
 
@@ -124,12 +113,7 @@ module RDoc::Encoding
124
113
  if text.kind_of? RDoc::Comment
125
114
  text.encode! encoding
126
115
  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
116
+ String.new text, encoding: encoding
133
117
  end
134
118
  end
135
119
 
@@ -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
-
@@ -220,8 +220,8 @@ class RDoc::Generator::Darkfish
220
220
  install_rdoc_static_file @template_dir + item, "./#{item}", options
221
221
  end
222
222
 
223
- @options.template_stylesheets.each do |stylesheet|
224
- FileUtils.cp stylesheet, '.', options
223
+ unless @options.template_stylesheets.empty?
224
+ FileUtils.cp @options.template_stylesheets, '.', **options
225
225
  end
226
226
 
227
227
  Dir[(@template_dir + "{js,images}/**/*").to_s].each do |path|
@@ -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
-
@@ -81,6 +81,7 @@ class RDoc::Generator::POT
81
81
  end
82
82
  end
83
83
 
84
+ # :nodoc:
84
85
  def class_dir
85
86
  nil
86
87
  end
@@ -28,4 +28,3 @@ class RDoc::Generator::RI
28
28
  end
29
29
 
30
30
  end
31
-
@@ -3,20 +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">
18
- <%- if @options.template_stylesheets.flatten.any? then -%>
19
- <%- @options.template_stylesheets.flatten.each do |stylesheet| -%>
20
- <link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
21
- <%- end -%>
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
+ <%- @options.template_stylesheets.each do |stylesheet| -%>
19
+ <link href="<%= h asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
22
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