diff --git a/Gemfile b/Gemfile index a7f4a9b5e..c0d72503b 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem "json-schema" gem "goodcheck" gem 'digest' gem 'tempfile' -gem "rdoc", "~> 6.11.0" +gem "rdoc" gem "fileutils" gem "raap" gem "activesupport", "~> 7.0" diff --git a/Gemfile.lock b/Gemfile.lock index a3f0d3b90..780bc67c9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,7 +95,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (6.11.0) + rdoc (6.13.1) psych (>= 4.0.0) regexp_parser (2.10.0) rspec (3.13.0) @@ -202,7 +202,7 @@ DEPENDENCIES rake-compiler rbs! rbs-amber! - rdoc (~> 6.11.0) + rdoc rspec rubocop rubocop-on-rbs diff --git a/lib/rbs/annotate/formatter.rb b/lib/rbs/annotate/formatter.rb index ae1ae3c54..c53124e27 100644 --- a/lib/rbs/annotate/formatter.rb +++ b/lib/rbs/annotate/formatter.rb @@ -59,20 +59,10 @@ def format(newline_at_end:) def self.each_part(doc, &block) if block - document = - case doc - when String - raise - when RDoc::Comment - document = doc.parse - when RDoc::Markup::Document - document = doc - end - - if document.file - yield document + if doc.file + yield doc else - document.each do |d| + doc.each do |d| each_part(d, &block) end end diff --git a/lib/rbs/annotate/rdoc_annotator.rb b/lib/rbs/annotate/rdoc_annotator.rb index 68c06241b..06958998f 100644 --- a/lib/rbs/annotate/rdoc_annotator.rb +++ b/lib/rbs/annotate/rdoc_annotator.rb @@ -39,7 +39,9 @@ def annotate_decls(decls, outer: []) def each_part(subjects, tester:) if block_given? subjects.each do |subject, docs| - Formatter.each_part(subject.comment) do |doc| + comment = subject.comment + raise if comment.is_a?(String) + Formatter.each_part(comment.parse) do |doc| if tester.test_path(doc.file || raise) yield [doc, subject] end diff --git a/lib/rbs/annotate/rdoc_source.rb b/lib/rbs/annotate/rdoc_source.rb index f47f212fa..f4ba46dfa 100644 --- a/lib/rbs/annotate/rdoc_source.rb +++ b/lib/rbs/annotate/rdoc_source.rb @@ -23,7 +23,7 @@ def load @stores.clear() RDoc::RI::Paths.each(with_system_dir, with_site_dir, with_home_dir, with_gems_dir ? :latest : false, *extra_dirs.map(&:to_s)) do |path, type| - store = RDoc::Store.new(path, type) + store = RDoc::Store.new(RDoc::Options.new, path:, type:) store.load_all @stores << store diff --git a/lib/rdoc/discover.rb b/lib/rdoc/discover.rb index c5f4a3b50..f6816143f 100644 --- a/lib/rdoc/discover.rb +++ b/lib/rdoc/discover.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true begin - gem 'rdoc', '~> 6.4' + gem 'rdoc', '~> 6.13' require 'rdoc_plugin/parser' module RDoc class Parser diff --git a/lib/rdoc_plugin/parser.rb b/lib/rdoc_plugin/parser.rb index 2b78fada3..eb09dafd0 100644 --- a/lib/rdoc_plugin/parser.rb +++ b/lib/rdoc_plugin/parser.rb @@ -86,7 +86,7 @@ def parse_method_decl(decl:, context:, outer_name: nil) end def parse_method_alias_decl(decl:, context:, outer_name: nil) - alias_def = RDoc::Alias.new(nil, decl.old_name.to_s, decl.new_name.to_s, nil, decl.kind == :singleton) + alias_def = RDoc::Alias.new(nil, decl.old_name.to_s, decl.new_name.to_s, nil, singleton: decl.kind == :singleton) alias_def.comment = construct_comment(context: context, comment: comment_string(decl)) if decl.comment context.add_alias(alias_def) end @@ -100,7 +100,7 @@ def parse_attr_decl(decl:, context:, outer_name: nil) when ::RBS::AST::Members::AttrAccessor 'RW' end - attribute = RDoc::Attr.new(nil, decl.name.to_s, rw, nil, decl.kind == :singleton) + attribute = RDoc::Attr.new(nil, decl.name.to_s, rw, nil, singleton: decl.kind == :singleton) attribute.visibility = decl.visibility attribute.comment = construct_comment(context: context, comment: comment_string(decl)) if decl.comment context.add_attribute(attribute) diff --git a/sig/annotate/formatter.rbs b/sig/annotate/formatter.rbs index 0464658b7..1fb31f079 100644 --- a/sig/annotate/formatter.rbs +++ b/sig/annotate/formatter.rbs @@ -17,8 +17,8 @@ module RBS def self.translate: (RDoc::Markup::Document) -> String? - def self.each_part: (RDoc::Markup::Document | RDoc::Comment | String) { (RDoc::Markup::Document) -> void } -> void - | (RDoc::Markup::Document | RDoc::Comment | String) -> Enumerator[RDoc::Markup::Document, void] + def self.each_part: (RDoc::Markup::Document) { (RDoc::Markup::Document) -> void } -> void + | (RDoc::Markup::Document) -> Enumerator[RDoc::Markup::Document, void] end end end diff --git a/sig/annotate/rdoc_annotater.rbs b/sig/annotate/rdoc_annotater.rbs index 872c38430..5cb4dc712 100644 --- a/sig/annotate/rdoc_annotater.rbs +++ b/sig/annotate/rdoc_annotater.rbs @@ -17,7 +17,7 @@ module RBS end interface _WithRDocComment - def comment: () -> (RDoc::Markup::Document | RDoc::Comment | String) + def comment: () -> (RDoc::Comment | String) end def each_part: (Array[Object & _WithRDocComment], tester: _PathTester) { ([RDoc::Markup::Document, Object & _WithRDocComment]) -> void } -> void diff --git a/stdlib/rdoc/0/code_object.rbs b/stdlib/rdoc/0/code_object.rbs index 2a9f37f3d..af7f631f7 100644 --- a/stdlib/rdoc/0/code_object.rbs +++ b/stdlib/rdoc/0/code_object.rbs @@ -30,7 +30,7 @@ module RDoc # # Our comment # - attr_reader comment: Markup::Document | Comment | String + attr_reader comment: Comment | String # # Replaces our comment with `comment`, unless it is empty. # - def comment=: (Markup::Document | Comment | String | nil) -> (Markup::Document | Comment | String) + def comment=: (Comment | String | nil) -> (Comment | String | nil) end end diff --git a/stdlib/rdoc/0/comment.rbs b/stdlib/rdoc/0/comment.rbs index 9eb9894a5..ee71bc82c 100644 --- a/stdlib/rdoc/0/comment.rbs +++ b/stdlib/rdoc/0/comment.rbs @@ -20,6 +20,8 @@ module RDoc # attr_accessor location: String + alias file location + # + # RDoc::Options handles the parsing and storage of options + # + # ## Saved Options + # + # You can save some options like the markup format in the `.rdoc_options` file + # in your gem. The easiest way to do this is: + # + # rdoc --markup tomdoc --write-options + # + # Which will automatically create the file and fill it with the options you + # specified. + # + # The following options will not be saved since they interfere with the user's + # preferences or with the normal operation of RDoc: + # + # * `--coverage-report` + # * `--dry-run` + # * `--encoding` + # * `--force-update` + # * `--format` + # * `--pipe` + # * `--quiet` + # * `--template` + # * `--verbose` + # + # ## Custom Options + # + # Generators can hook into RDoc::Options to add generator-specific command line + # options. + # + # When `--format` is encountered in ARGV, RDoc calls ::setup_options on the + # generator class to add extra options to the option parser. Options for custom + # generators must occur after `--format`. `rdoc --help` will list options for + # all installed generators. + # + # Example: + # + # class RDoc::Generator::Spellcheck + # RDoc::RDoc.add_generator self + # + # def self.setup_options rdoc_options + # op = rdoc_options.option_parser + # + # op.on('--spell-dictionary DICTIONARY', + # RDoc::Options::Path) do |dictionary| + # rdoc_options.spell_dictionary = dictionary + # end + # end + # end + # + # Of course, RDoc::Options does not respond to `spell_dictionary` by default so + # you will need to add it: + # + # class RDoc::Options + # + # ## + # # The spell dictionary used by the spell-checking plugin. + # + # attr_accessor :spell_dictionary + # + # end + # + # ## Option Validators + # + # OptionParser validators will validate and cast user input values. In addition + # to the validators that ship with OptionParser (String, Integer, Float, + # TrueClass, FalseClass, Array, Regexp, Date, Time, URI, etc.), RDoc::Options + # adds Path, PathArray and Template. + # + class Options + def initialize: (?untyped loaded_options) -> void + end +end diff --git a/stdlib/rdoc/0/rdoc.rbs b/stdlib/rdoc/0/rdoc.rbs index a5fa214ac..f00295040 100644 --- a/stdlib/rdoc/0/rdoc.rbs +++ b/stdlib/rdoc/0/rdoc.rbs @@ -190,7 +190,7 @@ module RDoc # # Usually this is called by super from a subclass. # - def initialize: (String text, String name) -> void + def initialize: (String text, String name, ?singleton: bool) -> void # # Creates a new AnyMethod with a token stream `text` and `name` # - def initialize: (String? text, String name) -> void + def initialize: (String? text, String name, ?singleton: bool) -> void end # @@ -286,7 +286,7 @@ module RDoc # Creates a new Attr with body `text`, `name`, read/write status `rw` and # `comment`. `singleton` marks this as a class attribute. # - def initialize: (String? text, String name, String rw, RDoc::Comment? comment, ?bool `singleton`) -> void + def initialize: (String? text, String name, String rw, RDoc::Comment? comment, ?singleton: bool) -> void end # @@ -372,6 +372,8 @@ module RDoc # attr_accessor old_name: String + attr_reader singleton: bool + # diff --git a/stdlib/rdoc/0/store.rbs b/stdlib/rdoc/0/store.rbs index ceeb1f168..a48c95bd5 100644 --- a/stdlib/rdoc/0/store.rbs +++ b/stdlib/rdoc/0/store.rbs @@ -26,7 +26,7 @@ module RDoc # --> # Creates a new Store of `type` that will load or save to `path` # - def initialize: (?String? path, ?Symbol? type) -> void + def initialize: (Options, ?path: String? , ?type: Symbol?) -> void #