rdoc 6.1.0 → 6.3.0

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/README.rdoc +0 -1
  4. data/Rakefile +12 -4
  5. data/lib/rdoc.rb +21 -0
  6. data/lib/rdoc/any_method.rb +52 -7
  7. data/lib/rdoc/class_module.rb +1 -1
  8. data/lib/rdoc/comment.rb +12 -1
  9. data/lib/rdoc/context.rb +10 -2
  10. data/lib/rdoc/context/section.rb +0 -13
  11. data/lib/rdoc/cross_reference.rb +4 -4
  12. data/lib/rdoc/erb_partial.rb +1 -1
  13. data/lib/rdoc/erbio.rb +2 -2
  14. data/lib/rdoc/generator/darkfish.rb +9 -9
  15. data/lib/rdoc/generator/pot.rb +3 -3
  16. data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -7
  17. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  18. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  19. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  20. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  21. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  22. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  23. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  28. data/lib/rdoc/generator/template/darkfish/class.rhtml +44 -44
  29. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +35 -6
  30. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  31. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +22 -99
  32. data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
  33. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  34. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  35. data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -40
  36. data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
  37. data/lib/rdoc/i18n.rb +1 -1
  38. data/lib/rdoc/markdown.kpeg +1 -1
  39. data/lib/rdoc/markdown.rb +16287 -0
  40. data/lib/rdoc/markdown/literals.rb +417 -0
  41. data/lib/rdoc/markup.rb +0 -2
  42. data/lib/rdoc/markup/formatter.rb +1 -1
  43. data/lib/rdoc/markup/parser.rb +58 -42
  44. data/lib/rdoc/markup/pre_process.rb +1 -1
  45. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  46. data/lib/rdoc/markup/to_html.rb +19 -6
  47. data/lib/rdoc/markup/to_html_crossref.rb +18 -6
  48. data/lib/rdoc/options.rb +23 -5
  49. data/lib/rdoc/parser.rb +7 -7
  50. data/lib/rdoc/parser/c.rb +139 -183
  51. data/lib/rdoc/parser/ripper_state_lex.rb +2 -1
  52. data/lib/rdoc/parser/ruby.rb +18 -8
  53. data/lib/rdoc/rd/block_parser.rb +1056 -0
  54. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  55. data/lib/rdoc/rdoc.rb +26 -20
  56. data/lib/rdoc/ri/driver.rb +9 -5
  57. data/lib/rdoc/ri/paths.rb +3 -17
  58. data/lib/rdoc/ri/task.rb +1 -1
  59. data/lib/rdoc/rubygems_hook.rb +2 -2
  60. data/lib/rdoc/servlet.rb +16 -8
  61. data/lib/rdoc/store.rb +6 -14
  62. data/lib/rdoc/task.rb +1 -1
  63. data/lib/rdoc/text.rb +8 -2
  64. data/lib/rdoc/token_stream.rb +8 -3
  65. data/lib/rdoc/tom_doc.rb +6 -7
  66. data/lib/rdoc/version.rb +1 -1
  67. data/man/ri.1 +247 -0
  68. data/rdoc.gemspec +194 -10
  69. metadata +10 -86
  70. data/.document +0 -5
  71. data/.gitignore +0 -14
  72. data/.travis.yml +0 -21
  73. data/appveyor.yml +0 -36
  74. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  75. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  76. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1adfe550f28540b0acea6b50aaefc740fc26d7c7e59a9df00812a1e18ee6c1b9
4
- data.tar.gz: 8188b1dc736c927d40e5dddd3918fe9fde31081f484eb31136939df50ba0f676
3
+ metadata.gz: 18741ef6dd2db34af2ea15a9e8a154a760c1f01bb0d69d15dc3af3f70cc00d7c
4
+ data.tar.gz: e61ab91ee4b0e776dd36e934da0534e6d52aa259ddff18be057955e109db08b4
5
5
  SHA512:
6
- metadata.gz: 16093877f3afa1f4f475b9e9129e814f4ebf604b0e0607b47d57b8cb33f0978548f7b2f4d8435e0a89114711b1e0789ec995a81aa5b09f23004d74daa25bfa41
7
- data.tar.gz: 0735ab8915312b67f031e2797017d91c3ad0fbc8d6d1829c8e69c5c9e2e58c5e5e6e09af49f0e7941238ea397f6482b44e7dc2a1bf294a93fbbb66652ca74006
6
+ metadata.gz: 9ea75c4b0339de23f73f84c890b23cb0b7bacb87ea191258f54160a28a4519c0e8edfbf6bc17ef67e631d923b17cb2030f79048d269b032eefe8b92f62fdb9df
7
+ data.tar.gz: bdbf42dea5706d0b13ce653a8591ff9fc0ece11b4d49c18e7d32bd725e901a3dd2e5feb3479b4185a874d12e024e7f77b6324592405a9b826efd00bb68589373
data/Gemfile CHANGED
@@ -1,3 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ group :development do
6
+ gem "rake"
7
+ gem "racc", "> 1.4.10"
8
+ gem "kpeg"
9
+ gem "test-unit"
10
+ gem "minitest" # for test_rdoc_rubygems_hook.rb
11
+ gem "rubocop"
12
+ end
@@ -3,7 +3,6 @@
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
- build status :: {<img src="https://travis-ci.org/ruby/rdoc.svg?branch=master" alt="Build Status on Travis CI" />}[https://travis-ci.org/ruby/rdoc] {<img src="https://ci.appveyor.com/api/projects/status/github/ruby/rdoc?branch=master&svg=true" alt="Build Status on AppVeyor" />}[https://ci.appveyor.com/project/ruby/rdoc]
7
6
  code quality :: {<img src="https://codeclimate.com/github/ruby/rdoc/badges/gpa.svg" alt="Code Climate">}[https://codeclimate.com/github/ruby/rdoc]
8
7
 
9
8
  == Description
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
5
5
  require 'rubocop/rake_task'
6
6
 
7
7
  task :docs => :generate
8
- task :test => :generate
8
+ task :test => [:normal_test, :rubygems_test]
9
9
 
10
10
  PARSER_FILES = %w[
11
11
  lib/rdoc/rd/block_parser.ry
@@ -34,10 +34,18 @@ task ghpages: :rdoc do
34
34
  FileUtils.cp_r Dir.glob("/tmp/html/*"), "."
35
35
  end
36
36
 
37
- Rake::TestTask.new(:test) do |t|
38
- t.libs << "test"
37
+ Rake::TestTask.new(:normal_test) do |t|
38
+ t.libs << "test/rdoc"
39
39
  t.verbose = true
40
- t.test_files = FileList['test/**/test_*.rb']
40
+ t.deps = :generate
41
+ t.test_files = FileList["test/**/test_*.rb"].exclude("test/rdoc/test_rdoc_rubygems_hook.rb")
42
+ end
43
+
44
+ Rake::TestTask.new(:rubygems_test) do |t|
45
+ t.libs << "test/rdoc"
46
+ t.verbose = true
47
+ t.deps = :generate
48
+ t.pattern = "test/rdoc/test_rdoc_rubygems_hook.rb"
41
49
  end
42
50
 
43
51
  path = "pkg/#{Bundler::GemHelper.gemspec.full_name}"
@@ -120,6 +120,27 @@ module RDoc
120
120
  end
121
121
  end
122
122
 
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
143
+
123
144
  autoload :RDoc, 'rdoc/rdoc'
124
145
 
125
146
  autoload :CrossReference, 'rdoc/cross_reference'
@@ -26,12 +26,6 @@ class RDoc::AnyMethod < RDoc::MethodAttr
26
26
 
27
27
  attr_accessor :c_function
28
28
 
29
- ##
30
- # Different ways to call this method
31
-
32
- attr_reader :call_seq
33
-
34
- ##
35
29
  # Parameters for this method
36
30
 
37
31
  attr_accessor :params
@@ -93,6 +87,19 @@ class RDoc::AnyMethod < RDoc::MethodAttr
93
87
  end
94
88
  end
95
89
 
90
+ ##
91
+ # Different ways to call this method
92
+
93
+ def call_seq
94
+ unless call_seq = _call_seq
95
+ call_seq = is_alias_for._call_seq if is_alias_for
96
+ end
97
+
98
+ return unless call_seq
99
+
100
+ deduplicate_call_seq(call_seq)
101
+ end
102
+
96
103
  ##
97
104
  # Sets the different ways you can call this method. If an empty +call_seq+
98
105
  # is given nil is assumed.
@@ -312,5 +319,43 @@ class RDoc::AnyMethod < RDoc::MethodAttr
312
319
  @superclass_method
313
320
  end
314
321
 
315
- end
322
+ protected
323
+
324
+ ##
325
+ # call_seq without deduplication and alias lookup.
326
+
327
+ def _call_seq
328
+ @call_seq if defined?(@call_seq) && @call_seq
329
+ end
330
+
331
+ private
332
+
333
+ ##
334
+ # call_seq with alias examples information removed, if this
335
+ # method is an alias method.
336
+
337
+ def deduplicate_call_seq(call_seq)
338
+ return call_seq unless is_alias_for || !aliases.empty?
339
+
340
+ method_name = self.name
341
+ method_name = method_name[0, 1] if method_name =~ /\A\[/
316
342
 
343
+ entries = call_seq.split "\n"
344
+
345
+ ignore = aliases.map(&:name)
346
+ if is_alias_for
347
+ ignore << is_alias_for.name
348
+ ignore.concat is_alias_for.aliases.map(&:name)
349
+ end
350
+ ignore.map! { |n| n =~ /\A\[/ ? n[0, 1] : n}
351
+ ignore.delete(method_name)
352
+ ignore = Regexp.union(ignore)
353
+
354
+ matching = entries.reject do |entry|
355
+ entry =~ /^\w*\.?#{ignore}/ or
356
+ entry =~ /\s#{ignore}\s/
357
+ end
358
+
359
+ matching.join "\n"
360
+ end
361
+ end
@@ -210,7 +210,7 @@ class RDoc::ClassModule < RDoc::Context
210
210
  normalize_comment comment
211
211
  end
212
212
 
213
- comment = "#{@comment}\n---\n#{comment}" unless @comment.empty?
213
+ comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty?
214
214
 
215
215
  super comment
216
216
  end
@@ -23,6 +23,11 @@ class RDoc::Comment
23
23
 
24
24
  attr_accessor :location
25
25
 
26
+ ##
27
+ # Line where this Comment was written
28
+
29
+ attr_accessor :line
30
+
26
31
  ##
27
32
  # For duck-typing when merging classes at load time
28
33
 
@@ -33,6 +38,11 @@ class RDoc::Comment
33
38
 
34
39
  attr_reader :text
35
40
 
41
+ ##
42
+ # Alias for text
43
+
44
+ alias to_s text
45
+
36
46
  ##
37
47
  # Overrides the content returned by #parse. Use when there is no #text
38
48
  # source for this comment
@@ -43,9 +53,10 @@ class RDoc::Comment
43
53
  # Creates a new comment with +text+ that is found in the RDoc::TopLevel
44
54
  # +location+.
45
55
 
46
- def initialize text = nil, location = nil
56
+ def initialize text = nil, location = nil, language = nil
47
57
  @location = location
48
58
  @text = text.nil? ? nil : text.dup
59
+ @language = language
49
60
 
50
61
  @document = nil
51
62
  @format = 'rdoc'
@@ -990,13 +990,21 @@ class RDoc::Context < RDoc::CodeObject
990
990
  @instance_attributes ||= attributes.reject { |a| a.singleton }
991
991
  end
992
992
 
993
+ ##
994
+ # Instance methods
995
+
996
+ def instance_methods
997
+ @instance_methods ||= method_list.reject { |a| a.singleton }
998
+ end
999
+
993
1000
  ##
994
1001
  # Instance methods
995
1002
  #--
996
- # TODO rename to instance_methods
1003
+ # TODO remove this later
997
1004
 
998
1005
  def instance_method_list
999
- @instance_method_list ||= method_list.reject { |a| a.singleton }
1006
+ warn '#instance_method_list is obsoleted, please use #instance_methods'
1007
+ @instance_methods ||= method_list.reject { |a| a.singleton }
1000
1008
  end
1001
1009
 
1002
1010
  ##
@@ -34,8 +34,6 @@ class RDoc::Context::Section
34
34
 
35
35
  attr_reader :title
36
36
 
37
- @@sequence = "SEC00000"
38
-
39
37
  ##
40
38
  # Creates a new section with +title+ and +comment+
41
39
 
@@ -43,9 +41,6 @@ class RDoc::Context::Section
43
41
  @parent = parent
44
42
  @title = title ? title.strip : title
45
43
 
46
- @@sequence = @@sequence.succ
47
- @sequence = @@sequence.dup
48
-
49
44
  @comments = []
50
45
 
51
46
  add_comment comment
@@ -233,13 +228,5 @@ class RDoc::Context::Section
233
228
  end
234
229
  end
235
230
 
236
- ##
237
- # Section sequence number (deprecated)
238
-
239
- def sequence
240
- warn "RDoc::Context::Section#sequence is deprecated, use #aref"
241
- @sequence
242
- end
243
-
244
231
  end
245
232
 
@@ -19,7 +19,7 @@ class RDoc::CrossReference
19
19
  #
20
20
  # See CLASS_REGEXP_STR
21
21
 
22
- METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
22
+ METHOD_REGEXP_STR = '([a-z]\w*[!?=]?|%|===|\[\]=?|<<|>>|\+@|-@|-|\+|\*)(?:\([\w.+*/=<>-]*\))?'
23
23
 
24
24
  ##
25
25
  # Regular expressions matching text that should potentially have
@@ -28,7 +28,7 @@ class RDoc::CrossReference
28
28
  # have been suppressed, since the suppression characters are removed by the
29
29
  # code that is triggered.
30
30
 
31
- CROSSREF_REGEXP = /(?:^|\s)
31
+ CROSSREF_REGEXP = /(?:^|[\s()])
32
32
  (
33
33
  (?:
34
34
  # A::B::C.meth
@@ -76,7 +76,7 @@ class RDoc::CrossReference
76
76
  # Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
77
77
 
78
78
  ALL_CROSSREF_REGEXP = /
79
- (?:^|\s)
79
+ (?:^|[\s()])
80
80
  (
81
81
  (?:
82
82
  # A::B::C.meth
@@ -173,7 +173,7 @@ class RDoc::CrossReference
173
173
  end unless ref
174
174
 
175
175
  # Try a page name
176
- ref = @store.page name if not ref and name =~ /^\w+$/
176
+ ref = @store.page name if not ref and name =~ /^[\w.]+$/
177
177
 
178
178
  ref = nil if RDoc::Alias === ref # external alias, can't link to it
179
179
 
@@ -12,7 +12,7 @@ class RDoc::ERBPartial < ERB
12
12
  def set_eoutvar compiler, eoutvar = '_erbout'
13
13
  super
14
14
 
15
- compiler.pre_cmd = ["#{eoutvar} ||= ''"]
15
+ compiler.pre_cmd = ["#{eoutvar} ||= +''"]
16
16
  end
17
17
 
18
18
  end
@@ -20,11 +20,11 @@ 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, trim_mode = nil, eoutvar = 'io'
23
+ def initialize str, safe_level = nil, legacy_trim_mode = nil, legacy_eoutvar = 'io', trim_mode: nil, eoutvar: 'io'
24
24
  if RUBY_VERSION >= '2.6'
25
25
  super(str, trim_mode: trim_mode, eoutvar: eoutvar)
26
26
  else
27
- super
27
+ super(str, safe_level, legacy_trim_mode, legacy_eoutvar)
28
28
  end
29
29
  end
30
30
 
@@ -4,7 +4,7 @@
4
4
  require 'erb'
5
5
  require 'fileutils'
6
6
  require 'pathname'
7
- require 'rdoc/generator/markup'
7
+ require_relative 'markup'
8
8
 
9
9
  ##
10
10
  # Darkfish RDoc HTML Generator
@@ -269,7 +269,7 @@ class RDoc::Generator::Darkfish
269
269
 
270
270
  @options.static_path.each do |path|
271
271
  unless File.directory? path then
272
- FileUtils.install path, @outputdir, fu_options.merge(:mode => 0644)
272
+ FileUtils.install path, @outputdir, **fu_options.merge(:mode => 0644)
273
273
  next
274
274
  end
275
275
 
@@ -278,9 +278,9 @@ class RDoc::Generator::Darkfish
278
278
  dest_file = @outputdir + entry
279
279
 
280
280
  if File.directory? entry then
281
- FileUtils.mkdir_p entry, fu_options
281
+ FileUtils.mkdir_p entry, **fu_options
282
282
  else
283
- FileUtils.install entry, dest_file, fu_options.merge(:mode => 0644)
283
+ FileUtils.install entry, dest_file, **fu_options.merge(:mode => 0644)
284
284
  end
285
285
  end
286
286
  end
@@ -585,16 +585,16 @@ class RDoc::Generator::Darkfish
585
585
  return unless source.exist?
586
586
 
587
587
  begin
588
- FileUtils.mkdir_p File.dirname(destination), options
588
+ FileUtils.mkdir_p File.dirname(destination), **options
589
589
 
590
590
  begin
591
- FileUtils.ln source, destination, options
591
+ FileUtils.ln source, destination, **options
592
592
  rescue Errno::EEXIST
593
593
  FileUtils.rm destination
594
594
  retry
595
595
  end
596
596
  rescue
597
- FileUtils.cp source, destination, options
597
+ FileUtils.cp source, destination, **options
598
598
  end
599
599
  end
600
600
 
@@ -779,9 +779,9 @@ class RDoc::Generator::Darkfish
779
779
  end
780
780
 
781
781
  if RUBY_VERSION >= '2.6'
782
- template = klass.new template, trim_mode: '<>', eoutvar: erbout
782
+ template = klass.new template, trim_mode: '-', eoutvar: erbout
783
783
  else
784
- template = klass.new template, nil, '<>', erbout
784
+ template = klass.new template, nil, '-', erbout
785
785
  end
786
786
  @template_cache[file] = template
787
787
  template
@@ -91,8 +91,8 @@ class RDoc::Generator::POT
91
91
  extractor.extract
92
92
  end
93
93
 
94
- require 'rdoc/generator/pot/message_extractor'
95
- require 'rdoc/generator/pot/po'
96
- require 'rdoc/generator/pot/po_entry'
94
+ require_relative 'pot/message_extractor'
95
+ require_relative 'pot/po'
96
+ require_relative 'pot/po_entry'
97
97
 
98
98
  end
@@ -7,14 +7,16 @@
7
7
  var index_rel_prefix = "<%= rel_prefix %>/";
8
8
  </script>
9
9
 
10
- <script src="<%= asset_rel_prefix %>/js/jquery.js"></script>
11
- <script src="<%= asset_rel_prefix %>/js/darkfish.js"></script>
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>
12
15
 
13
16
  <link href="<%= asset_rel_prefix %>/css/fonts.css" rel="stylesheet">
14
17
  <link href="<%= asset_rel_prefix %>/css/rdoc.css" rel="stylesheet">
15
- <% if @options.template_stylesheets.flatten.any? then %>
16
- <% @options.template_stylesheets.flatten.each do |stylesheet| %>
18
+ <%- if @options.template_stylesheets.flatten.any? then -%>
19
+ <%- @options.template_stylesheets.flatten.each do |stylesheet| -%>
17
20
  <link href="<%= asset_rel_prefix %>/<%= File.basename stylesheet %>" rel="stylesheet">
18
- <% end %>
19
- <% end %>
20
-
21
+ <%- end -%>
22
+ <%- end -%>
@@ -1,4 +1,4 @@
1
- <% if !svninfo.empty? then %>
1
+ <%- if !svninfo.empty? then %>
2
2
  <div id="file-svninfo-section" class="nav-section">
3
3
  <h3>VCS Info</h3>
4
4
 
@@ -16,4 +16,4 @@
16
16
  </dl>
17
17
  </div>
18
18
  </div>
19
- <% end %>
19
+ <%- end -%>
@@ -2,8 +2,8 @@
2
2
  <h3>Class and Module Index</h3>
3
3
 
4
4
  <ul class="link-list">
5
- <% @modsort.each do |index_klass| %>
5
+ <%- @modsort.each do |index_klass| -%>
6
6
  <li><a href="<%= rel_prefix %>/<%= index_klass.path %>"><%= index_klass.full_name %></a>
7
- <% end %>
7
+ <%- end -%>
8
8
  </ul>
9
9
  </div>