rdoc 5.0.0 → 6.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (158) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +4 -4
  3. data/Gemfile +9 -0
  4. data/History.rdoc +12 -2
  5. data/README.rdoc +5 -6
  6. data/Rakefile +35 -65
  7. data/lib/rdoc/alias.rb +1 -1
  8. data/lib/rdoc/anon_class.rb +1 -1
  9. data/lib/rdoc/any_method.rb +59 -15
  10. data/lib/rdoc/attr.rb +1 -1
  11. data/lib/rdoc/class_module.rb +5 -3
  12. data/lib/rdoc/code_object.rb +2 -9
  13. data/lib/rdoc/code_objects.rb +1 -1
  14. data/lib/rdoc/comment.rb +32 -11
  15. data/lib/rdoc/constant.rb +3 -3
  16. data/lib/rdoc/context/section.rb +1 -14
  17. data/lib/rdoc/context.rb +74 -21
  18. data/lib/rdoc/cross_reference.rb +33 -15
  19. data/lib/rdoc/encoding.rb +58 -30
  20. data/lib/rdoc/erb_partial.rb +2 -2
  21. data/lib/rdoc/erbio.rb +8 -4
  22. data/lib/rdoc/extend.rb +1 -1
  23. data/lib/rdoc/generator/darkfish.rb +60 -29
  24. data/lib/rdoc/generator/json_index.rb +7 -4
  25. data/lib/rdoc/generator/markup.rb +3 -13
  26. data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
  27. data/lib/rdoc/generator/pot/po.rb +3 -3
  28. data/lib/rdoc/generator/pot/po_entry.rb +11 -11
  29. data/lib/rdoc/generator/pot.rb +4 -4
  30. data/lib/rdoc/generator/ri.rb +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  44. data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
  45. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
  46. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  47. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +22 -99
  48. data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
  49. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  50. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  51. data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
  52. data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
  53. data/lib/rdoc/generator.rb +1 -1
  54. data/lib/rdoc/ghost_method.rb +1 -1
  55. data/lib/rdoc/i18n/locale.rb +2 -2
  56. data/lib/rdoc/i18n/text.rb +5 -5
  57. data/lib/rdoc/i18n.rb +3 -3
  58. data/lib/rdoc/include.rb +1 -1
  59. data/lib/rdoc/known_classes.rb +1 -1
  60. data/lib/rdoc/markdown/entities.rb +1 -1
  61. data/lib/rdoc/markdown/literals.kpeg +1 -0
  62. data/lib/rdoc/markdown/literals.rb +19 -7
  63. data/lib/rdoc/markdown.kpeg +92 -44
  64. data/lib/rdoc/markdown.rb +1171 -610
  65. data/lib/rdoc/markup/attr_changer.rb +1 -1
  66. data/lib/rdoc/markup/attr_span.rb +9 -3
  67. data/lib/rdoc/markup/attribute_manager.rb +115 -50
  68. data/lib/rdoc/markup/attributes.rb +7 -7
  69. data/lib/rdoc/markup/blank_line.rb +1 -1
  70. data/lib/rdoc/markup/block_quote.rb +1 -1
  71. data/lib/rdoc/markup/document.rb +1 -1
  72. data/lib/rdoc/markup/formatter.rb +25 -24
  73. data/lib/rdoc/markup/hard_break.rb +1 -1
  74. data/lib/rdoc/markup/heading.rb +4 -4
  75. data/lib/rdoc/markup/include.rb +1 -1
  76. data/lib/rdoc/markup/indented_paragraph.rb +1 -1
  77. data/lib/rdoc/markup/list.rb +1 -1
  78. data/lib/rdoc/markup/list_item.rb +1 -1
  79. data/lib/rdoc/markup/paragraph.rb +1 -1
  80. data/lib/rdoc/markup/parser.rb +79 -47
  81. data/lib/rdoc/markup/pre_process.rb +11 -6
  82. data/lib/rdoc/markup/raw.rb +1 -1
  83. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  84. data/lib/rdoc/markup/rule.rb +1 -1
  85. data/lib/rdoc/markup/to_ansi.rb +1 -1
  86. data/lib/rdoc/markup/to_bs.rb +4 -4
  87. data/lib/rdoc/markup/to_html.rb +71 -26
  88. data/lib/rdoc/markup/to_html_crossref.rb +41 -26
  89. data/lib/rdoc/markup/to_html_snippet.rb +10 -10
  90. data/lib/rdoc/markup/to_joined_paragraph.rb +7 -32
  91. data/lib/rdoc/markup/to_label.rb +10 -10
  92. data/lib/rdoc/markup/to_markdown.rb +9 -9
  93. data/lib/rdoc/markup/to_rdoc.rb +35 -7
  94. data/lib/rdoc/markup/to_table_of_contents.rb +2 -1
  95. data/lib/rdoc/markup/to_test.rb +1 -1
  96. data/lib/rdoc/markup/to_tt_only.rb +3 -3
  97. data/lib/rdoc/markup/verbatim.rb +1 -1
  98. data/lib/rdoc/markup.rb +14 -17
  99. data/lib/rdoc/meta_method.rb +1 -1
  100. data/lib/rdoc/method_attr.rb +2 -2
  101. data/lib/rdoc/mixin.rb +1 -1
  102. data/lib/rdoc/normal_class.rb +3 -3
  103. data/lib/rdoc/normal_module.rb +1 -1
  104. data/lib/rdoc/options.rb +79 -21
  105. data/lib/rdoc/parser/c.rb +147 -194
  106. data/lib/rdoc/parser/changelog.rb +150 -19
  107. data/lib/rdoc/parser/markdown.rb +1 -1
  108. data/lib/rdoc/parser/rd.rb +1 -1
  109. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  110. data/lib/rdoc/parser/ruby.rb +634 -465
  111. data/lib/rdoc/parser/ruby_tools.rb +33 -34
  112. data/lib/rdoc/parser/simple.rb +3 -3
  113. data/lib/rdoc/parser/text.rb +1 -1
  114. data/lib/rdoc/parser.rb +12 -35
  115. data/lib/rdoc/rd/block_parser.rb +109 -108
  116. data/lib/rdoc/rd/block_parser.ry +3 -3
  117. data/lib/rdoc/rd/inline.rb +5 -5
  118. data/lib/rdoc/rd/inline_parser.rb +186 -185
  119. data/lib/rdoc/rd/inline_parser.ry +1 -1
  120. data/lib/rdoc/rd.rb +1 -1
  121. data/lib/rdoc/rdoc.rb +54 -41
  122. data/lib/rdoc/require.rb +1 -1
  123. data/lib/rdoc/ri/driver.rb +132 -42
  124. data/lib/rdoc/ri/formatter.rb +1 -1
  125. data/lib/rdoc/ri/paths.rb +4 -18
  126. data/lib/rdoc/ri/store.rb +1 -1
  127. data/lib/rdoc/ri/task.rb +2 -2
  128. data/lib/rdoc/ri.rb +1 -1
  129. data/lib/rdoc/rubygems_hook.rb +3 -3
  130. data/lib/rdoc/servlet.rb +21 -12
  131. data/lib/rdoc/single_class.rb +1 -1
  132. data/lib/rdoc/stats/normal.rb +24 -18
  133. data/lib/rdoc/stats/quiet.rb +1 -1
  134. data/lib/rdoc/stats/verbose.rb +1 -1
  135. data/lib/rdoc/stats.rb +1 -1
  136. data/lib/rdoc/store.rb +38 -27
  137. data/lib/rdoc/task.rb +2 -2
  138. data/lib/rdoc/text.rb +16 -21
  139. data/lib/rdoc/token_stream.rb +56 -33
  140. data/lib/rdoc/tom_doc.rb +17 -12
  141. data/lib/rdoc/top_level.rb +9 -3
  142. data/lib/rdoc/version.rb +8 -0
  143. data/lib/rdoc.rb +24 -10
  144. data/man/ri.1 +247 -0
  145. data/rdoc.gemspec +206 -15
  146. metadata +15 -64
  147. data/.document +0 -5
  148. data/.gitignore +0 -13
  149. data/.travis.yml +0 -23
  150. data/lib/gauntlet_rdoc.rb +0 -82
  151. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  152. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  153. data/lib/rdoc/markup/inline.rb +0 -2
  154. data/lib/rdoc/markup/special.rb +0 -41
  155. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
  156. data/lib/rdoc/ruby_lex.rb +0 -1367
  157. data/lib/rdoc/ruby_token.rb +0 -461
  158. data/lib/rdoc/test_case.rb +0 -204
data/lib/rdoc/task.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  # Copyright (c) 2003, 2004 Jim Weirich, 2009 Eric Hodel
4
4
  #
@@ -128,7 +128,7 @@ class RDoc::Task < Rake::TaskLib
128
128
  attr_accessor :template
129
129
 
130
130
  ##
131
- # Name of format generator (<tt>--format<tt>) used by rdoc. (defaults to
131
+ # Name of format generator (<tt>--format</tt>) used by rdoc. (defaults to
132
132
  # rdoc's default)
133
133
 
134
134
  attr_accessor :generator
data/lib/rdoc/text.rb CHANGED
@@ -1,26 +1,17 @@
1
- # coding: utf-8
2
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
3
2
 
4
3
  ##
5
4
  # For RDoc::Text#to_html
6
5
 
7
6
  require 'strscan'
8
7
 
9
- ##
10
- # For RDoc::Text#snippet
11
-
12
- begin
13
- gem 'json'
14
- rescue NameError => e # --disable-gems
15
- raise unless e.name == :gem
16
- rescue Gem::LoadError
17
- end
18
-
19
8
  ##
20
9
  # Methods for manipulating comment text
21
10
 
22
11
  module RDoc::Text
23
12
 
13
+ attr_accessor :language
14
+
24
15
  ##
25
16
  # Maps markup formats to classes that can parse them. If the format is
26
17
  # unknown, "rdoc" format is used.
@@ -71,7 +62,7 @@ module RDoc::Text
71
62
  text.each_line do |line|
72
63
  nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do
73
64
  r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
74
- r.force_encoding text.encoding
65
+ r = RDoc::Encoding.change_encoding r, text.encoding
75
66
  r
76
67
  end
77
68
 
@@ -93,7 +84,7 @@ module RDoc::Text
93
84
  end
94
85
 
95
86
  empty = ''
96
- empty.force_encoding text.encoding
87
+ empty = RDoc::Encoding.change_encoding empty, text.encoding
97
88
 
98
89
  text.gsub(/^ {0,#{indent}}/, empty)
99
90
  end
@@ -122,8 +113,12 @@ module RDoc::Text
122
113
  def normalize_comment text
123
114
  return text if text.empty?
124
115
 
125
- text = strip_stars text
126
- text = strip_hashes text
116
+ case language
117
+ when :ruby
118
+ text = strip_hashes text
119
+ when :c
120
+ text = strip_stars text
121
+ end
127
122
  text = expand_tabs text
128
123
  text = flush_left text
129
124
  text = strip_newlines text
@@ -160,7 +155,7 @@ module RDoc::Text
160
155
  return text if text =~ /^(?>\s*)[^\#]/
161
156
 
162
157
  empty = ''
163
- empty.force_encoding text.encoding
158
+ empty = RDoc::Encoding.change_encoding empty, text.encoding
164
159
 
165
160
  text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty)
166
161
  end
@@ -180,17 +175,17 @@ module RDoc::Text
180
175
 
181
176
  encoding = text.encoding
182
177
 
183
- text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, ''
178
+ text = text.gsub %r%Document-method:\s+[\w:.#=!?|^&<>~+\-/*\%@`\[\]]+%, ''
184
179
 
185
180
  space = ' '
186
- space.force_encoding encoding if encoding
181
+ space = RDoc::Encoding.change_encoding space, encoding if encoding
187
182
 
188
183
  text.sub! %r%/\*+% do space * $&.length end
189
184
  text.sub! %r%\*+/% do space * $&.length end
190
185
  text.gsub! %r%^[ \t]*\*%m do space * $&.length end
191
186
 
192
187
  empty = ''
193
- empty.force_encoding encoding if encoding
188
+ empty = RDoc::Encoding.change_encoding empty, encoding if encoding
194
189
  text.gsub(/^\s+$/, empty)
195
190
  end
196
191
 
@@ -199,7 +194,7 @@ module RDoc::Text
199
194
  # trademark symbols in +text+ to properly encoded characters.
200
195
 
201
196
  def to_html text
202
- html = ''.encode text.encoding
197
+ html = (''.encode text.encoding).dup
203
198
 
204
199
  encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]
205
200
 
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A TokenStream is a list of tokens, gathered during the parse of some entity
4
4
  # (say a method). Entities populate these streams by being registered with the
@@ -10,43 +10,61 @@ module RDoc::TokenStream
10
10
 
11
11
  ##
12
12
  # Converts +token_stream+ to HTML wrapping various tokens with
13
- # <tt><span></tt> elements. The following tokens types are wrapped in spans
14
- # with the given class names:
15
- #
16
- # TkCONSTANT :: 'ruby-constant'
17
- # TkKW :: 'ruby-keyword'
18
- # TkIVAR :: 'ruby-ivar'
19
- # TkOp :: 'ruby-operator'
20
- # TkId :: 'ruby-identifier'
21
- # TkNode :: 'ruby-node'
22
- # TkCOMMENT :: 'ruby-comment'
23
- # TkREGEXP :: 'ruby-regexp'
24
- # TkSTRING :: 'ruby-string'
25
- # TkVal :: 'ruby-value'
26
- #
27
- # Other token types are not wrapped in spans.
13
+ # <tt><span></tt> elements. Some tokens types are wrapped in spans
14
+ # with the given class names. Other token types are not wrapped in spans.
28
15
 
29
16
  def self.to_html token_stream
17
+ starting_title = false
18
+
30
19
  token_stream.map do |t|
31
20
  next unless t
32
21
 
33
- style = case t
34
- when RDoc::RubyToken::TkCONSTANT then 'ruby-constant'
35
- when RDoc::RubyToken::TkKW then 'ruby-keyword'
36
- when RDoc::RubyToken::TkIVAR then 'ruby-ivar'
37
- when RDoc::RubyToken::TkOp then 'ruby-operator'
38
- when RDoc::RubyToken::TkId then 'ruby-identifier'
39
- when RDoc::RubyToken::TkNode then 'ruby-node'
40
- when RDoc::RubyToken::TkCOMMENT then 'ruby-comment'
41
- when RDoc::RubyToken::TkREGEXP then 'ruby-regexp'
42
- when RDoc::RubyToken::TkSTRING then 'ruby-string'
43
- when RDoc::RubyToken::TkVal then 'ruby-value'
22
+ style = case t[:kind]
23
+ when :on_const then 'ruby-constant'
24
+ when :on_kw then 'ruby-keyword'
25
+ when :on_ivar then 'ruby-ivar'
26
+ when :on_cvar then 'ruby-identifier'
27
+ when :on_gvar then 'ruby-identifier'
28
+ when '=' != t[:text] && :on_op
29
+ then 'ruby-operator'
30
+ when :on_tlambda then 'ruby-operator'
31
+ when :on_ident then 'ruby-identifier'
32
+ when :on_label then 'ruby-value'
33
+ when :on_backref, :on_dstring
34
+ then 'ruby-node'
35
+ when :on_comment then 'ruby-comment'
36
+ when :on_embdoc then 'ruby-comment'
37
+ when :on_regexp then 'ruby-regexp'
38
+ when :on_tstring then 'ruby-string'
39
+ when :on_int, :on_float,
40
+ :on_rational, :on_imaginary,
41
+ :on_heredoc,
42
+ :on_symbol, :on_CHAR then 'ruby-value'
43
+ when :on_heredoc_beg, :on_heredoc_end
44
+ then 'ruby-identifier'
44
45
  end
45
46
 
46
- text = CGI.escapeHTML t.text
47
+ comment_with_nl = false
48
+ if :on_comment == t[:kind] or :on_embdoc == t[:kind] or :on_heredoc_end == t[:kind]
49
+ comment_with_nl = true if "\n" == t[:text][-1]
50
+ text = t[:text].rstrip
51
+ else
52
+ text = t[:text]
53
+ end
54
+
55
+ if :on_ident == t[:kind] && starting_title
56
+ starting_title = false
57
+ style = 'ruby-identifier ruby-title'
58
+ end
59
+
60
+ if :on_kw == t[:kind] and 'def' == t[:text]
61
+ starting_title = true
62
+ end
63
+
64
+ text = CGI.escapeHTML text
47
65
 
48
66
  if style then
49
- "<span class=\"#{style}\">#{text}</span>"
67
+ "<span class=\"#{style}\">#{text}</span>#{"\n" if comment_with_nl}"
50
68
  else
51
69
  text
52
70
  end
@@ -56,11 +74,16 @@ module RDoc::TokenStream
56
74
  ##
57
75
  # Adds +tokens+ to the collected tokens
58
76
 
59
- def add_tokens(*tokens)
60
- tokens.flatten.each { |token| @token_stream << token }
77
+ def add_tokens(tokens)
78
+ @token_stream.concat(tokens)
61
79
  end
62
80
 
63
- alias add_token add_tokens
81
+ ##
82
+ # Adds one +token+ to the collected tokens
83
+
84
+ def add_token(token)
85
+ @token_stream.push(token)
86
+ end
64
87
 
65
88
  ##
66
89
  # Starts collecting tokens
@@ -89,7 +112,7 @@ module RDoc::TokenStream
89
112
  # Returns a string representation of the token stream
90
113
 
91
114
  def tokens_to_s
92
- token_stream.compact.map { |token| token.text }.join ''
115
+ token_stream.compact.map { |token| token[:text] }.join ''
93
116
  end
94
117
 
95
118
  end
data/lib/rdoc/tom_doc.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  # :markup: tomdoc
3
3
 
4
4
  # A parser for TomDoc based on TomDoc 1.0.0-rc1 (02adef9b5a)
@@ -180,12 +180,19 @@ class RDoc::TomDoc < RDoc::Markup::Parser
180
180
 
181
181
  case type
182
182
  when :TEXT then
183
- @section = 'Returns' if data =~ /\AReturns/
183
+ @section = 'Returns' if data =~ /\A(Returns|Raises)/
184
184
 
185
185
  paragraph << data
186
186
  when :NEWLINE then
187
187
  if :TEXT == peek_token[0] then
188
- paragraph << ' '
188
+ # Lines beginning with 'Raises' in the Returns section should not be
189
+ # treated as multiline text
190
+ if 'Returns' == @section and
191
+ peek_token[1].start_with?('Raises') then
192
+ break
193
+ else
194
+ paragraph << ' '
195
+ end
189
196
  else
190
197
  break
191
198
  end
@@ -222,7 +229,7 @@ class RDoc::TomDoc < RDoc::Markup::Parser
222
229
  # Returns self.
223
230
 
224
231
  def tokenize text
225
- text.sub!(/\A(Public|Internal|Deprecated):\s+/, '')
232
+ text = text.sub(/\A(Public|Internal|Deprecated):\s+/, '')
226
233
 
227
234
  setup_scanner text
228
235
 
@@ -235,19 +242,18 @@ class RDoc::TomDoc < RDoc::Markup::Parser
235
242
 
236
243
  @tokens << case
237
244
  when @s.scan(/\r?\n/) then
238
- token = [:NEWLINE, @s.matched, *token_pos(pos)]
239
- @line_pos = char_pos @s.pos
240
- @line += 1
245
+ token = [:NEWLINE, @s.matched, *pos]
246
+ @s.newline!
241
247
  token
242
248
  when @s.scan(/(Examples|Signature)$/) then
243
- @tokens << [:HEADER, 3, *token_pos(pos)]
249
+ @tokens << [:HEADER, 3, *pos]
244
250
 
245
- [:TEXT, @s[1], *token_pos(pos)]
251
+ [:TEXT, @s[1], *pos]
246
252
  when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
247
- [:NOTE, @s[1], *token_pos(pos)]
253
+ [:NOTE, @s[1], *pos]
248
254
  else
249
255
  @s.scan(/.*/)
250
- [:TEXT, @s.matched.sub(/\r$/, ''), *token_pos(pos)]
256
+ [:TEXT, @s.matched.sub(/\r$/, ''), *pos]
251
257
  end
252
258
  end
253
259
 
@@ -255,4 +261,3 @@ class RDoc::TomDoc < RDoc::Markup::Parser
255
261
  end
256
262
 
257
263
  end
258
-
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A TopLevel context is a representation of the contents of a single file
4
4
 
@@ -33,7 +33,7 @@ class RDoc::TopLevel < RDoc::Context
33
33
  ##
34
34
  # The parser class that processed this file
35
35
 
36
- attr_accessor :parser
36
+ attr_reader :parser
37
37
 
38
38
  ##
39
39
  # Creates a new TopLevel for the file at +absolute_name+. If documentation
@@ -52,6 +52,12 @@ class RDoc::TopLevel < RDoc::Context
52
52
  @classes_or_modules = []
53
53
  end
54
54
 
55
+ def parser=(val)
56
+ @parser = val
57
+ @store.update_parser_of_file(absolute_name, val) if @store
58
+ @parser
59
+ end
60
+
55
61
  ##
56
62
  # An RDoc::TopLevel is equal to another with the same relative_name
57
63
 
@@ -272,7 +278,7 @@ class RDoc::TopLevel < RDoc::Context
272
278
  # Is this TopLevel from a text file instead of a source code file?
273
279
 
274
280
  def text?
275
- @parser and @parser.ancestors.include? RDoc::Parser::Text
281
+ @parser and @parser.include? RDoc::Parser::Text
276
282
  end
277
283
 
278
284
  def to_s # :nodoc:
@@ -0,0 +1,8 @@
1
+ module RDoc
2
+
3
+ ##
4
+ # RDoc version you are using
5
+
6
+ VERSION = '6.3.1'
7
+
8
+ end
data/lib/rdoc.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  $DEBUG_RDOC = nil
3
3
 
4
4
  # :main: README.rdoc
@@ -62,10 +62,7 @@ module RDoc
62
62
 
63
63
  class Error < RuntimeError; end
64
64
 
65
- ##
66
- # RDoc version you are using
67
-
68
- VERSION = '5.0.0'
65
+ require 'rdoc/version'
69
66
 
70
67
  ##
71
68
  # Method visibilities
@@ -123,9 +120,28 @@ module RDoc
123
120
  end
124
121
  end
125
122
 
126
- autoload :RDoc, 'rdoc/rdoc'
123
+ def self.home
124
+ rdoc_dir = begin
125
+ File.expand_path('~/.rdoc')
126
+ rescue ArgumentError
127
+ end
128
+
129
+ if File.directory?(rdoc_dir)
130
+ rdoc_dir
131
+ else
132
+ begin
133
+ # XDG
134
+ xdg_data_home = ENV["XDG_DATA_HOME"] || File.join(File.expand_path("~"), '.local', 'share')
135
+ unless File.exist?(xdg_data_home)
136
+ FileUtils.mkdir_p xdg_data_home
137
+ end
138
+ File.join xdg_data_home, "rdoc"
139
+ rescue Errno::EACCES
140
+ end
141
+ end
142
+ end
127
143
 
128
- autoload :TestCase, 'rdoc/test_case'
144
+ autoload :RDoc, 'rdoc/rdoc'
129
145
 
130
146
  autoload :CrossReference, 'rdoc/cross_reference'
131
147
  autoload :ERBIO, 'rdoc/erbio'
@@ -148,13 +164,11 @@ module RDoc
148
164
 
149
165
  autoload :KNOWN_CLASSES, 'rdoc/known_classes'
150
166
 
151
- autoload :RubyLex, 'rdoc/ruby_lex'
152
- autoload :RubyToken, 'rdoc/ruby_token'
153
167
  autoload :TokenStream, 'rdoc/token_stream'
154
168
 
155
169
  autoload :Comment, 'rdoc/comment'
156
170
 
157
- autoload :I18n, 'rdoc/i18n'
171
+ require 'rdoc/i18n'
158
172
 
159
173
  # code objects
160
174
  #
data/man/ri.1 ADDED
@@ -0,0 +1,247 @@
1
+ .\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ .Dd April 20, 2017
3
+ .Dt RI \&1 "Ruby Programmer's Reference Guide"
4
+ .Os UNIX
5
+ .Sh NAME
6
+ .Nm ri
7
+ .Nd Ruby API reference front end
8
+ .Sh SYNOPSIS
9
+ .Nm
10
+ .Op Fl ahilTv
11
+ .Op Fl d Ar DIRNAME
12
+ .Op Fl f Ar FORMAT
13
+ .Op Fl w Ar WIDTH
14
+ .Op Fl - Ns Oo Cm no- Oc Ns Cm pager
15
+ .Op Fl -server Ns Oo = Ns Ar PORT Oc
16
+ .Op Fl - Ns Oo Cm no- Oc Ns Cm list-doc-dirs
17
+ .Op Fl -no-standard-docs
18
+ .Op Fl - Ns Oo Cm no- Oc Ns Bro Cm system Ns | Ns Cm site Ns | Ns Cm gems Ns | Ns Cm home Brc
19
+ .Op Fl - Ns Oo Cm no- Oc Ns Cm profile
20
+ .Op Fl -dump Ns = Ns Ar CACHE
21
+ .Op Ar name ...
22
+ .Sh DESCRIPTION
23
+ .Nm
24
+ is a command-line front end for the Ruby API reference.
25
+ You can search and read the API reference for classes and methods with
26
+ .Nm .
27
+ .Pp
28
+ .Nm
29
+ is a part of Ruby.
30
+ .Pp
31
+ .Ar name
32
+ can be:
33
+ .Bl -diag -offset indent
34
+ .It Class | Module | Module::Class
35
+ .Pp
36
+ .It Class::method | Class#method | Class.method | method
37
+ .Pp
38
+ .It gem_name: | gem_name:README | gem_name:History
39
+ .El
40
+ .Pp
41
+ All class names may be abbreviated to their minimum unambiguous form.
42
+ If a name is ambiguous, all valid options will be listed.
43
+ .Pp
44
+ A
45
+ .Ql \&.
46
+ matches either class or instance methods, while #method
47
+ matches only instance and ::method matches only class methods.
48
+ .Pp
49
+ README and other files may be displayed by prefixing them with the gem name
50
+ they're contained in. If the gem name is followed by a
51
+ .Ql \&:
52
+ all files in the gem will be shown.
53
+ The file name extension may be omitted where it is unambiguous.
54
+ .Pp
55
+ For example:
56
+ .Bd -literal -offset indent
57
+ ri Fil
58
+ ri File
59
+ ri File.new
60
+ ri zip
61
+ ri rdoc:README
62
+ .Ed
63
+ .Pp
64
+ Note that shell quoting or escaping may be required for method names
65
+ containing punctuation:
66
+ .Bd -literal -offset indent
67
+ ri 'Array.[]'
68
+ ri compact\e!
69
+ .Ed
70
+ .Pp
71
+ To see the default directories
72
+ .Nm
73
+ will search, run:
74
+ .Bd -literal -offset indent
75
+ ri --list-doc-dirs
76
+ .Ed
77
+ .Pp
78
+ Specifying the
79
+ .Fl -system , Fl -site , Fl -home , Fl -gems ,
80
+ or
81
+ .Fl -doc-dir
82
+ options will limit
83
+ .Nm
84
+ to searching only the specified directories.
85
+ .Pp
86
+ .Nm
87
+ options may be set in the
88
+ .Ev RI
89
+ environment variable.
90
+ .Pp
91
+ The
92
+ .Nm
93
+ pager can be set with the
94
+ .Ev RI_PAGER
95
+ environment variable or the
96
+ .Ev PAGER
97
+ environment variable.
98
+ .Pp
99
+ .Sh OPTIONS
100
+ .Bl -tag -width "1234567890123" -compact
101
+ .Pp
102
+ .It Fl i
103
+ .It Fl - Ns Oo Cm no- Oc Ns Cm interactive
104
+ In interactive mode you can repeatedly
105
+ look up methods with autocomplete.
106
+ .Pp
107
+ .It Fl a
108
+ .It Fl - Ns Oo Cm no- Oc Ns Cm all
109
+ Show all documentation for a class or module.
110
+ .Pp
111
+ .It Fl l
112
+ .It Fl - Ns Oo Cm no- Oc Ns Cm list
113
+ List classes
114
+ .Nm
115
+ knows about.
116
+ .Pp
117
+ .It Fl - Ns Oo Cm no- Oc Ns Cm pager
118
+ Send output to a pager,
119
+ rather than directly to stdout.
120
+ .Pp
121
+ .It Fl T
122
+ Synonym for
123
+ .Fl -no-pager .
124
+ .Pp
125
+ .It Fl w Ar WIDTH
126
+ .It Fl -width Ns = Ns Ar WIDTH
127
+ Set the width of the output.
128
+ .Pp
129
+ .It Fl -server Ns Oo = Ns Ar PORT Oc
130
+ Run RDoc server on the given port.
131
+ The default port is\~8214.
132
+ .Pp
133
+ .It Fl f Ar FORMAT
134
+ .It Fl -format Ns = Ns Ar FORMAT
135
+ Use the selected formatter.
136
+ The default formatter is
137
+ .Li bs
138
+ for paged output and
139
+ .Li ansi
140
+ otherwise.
141
+ Valid formatters are:
142
+ .Li ansi , Li bs , Li markdown , Li rdoc .
143
+ .Pp
144
+ .It Fl h
145
+ .It Fl -help
146
+ Show help and exit.
147
+ .Pp
148
+ .It Fl v
149
+ .It Fl -version
150
+ Output version information and exit.
151
+ .El
152
+ .Pp
153
+ Data source options:
154
+ .Bl -tag -width "1234567890123" -compact
155
+ .Pp
156
+ .It Fl - Ns Oo Cm no- Oc Ns Cm list-doc-dirs
157
+ List the directories from which
158
+ .Nm
159
+ will source documentation on stdout and exit.
160
+ .Pp
161
+ .It Fl d Ar DIRNAME
162
+ .It Fl -doc-dir Ns = Ns Ar DIRNAME
163
+ List of directories from which to source
164
+ documentation in addition to the standard
165
+ directories. May be repeated.
166
+ .Pp
167
+ .It Fl -no-standard-docs
168
+ Do not include documentation from the Ruby standard library,
169
+ .Pa site_lib ,
170
+ installed gems, or
171
+ .Pa ~/.rdoc .
172
+ Use with
173
+ .Fl -doc-dir .
174
+ .Pp
175
+ .It Fl - Ns Oo Cm no- Oc Ns Cm system
176
+ Include documentation from Ruby's standard library. Defaults to true.
177
+ .Pp
178
+ .It Fl - Ns Oo Cm no- Oc Ns Cm site
179
+ Include documentation from libraries installed in
180
+ .Pa site_lib .
181
+ Defaults to true.
182
+ .Pp
183
+ .It Fl - Ns Oo Cm no- Oc Ns Cm gems
184
+ Include documentation from RubyGems. Defaults to true.
185
+ .Pp
186
+ .It Fl - Ns Oo Cm no- Oc Ns Cm home
187
+ Include documentation stored in
188
+ .Pa ~/.rdoc .
189
+ Defaults to true.
190
+ .El
191
+ .Pp
192
+ Debug options:
193
+ .Bl -tag -width "1234567890123" -compact
194
+ .Pp
195
+ .It Fl - Ns Oo Cm no- Oc Ns Cm profile
196
+ Run with the Ruby profiler.
197
+ .Pp
198
+ .It Fl -dump Ns = Ns Ar CACHE
199
+ Dump data from an ri cache or data file.
200
+ .El
201
+ .Pp
202
+ .Sh ENVIRONMENT
203
+ .Bl -tag -width "USERPROFILE" -compact
204
+ .Pp
205
+ .It Ev RI
206
+ Options to prepend to those specified on the command-line.
207
+ .Pp
208
+ .It Ev RI_PAGER
209
+ .It Ev PAGER
210
+ Pager program to use for displaying.
211
+ .Pp
212
+ .It Ev HOME
213
+ .It Ev USERPROFILE
214
+ .It Ev HOMEPATH
215
+ Path to the user's home directory.
216
+ .El
217
+ .Pp
218
+ .Sh FILES
219
+ .Bl -tag -width "USERPROFILE" -compact
220
+ .Pp
221
+ .It Pa ~/.rdoc
222
+ Path for ri data in the user's home directory.
223
+ .Pp
224
+ .El
225
+ .Pp
226
+ .Sh SEE ALSO
227
+ .Xr ruby 1 ,
228
+ .Xr rdoc 1 ,
229
+ .Xr gem 1
230
+ .Pp
231
+ .Sh REPORTING BUGS
232
+ .Bl -bullet
233
+ .It
234
+ Security vulnerabilities should be reported via an email to
235
+ .Mt security@ruby-lang.org .
236
+ Reported problems will be published after being fixed.
237
+ .Pp
238
+ .It
239
+ Other bugs and feature requests can be reported via the
240
+ Ruby Issue Tracking System
241
+ .Pq Lk https://bugs.ruby-lang.org/ .
242
+ Do not report security vulnerabilities
243
+ via this system because it publishes the vulnerabilities immediately.
244
+ .El
245
+ .Sh AUTHORS
246
+ Written by
247
+ .An Dave Thomas Aq dave@pragmaticprogrammer.com .