rdoc 5.1.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 +4 -4
  5. data/README.rdoc +5 -6
  6. data/Rakefile +35 -67
  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 +63 -20
  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 +6 -3
  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 +1 -1
  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 +68 -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 +632 -466
  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 +9 -34
  115. data/lib/rdoc/rd/block_parser.rb +47 -46
  116. data/lib/rdoc/rd/block_parser.ry +2 -2
  117. data/lib/rdoc/rd/inline.rb +5 -5
  118. data/lib/rdoc/rd/inline_parser.rb +139 -138
  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 -24
  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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9174b0195d9838a298a513ba2085d112124c7794
4
- data.tar.gz: 2004a3d7156daa611a1d889f9ea9c6c1fa3e5258
2
+ SHA256:
3
+ metadata.gz: 327e6414793206350f148388b0df495ff2c748c1d4bb129ef320a442e4084619
4
+ data.tar.gz: 44c884a1eb18506c90af82fefa6f7686973ab32e1ceb42c6616b0ffbf88ac868
5
5
  SHA512:
6
- metadata.gz: '092085cdf5a1d41d6c317ad6574f8b36b09f2658df2736fb19dcb4f475df81d3b8db6172a8a2cc1c342aef8a791b6c0b432dce2d7e158b0086f1a95c2b34d40c'
7
- data.tar.gz: 6f206046fd878159a867e3d394deb4ddf5f37a3f437bf314cfd214f6b11e5ab1c2f5d81cadef42ac04fec22396e90f463cfb4e1169877380968a9e45cb1dfabe
6
+ metadata.gz: 8691cde93b42f6c4ff77f6212e40c5c15c408b1953e58cf14f17cef142970ff79564bf7fe12b7f072067267fd67ad62920241e54e7a6d592487545bd19a82311
7
+ data.tar.gz: 3adbda517d389982d0d67ccd92478d0b0912c156c2988a26089715ff77e998025d6f2d8eafd44cdbd66daa2c647bd2201d1c0f57c5731bac19c45aea3014ae4c
data/CONTRIBUTING.rdoc CHANGED
@@ -8,7 +8,7 @@ classes for each feature.
8
8
  == Bugs
9
9
 
10
10
  If you think you found a bug, file a ticket on the {issues
11
- tracker}[https://github.com/rdoc/rdoc/issues] on github.
11
+ tracker}[https://github.com/ruby/rdoc/issues] on github.
12
12
 
13
13
  If your bug involves an error RDoc produced please include a sample file that
14
14
  illustrates the problem or link to the repository or gem that is associated
@@ -17,8 +17,8 @@ with the bug.
17
17
  Please include steps to reproduce the issue. Here are some examples of good
18
18
  issues:
19
19
 
20
- * https://github.com/rdoc/rdoc/issues/55
21
- * https://github.com/rdoc/rdoc/issues/61
20
+ * https://github.com/ruby/rdoc/issues/55
21
+ * https://github.com/ruby/rdoc/issues/61
22
22
 
23
23
  == Developer Quick Start
24
24
 
@@ -35,7 +35,7 @@ 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
37
  If the tests don't pass on the first run check the {Travis CI page for
38
- RDoc}[https://travis-ci.org/rdoc/rdoc] to see if there are any known failures
38
+ RDoc}[https://travis-ci.org/ruby/rdoc] to see if there are any known failures
39
39
  (there shouldn't be).
40
40
 
41
41
  You can now use `rake` and `autotest` to run the tests.
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
data/History.rdoc CHANGED
@@ -1,12 +1,12 @@
1
1
  === 5.1.0 / 2017-02-24
2
2
 
3
3
  * Bug fixes
4
- * Fix an issue that rdoc fails when running on Windows with RUBYOPT=-U.
5
- PR #430 by Toshihiko Ichida
4
+ * Fix an issue that rdoc fails when running on Windows with RUBYOPT=-U.
5
+ PR #430 by Toshihiko Ichida
6
6
 
7
7
  * Minor enhancements
8
- * Parse ruby 2.1 <visibility> def. PR #436 by Akira Matsuda.
9
- * Suppress warnings in eval. PR #440 by Nobuyoshi Nakada.
8
+ * Parse ruby 2.1 <visibility> def. PR #436 by Akira Matsuda.
9
+ * Suppress warnings in eval. PR #440 by Nobuyoshi Nakada.
10
10
 
11
11
  === 5.0.0 / 2016-11-05
12
12
 
data/README.rdoc CHANGED
@@ -1,10 +1,9 @@
1
1
  = \RDoc - Ruby Documentation System
2
2
 
3
- home :: https://github.com/rdoc/rdoc
4
- rdoc :: https://rdoc.github.io/rdoc
5
- bugs :: https://github.com/rdoc/rdoc/issues
6
- build status :: {<img src="https://travis-ci.org/rdoc/rdoc.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/rdoc/rdoc]
7
- code quality :: {<img src="https://codeclimate.com/github/rdoc/rdoc/badges/gpa.svg" alt="Code Climate">}[https://codeclimate.com/github/rdoc/rdoc]
3
+ home :: https://github.com/ruby/rdoc
4
+ rdoc :: https://ruby.github.io/rdoc
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]
8
7
 
9
8
  == Description
10
9
 
@@ -47,7 +46,7 @@ contain just Markup-style markup (with or without leading '#' comment
47
46
  markers). If directory names are passed to RDoc, they are scanned
48
47
  recursively for C and Ruby source files only.
49
48
 
50
- To generate documentation using +rake+ see RDoc::Task[https://rdoc.github.io/rdoc/RDocTask.html].
49
+ To generate documentation using +rake+ see RDoc::Task[https://ruby.github.io/rdoc/RDocTask.html].
51
50
 
52
51
  To generate documentation programmatically:
53
52
 
data/Rakefile CHANGED
@@ -3,10 +3,8 @@ require 'rdoc/task'
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/testtask'
5
5
 
6
- ENV['BENCHMARK'] = 'yes'
7
-
8
6
  task :docs => :generate
9
- task :test => :generate
7
+ task :test => [:normal_test, :rubygems_test]
10
8
 
11
9
  PARSER_FILES = %w[
12
10
  lib/rdoc/rd/block_parser.ry
@@ -35,10 +33,18 @@ task ghpages: :rdoc do
35
33
  FileUtils.cp_r Dir.glob("/tmp/html/*"), "."
36
34
  end
37
35
 
38
- Rake::TestTask.new(:test) do |t|
39
- t.libs << "test"
40
- t.libs << "lib"
41
- t.test_files = FileList['test/**/test_*.rb']
36
+ Rake::TestTask.new(:normal_test) do |t|
37
+ t.libs << "test/rdoc"
38
+ t.verbose = true
39
+ t.deps = :generate
40
+ t.test_files = FileList["test/**/test_*.rb"].exclude("test/rdoc/test_rdoc_rubygems_hook.rb")
41
+ end
42
+
43
+ Rake::TestTask.new(:rubygems_test) do |t|
44
+ t.libs << "test/rdoc"
45
+ t.verbose = true
46
+ t.deps = :generate
47
+ t.pattern = "test/rdoc/test_rdoc_rubygems_hook.rb"
42
48
  end
43
49
 
44
50
  path = "pkg/#{Bundler::GemHelper.gemspec.full_name}"
@@ -55,20 +61,25 @@ package_parser_files = PARSER_FILES.map do |parser_file|
55
61
  end
56
62
 
57
63
  parsed_files = PARSER_FILES.map do |parser_file|
58
- name = File.basename(parser_file, File.extname(parser_file))
59
- _path = File.dirname(parser_file)
60
- parsed_file = "#{_path}/#{name}.rb"
64
+ ext = File.extname(parser_file)
65
+ parsed_file = "#{parser_file.chomp(ext)}.rb"
61
66
 
62
- file parsed_file do |t|
67
+ file parsed_file => parser_file do |t|
63
68
  puts "Generating #{parsed_file}..."
64
- if parser_file =~ /\.ry\z/ # need racc
69
+ case ext
70
+ when '.ry' # need racc
65
71
  racc = Gem.bin_path 'racc', 'racc'
66
72
  rb_file = parser_file.gsub(/\.ry\z/, ".rb")
67
- ruby "-rubygems #{racc} -l -o #{rb_file} #{parser_file}"
68
- elsif parser_file =~ /\.kpeg\z/ # need kpeg
73
+ ruby "#{racc} -l -o #{rb_file} #{parser_file}"
74
+ open(rb_file, 'r+') do |f|
75
+ newtext = "# frozen_string_literal: true\n#{f.read}"
76
+ f.rewind
77
+ f.write newtext
78
+ end
79
+ when '.kpeg' # need kpeg
69
80
  kpeg = Gem.bin_path 'kpeg', 'kpeg'
70
81
  rb_file = parser_file.gsub(/\.kpeg\z/, ".rb")
71
- ruby "-rubygems #{kpeg} -fsv -o #{rb_file} #{parser_file}"
82
+ ruby "#{kpeg} -fsv -o #{rb_file} #{parser_file}"
72
83
  end
73
84
  end
74
85
 
@@ -76,58 +87,15 @@ parsed_files = PARSER_FILES.map do |parser_file|
76
87
  end
77
88
 
78
89
  task "#{path}.gem" => package_parser_files
90
+ desc "Generate all files used racc and kpeg"
79
91
  task :generate => parsed_files
80
- task :check_manifest => :generate
81
-
82
- # These tasks expect to have the following directory structure:
83
- #
84
- # git/git.rubini.us/code # Rubinius git HEAD checkout
85
- # svn/ruby/trunk # ruby subversion HEAD checkout
86
- # svn/rdoc/trunk # RDoc subversion HEAD checkout
87
- #
88
- # If you don't have this directory structure, set RUBY_PATH and/or
89
- # RUBINIUS_PATH.
90
-
91
- diff_options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
92
- rsync_options = "-avP --exclude '*svn*' --exclude '*swp' --exclude '*rbc' --exclude '*.rej' --exclude '*.orig' --exclude '*.kpeg' --exclude '*.ry' --exclude 'literals_1_8.rb' --exclude 'gauntlet_rdoc.rb'"
93
-
94
- rubinius_dir = ENV['RUBINIUS_PATH'] || '../../../git/git.rubini.us/code'
95
- ruby_dir = ENV['RUBY_PATH'] || '../../svn/ruby/trunk'
96
-
97
- desc "Updates Ruby HEAD with the currently checked-out copy of RDoc."
98
- task :update_ruby do
99
- sh "rsync #{rsync_options} bin/rdoc #{ruby_dir}/bin/rdoc"
100
- sh "rsync #{rsync_options} bin/ri #{ruby_dir}/bin/ri"
101
- sh "rsync #{rsync_options} lib/ #{ruby_dir}/lib"
102
- sh "rsync #{rsync_options} test/ #{ruby_dir}/test/rdoc"
103
- end
104
92
 
105
- desc "Diffs Ruby HEAD with the currently checked-out copy of RDoc."
106
- task :diff_ruby do
107
- options = "-urpN --exclude '*svn*' --exclude '*swp' --exclude '*rbc'"
108
-
109
- sh "diff #{diff_options} bin/rdoc #{ruby_dir}/bin/rdoc; true"
110
- sh "diff #{diff_options} bin/ri #{ruby_dir}/bin/ri; true"
111
- sh "diff #{diff_options} lib/rdoc.rb #{ruby_dir}/lib/rdoc.rb; true"
112
- sh "diff #{diff_options} lib/rdoc #{ruby_dir}/lib/rdoc; true"
113
- sh "diff #{diff_options} test #{ruby_dir}/test/rdoc; true"
114
- end
115
-
116
- desc "Updates Rubinius HEAD with the currently checked-out copy of RDoc."
117
- task :update_rubinius do
118
- sh "rsync #{rsync_options} bin/rdoc #{rubinius_dir}/lib/bin/rdoc.rb"
119
- sh "rsync #{rsync_options} bin/ri #{rubinius_dir}/lib/bin/ri.rb"
120
- sh "rsync #{rsync_options} lib/ #{rubinius_dir}/lib"
121
- sh "rsync #{rsync_options} test/ #{rubinius_dir}/test/rdoc"
122
- end
123
-
124
- desc "Diffs Rubinius HEAD with the currently checked-out copy of RDoc."
125
- task :diff_rubinius do
126
- sh "diff #{diff_options} bin/rdoc #{rubinius_dir}/lib/bin/rdoc.rb; true"
127
- sh "diff #{diff_options} bin/ri #{rubinius_dir}/lib/bin/ri.rb; true"
128
- sh "diff #{diff_options} lib/rdoc.rb #{rubinius_dir}/lib/rdoc.rb; true"
129
- sh "diff #{diff_options} lib/rdoc #{rubinius_dir}/lib/rdoc; true"
130
- sh "diff #{diff_options} test #{rubinius_dir}/test/rdoc; true"
93
+ begin
94
+ require 'rubocop/rake_task'
95
+ rescue LoadError
96
+ else
97
+ RuboCop::RakeTask.new(:rubocop) do |t|
98
+ t.options = [*parsed_files]
99
+ end
100
+ task :build => [:generate, "rubocop:auto_correct"]
131
101
  end
132
-
133
- task :build => [:generate]
data/lib/rdoc/alias.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # Represent an alias, which is an old_name/new_name pair associated with a
4
4
  # particular context
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # An anonymous class like:
4
4
  #
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # AnyMethod is the base class for objects representing methods
4
4
 
@@ -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.
@@ -244,9 +251,9 @@ class RDoc::AnyMethod < RDoc::MethodAttr
244
251
  if @block_params then
245
252
  # If this method has explicit block parameters, remove any explicit
246
253
  # &block
247
- params.sub!(/,?\s*&\w+/, '')
254
+ params = params.sub(/,?\s*&\w+/, '')
248
255
  else
249
- params.sub!(/\&(\w+)/, '\1')
256
+ params = params.sub(/\&(\w+)/, '\1')
250
257
  end
251
258
 
252
259
  params = params.gsub(/\s+/, '').split(',').reject(&:empty?)
@@ -265,7 +272,7 @@ class RDoc::AnyMethod < RDoc::MethodAttr
265
272
  params = params.sub(/(\|[^|]+\|)\s*\.\.\.\s*(end|\})/, '\1 \2')
266
273
  elsif @params then
267
274
  params = @params.gsub(/\s*\#.*/, '')
268
- params = params.tr("\n", " ").squeeze(" ")
275
+ params = params.tr_s("\n ", " ")
269
276
  params = "(#{params})" unless params[0] == ?(
270
277
  else
271
278
  params = ''
@@ -274,12 +281,11 @@ class RDoc::AnyMethod < RDoc::MethodAttr
274
281
  if @block_params then
275
282
  # If this method has explicit block parameters, remove any explicit
276
283
  # &block
277
- params.sub!(/,?\s*&\w+/, '')
284
+ params = params.sub(/,?\s*&\w+/, '')
278
285
 
279
- block = @block_params.gsub(/\s*\#.*/, '')
280
- block = block.tr("\n", " ").squeeze(" ")
286
+ block = @block_params.tr_s("\n ", " ")
281
287
  if block[0] == ?(
282
- block.sub!(/^\(/, '').sub!(/\)/, '')
288
+ block = block.sub(/^\(/, '').sub(/\)/, '')
283
289
  end
284
290
  params << " { |#{block}| ... }"
285
291
  end
@@ -313,5 +319,43 @@ class RDoc::AnyMethod < RDoc::MethodAttr
313
319
  @superclass_method
314
320
  end
315
321
 
316
- 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\[/
317
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
data/lib/rdoc/attr.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # An attribute created by \#attr, \#attr_reader, \#attr_writer or
4
4
  # \#attr_accessor
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # ClassModule is the base class for objects representing either a class or a
4
4
  # module.
@@ -136,7 +136,9 @@ class RDoc::ClassModule < RDoc::Context
136
136
  normalize_comment comment
137
137
  end
138
138
 
139
- @comment_location.delete_if { |(_, l)| l == location }
139
+ if location.parser == RDoc::Parser::C
140
+ @comment_location.delete_if { |(_, l)| l == location }
141
+ end
140
142
 
141
143
  @comment_location << [comment, location]
142
144
 
@@ -208,7 +210,7 @@ class RDoc::ClassModule < RDoc::Context
208
210
  normalize_comment comment
209
211
  end
210
212
 
211
- comment = "#{@comment}\n---\n#{comment}" unless @comment.empty?
213
+ comment = "#{@comment.to_s}\n---\n#{comment.to_s}" unless @comment.empty?
212
214
 
213
215
  super comment
214
216
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # Base class for the RDoc code tree.
4
4
  #
@@ -69,13 +69,6 @@ class RDoc::CodeObject
69
69
 
70
70
  attr_reader :metadata
71
71
 
72
- ##
73
- # Offset in #file where this CodeObject was defined
74
- #--
75
- # TODO character or byte?
76
-
77
- attr_accessor :offset
78
-
79
72
  ##
80
73
  # Sets the parent CodeObject
81
74
 
@@ -151,7 +144,7 @@ class RDoc::CodeObject
151
144
  # HACK correct fix is to have #initialize create @comment
152
145
  # with the correct encoding
153
146
  if String === @comment and @comment.empty? then
154
- @comment.force_encoding comment.encoding
147
+ @comment = RDoc::Encoding.change_encoding @comment, comment.encoding
155
148
  end
156
149
  @comment
157
150
  end
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  # This file was used to load all the RDoc::CodeObject subclasses at once. Now
3
3
  # autoload handles this.
4
4
 
data/lib/rdoc/comment.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A comment holds the text comment for a RDoc::CodeObject and provides a
4
4
  # unified way of cleaning it up and parsing it into an RDoc::Markup::Document.
@@ -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
- @text = text
58
+ @text = text.nil? ? nil : text.dup
59
+ @language = language
49
60
 
50
61
  @document = nil
51
62
  @format = 'rdoc'
@@ -114,10 +125,14 @@ class RDoc::Comment
114
125
 
115
126
  method.call_seq = seq.chomp
116
127
 
117
- elsif @text.sub!(/^\s*:?call-seq:(.*?)(^\s*$|\z)/m, '') then
118
- seq = $1
119
- seq.gsub!(/^\s*/, '')
120
- method.call_seq = seq
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
121
136
  end
122
137
 
123
138
  method
@@ -133,8 +148,14 @@ class RDoc::Comment
133
148
  ##
134
149
  # HACK dubious
135
150
 
136
- def force_encoding encoding
137
- @text.force_encoding encoding
151
+ 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
158
+ self
138
159
  end
139
160
 
140
161
  ##
@@ -200,7 +221,7 @@ class RDoc::Comment
200
221
  def remove_private
201
222
  # Workaround for gsub encoding for Ruby 1.9.2 and earlier
202
223
  empty = ''
203
- empty.force_encoding @text.encoding
224
+ empty = RDoc::Encoding.change_encoding empty, @text.encoding
204
225
 
205
226
  @text = @text.gsub(%r%^\s*([#*]?)--.*?^\s*(\1)\+\+\n?%m, empty)
206
227
  @text = @text.sub(%r%^\s*[#*]?--.*%m, '')
@@ -216,7 +237,7 @@ class RDoc::Comment
216
237
  @text.nil? and @document
217
238
 
218
239
  @document = nil
219
- @text = text
240
+ @text = text.nil? ? nil : text.dup
220
241
  end
221
242
 
222
243
  ##
data/lib/rdoc/constant.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A constant
4
4
 
@@ -36,7 +36,7 @@ class RDoc::Constant < RDoc::CodeObject
36
36
  @value = value
37
37
 
38
38
  @is_alias_for = nil
39
- @visibility = nil
39
+ @visibility = :public
40
40
 
41
41
  self.comment = comment
42
42
  end
@@ -136,7 +136,7 @@ class RDoc::Constant < RDoc::CodeObject
136
136
  initialize array[1], nil, array[5]
137
137
 
138
138
  @full_name = array[2]
139
- @visibility = array[3]
139
+ @visibility = array[3] || :public
140
140
  @is_alias_for = array[4]
141
141
  # 5 handled above
142
142
  # 6 handled below
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  ##
3
3
  # A section of documentation like:
4
4
  #
@@ -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.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