From 77a80c76a91291b15c5130d705efd58ea4c8beab Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 22 Feb 2026 13:51:36 +0000 Subject: [PATCH 1/2] Drop unused `markup` parameter from Formatter hierarchy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No caller ever passes a non-nil `markup` to any formatter constructor — every formatter creates its own `RDoc::Markup.new` internally. Remove the `markup` parameter from `Formatter#initialize` and all subclasses: `ToHtml`, `ToHtmlCrossref`, `ToHtmlSnippet`, `ToRdoc`, `ToLabel`, `ToTtOnly`, `ToAnsi`, `ToBs`, `ToMarkdown`. Also remove the dead `markup` variable in `Heading.to_html` that was configured with crossref regexp handling but never passed to the formatter. --- lib/rdoc/markup/formatter.rb | 4 ++-- lib/rdoc/markup/heading.rb | 3 --- lib/rdoc/markup/to_ansi.rb | 2 +- lib/rdoc/markup/to_bs.rb | 2 +- lib/rdoc/markup/to_html.rb | 2 +- lib/rdoc/markup/to_html_crossref.rb | 4 ++-- lib/rdoc/markup/to_html_snippet.rb | 4 ++-- lib/rdoc/markup/to_label.rb | 4 ++-- lib/rdoc/markup/to_markdown.rb | 2 +- lib/rdoc/markup/to_rdoc.rb | 4 ++-- lib/rdoc/markup/to_tt_only.rb | 4 ++-- test/rdoc/markup/formatter_test.rb | 5 +++-- test/rdoc/markup/markup_test.rb | 4 ++-- test/rdoc/rdoc_markdown_test.rb | 2 +- 14 files changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb index e858aa3e74..56f7dc1a85 100644 --- a/lib/rdoc/markup/formatter.rb +++ b/lib/rdoc/markup/formatter.rb @@ -48,10 +48,10 @@ def self.gen_relative_url(path, target) ## # Creates a new Formatter - def initialize(options, markup = nil) + def initialize(options) @options = options - @markup = markup || RDoc::Markup.new + @markup = RDoc::Markup.new @from_path = '.' end diff --git a/lib/rdoc/markup/heading.rb b/lib/rdoc/markup/heading.rb index 3936d836c8..43bf90bf7a 100644 --- a/lib/rdoc/markup/heading.rb +++ b/lib/rdoc/markup/heading.rb @@ -52,9 +52,6 @@ def self.to_label #: () -> RDoc::Markup::ToHtml def self.to_html @to_html ||= begin - markup = Markup.new - markup.add_regexp_handling CrossReference::CROSSREF_REGEXP, :CROSSREF - to_html = Markup::ToHtml.new nil def to_html.handle_regexp_CROSSREF(text) diff --git a/lib/rdoc/markup/to_ansi.rb b/lib/rdoc/markup/to_ansi.rb index b3556a0744..19a188d197 100644 --- a/lib/rdoc/markup/to_ansi.rb +++ b/lib/rdoc/markup/to_ansi.rb @@ -7,7 +7,7 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc ## # Creates a new ToAnsi visitor that is ready to output vibrant ANSI color! - def initialize(markup = nil) + def initialize super @headings.clear diff --git a/lib/rdoc/markup/to_bs.rb b/lib/rdoc/markup/to_bs.rb index f047e30803..f060d36523 100644 --- a/lib/rdoc/markup/to_bs.rb +++ b/lib/rdoc/markup/to_bs.rb @@ -10,7 +10,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc ## # Returns a new ToBs that is ready for hot backspace action! - def initialize(markup = nil) + def initialize super @in_b = false diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index 6d9899000e..c81e144b00 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -43,7 +43,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter ## # Creates a new formatter that will output HTML - def initialize(options, markup = nil) + def initialize(options) super @code_object = nil diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb index 089f7fea8f..fc8354d48f 100644 --- a/lib/rdoc/markup/to_html_crossref.rb +++ b/lib/rdoc/markup/to_html_crossref.rb @@ -29,10 +29,10 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # references are removed unless +show_hash+ is true. Only method names # preceded by '#' or '::' are linked, unless +hyperlink_all+ is true. - def initialize(options, from_path, context, markup = nil) + def initialize(options, from_path, context) raise ArgumentError, 'from_path cannot be nil' if from_path.nil? - super options, markup + super options @context = context @from_path = from_path diff --git a/lib/rdoc/markup/to_html_snippet.rb b/lib/rdoc/markup/to_html_snippet.rb index 52cc4543f3..6f7740f28f 100644 --- a/lib/rdoc/markup/to_html_snippet.rb +++ b/lib/rdoc/markup/to_html_snippet.rb @@ -34,8 +34,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml # next word boundary after the given number of +characters+ or +paragraphs+ # of text have been encountered. - def initialize(options, characters = 100, paragraphs = 3, markup = nil) - super options, markup + def initialize(options, characters = 100, paragraphs = 3) + super options @character_limit = characters @paragraph_limit = paragraphs diff --git a/lib/rdoc/markup/to_label.rb b/lib/rdoc/markup/to_label.rb index 4ab030bb70..80b6ede85c 100644 --- a/lib/rdoc/markup/to_label.rb +++ b/lib/rdoc/markup/to_label.rb @@ -14,8 +14,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter ## # Creates a new formatter that will output HTML-safe labels - def initialize(markup = nil) - super nil, markup + def initialize + super nil @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF diff --git a/lib/rdoc/markup/to_markdown.rb b/lib/rdoc/markup/to_markdown.rb index 4c19e460c4..3c5c49f41a 100644 --- a/lib/rdoc/markup/to_markdown.rb +++ b/lib/rdoc/markup/to_markdown.rb @@ -9,7 +9,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc ## # Creates a new formatter that will output Markdown format text - def initialize(markup = nil) + def initialize super @headings[1] = ['# ', ''] diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb index 88caebd3c0..095affd725 100644 --- a/lib/rdoc/markup/to_rdoc.rb +++ b/lib/rdoc/markup/to_rdoc.rb @@ -52,8 +52,8 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter ## # Creates a new formatter that will output (mostly) \RDoc markup - def initialize(markup = nil) - super nil, markup + def initialize + super nil @markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF) @width = 78 diff --git a/lib/rdoc/markup/to_tt_only.rb b/lib/rdoc/markup/to_tt_only.rb index 19e3622f75..1e97b78f5d 100644 --- a/lib/rdoc/markup/to_tt_only.rb +++ b/lib/rdoc/markup/to_tt_only.rb @@ -18,8 +18,8 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter ## # Creates a new tt-only formatter. - def initialize(markup = nil) - super nil, markup + def initialize + super nil end ## diff --git a/test/rdoc/markup/formatter_test.rb b/test/rdoc/markup/formatter_test.rb index 2ff7323622..6ee0479241 100644 --- a/test/rdoc/markup/formatter_test.rb +++ b/test/rdoc/markup/formatter_test.rb @@ -5,8 +5,9 @@ class RDocMarkupFormatterTest < RDoc::TestCase class ToTest < RDoc::Markup::Formatter - def initialize(markup) - super nil, markup + def initialize(markup = nil) + super(nil) + @markup = markup if markup end def accept_paragraph(paragraph) diff --git a/test/rdoc/markup/markup_test.rb b/test/rdoc/markup/markup_test.rb index 979d0a8c29..815a52c6d1 100644 --- a/test/rdoc/markup/markup_test.rb +++ b/test/rdoc/markup/markup_test.rb @@ -24,7 +24,7 @@ def test_convert m = RDoc::Markup.new - tt = RDoc::Markup::ToTest.new m + tt = RDoc::Markup::ToTest.new nil out = m.convert str, tt @@ -55,7 +55,7 @@ def test_convert_document m = RDoc::Markup.new - tt = RDoc::Markup::ToTest.new m + tt = RDoc::Markup::ToTest.new nil out = m.convert doc, tt diff --git a/test/rdoc/rdoc_markdown_test.rb b/test/rdoc/rdoc_markdown_test.rb index 1b3e4e96ce..2b47341796 100644 --- a/test/rdoc/rdoc_markdown_test.rb +++ b/test/rdoc/rdoc_markdown_test.rb @@ -14,7 +14,7 @@ def setup @parser = RDoc::Markdown.new - @to_html = RDoc::Markup::ToHtml.new(RDoc::Options.new, nil) + @to_html = RDoc::Markup::ToHtml.new(RDoc::Options.new) end def test_class_parse From 7c47d0a0628a5c83a1c0dc6a29c264e91227545c Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 22 Feb 2026 13:52:27 +0000 Subject: [PATCH 2/2] Decouple Formatter from `RDoc::Options` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Formatter#initialize` took an `RDoc::Options` object, but only 2 subclasses (`ToHtml`, `ToHtmlCrossref`) read from it — using just 6 specific boolean/array values. All other formatters passed `nil`. Replace the `options` parameter with explicit keyword arguments: - `ToHtml`: `pipe:`, `output_decoration:` - `ToHtmlCrossref`: `pipe:`, `output_decoration:`, `hyperlink_all:`, `show_hash:`, `autolink_excluded_words:`, `warn_missing_rdoc_ref:` Call sites (`Generator::Markup#formatter`, `RDoc::RDoc#handle_pipe`) now unpack the needed values from `RDoc::Options` at the boundary. `ToHtmlSnippet` and `Text#snippet` no longer receive or forward options. Delete `LinkLabelToHtml` (zero callers in the codebase). Update `CodeObject#options` comment to reflect remaining callers. --- lib/rdoc/code_object.rb | 3 ++- lib/rdoc/generator/markup.rb | 10 +++++++- lib/rdoc/markup/formatter.rb | 4 +-- lib/rdoc/markup/heading.rb | 2 +- lib/rdoc/markup/to_html.rb | 30 ++++++----------------- lib/rdoc/markup/to_html_crossref.rb | 20 +++++++++------ lib/rdoc/markup/to_html_snippet.rb | 4 +-- lib/rdoc/markup/to_joined_paragraph.rb | 5 ---- lib/rdoc/markup/to_label.rb | 2 +- lib/rdoc/markup/to_rdoc.rb | 2 +- lib/rdoc/markup/to_table_of_contents.rb | 2 +- lib/rdoc/markup/to_tt_only.rb | 7 ------ lib/rdoc/rdoc.rb | 2 +- lib/rdoc/text.rb | 2 +- test/rdoc/markup/formatter_test.rb | 2 +- test/rdoc/markup/markup_test.rb | 4 +-- test/rdoc/markup/to_html_crossref_test.rb | 27 ++++++++++---------- test/rdoc/markup/to_html_snippet_test.rb | 10 ++++---- test/rdoc/markup/to_html_test.rb | 11 ++++----- test/rdoc/rdoc_markdown_test.rb | 2 +- test/rdoc/rdoc_text_test.rb | 2 +- 21 files changed, 68 insertions(+), 85 deletions(-) diff --git a/lib/rdoc/code_object.rb b/lib/rdoc/code_object.rb index 388863b06c..4f5a998fc6 100644 --- a/lib/rdoc/code_object.rb +++ b/lib/rdoc/code_object.rb @@ -277,7 +277,8 @@ def ignored? # The options instance from the store this CodeObject is attached to, or a # default options instance if the CodeObject is not attached. # - # This is used by Text#snippet + # Used by: store= (visibility check), ClassModule#path, TopLevel#path, + # ClassModule#embed_mixins def options @store&.options || RDoc::Options.new diff --git a/lib/rdoc/generator/markup.rb b/lib/rdoc/generator/markup.rb index 1c39687040..dc4556c019 100644 --- a/lib/rdoc/generator/markup.rb +++ b/lib/rdoc/generator/markup.rb @@ -37,7 +37,15 @@ def formatter options = @store.options this = RDoc::Context === self ? self : @parent - @formatter = RDoc::Markup::ToHtmlCrossref.new options, this.path, this + @formatter = RDoc::Markup::ToHtmlCrossref.new( + this.path, this, + pipe: options.pipe, + output_decoration: options.output_decoration, + hyperlink_all: options.hyperlink_all, + show_hash: options.show_hash, + autolink_excluded_words: options.autolink_excluded_words || [], + warn_missing_rdoc_ref: options.warn_missing_rdoc_ref + ) @formatter.code_object = self @formatter end diff --git a/lib/rdoc/markup/formatter.rb b/lib/rdoc/markup/formatter.rb index 56f7dc1a85..433237393d 100644 --- a/lib/rdoc/markup/formatter.rb +++ b/lib/rdoc/markup/formatter.rb @@ -48,9 +48,7 @@ def self.gen_relative_url(path, target) ## # Creates a new Formatter - def initialize(options) - @options = options - + def initialize @markup = RDoc::Markup.new @from_path = '.' diff --git a/lib/rdoc/markup/heading.rb b/lib/rdoc/markup/heading.rb index 43bf90bf7a..0ceef85bd8 100644 --- a/lib/rdoc/markup/heading.rb +++ b/lib/rdoc/markup/heading.rb @@ -52,7 +52,7 @@ def self.to_label #: () -> RDoc::Markup::ToHtml def self.to_html @to_html ||= begin - to_html = Markup::ToHtml.new nil + to_html = Markup::ToHtml.new def to_html.handle_regexp_CROSSREF(text) text.sub(/^\\/, '') diff --git a/lib/rdoc/markup/to_html.rb b/lib/rdoc/markup/to_html.rb index c81e144b00..90eff47840 100644 --- a/lib/rdoc/markup/to_html.rb +++ b/lib/rdoc/markup/to_html.rb @@ -43,9 +43,11 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter ## # Creates a new formatter that will output HTML - def initialize(options) - super + def initialize(pipe: false, output_decoration: true) + super() + @pipe = pipe + @output_decoration = output_decoration @code_object = nil @from_path = '' @in_list_entry = nil @@ -347,7 +349,7 @@ def accept_verbatim(verbatim) CGI.escapeHTML text end - if @options.pipe then + if @pipe @res << "\n
#{CGI.escapeHTML text}\n
\n" else @res << "\n#{content}\n" @@ -418,17 +420,17 @@ def accept_heading(heading) # Add legacy anchor before the heading for backward compatibility. # This allows old links with label- prefix to still work. - if @options.output_decoration && !@options.pipe + if @output_decoration && !@pipe @res << "\n" end - @res << if @options.output_decoration + @res << if @output_decoration "\n" else "\n" end - if @options.pipe + if @pipe @res << to_html(heading.text) else @res << "#{to_html(heading.text)}" @@ -586,19 +588,3 @@ def to_html(item) to_html_characters(handle_inline(item)) end end - -## -# Formatter dedicated to rendering tidy link labels without mutating the -# calling formatter's state. - -class RDoc::Markup::LinkLabelToHtml < RDoc::Markup::ToHtml - def self.render(label, options, from_path) - new(options, from_path).to_html(label) - end - - def initialize(options, from_path = nil) - super(options) - - self.from_path = from_path if from_path - end -end diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb index fc8354d48f..6e0d0793be 100644 --- a/lib/rdoc/markup/to_html_crossref.rb +++ b/lib/rdoc/markup/to_html_crossref.rb @@ -29,15 +29,19 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # references are removed unless +show_hash+ is true. Only method names # preceded by '#' or '::' are linked, unless +hyperlink_all+ is true. - def initialize(options, from_path, context) + def initialize(from_path, context, pipe: false, output_decoration: true, + hyperlink_all: false, show_hash: false, + autolink_excluded_words: [], warn_missing_rdoc_ref: true) raise ArgumentError, 'from_path cannot be nil' if from_path.nil? - super options + super(pipe: pipe, output_decoration: output_decoration) @context = context @from_path = from_path - @hyperlink_all = @options.hyperlink_all - @show_hash = @options.show_hash + @hyperlink_all = hyperlink_all + @show_hash = show_hash + @autolink_excluded_words = autolink_excluded_words + @warn_missing_rdoc_ref = warn_missing_rdoc_ref @cross_reference = RDoc::CrossReference.new @context end @@ -48,7 +52,7 @@ def init_link_notation_regexp_handlings # The crossref must be linked before tidylink because Klass.method[:sym] # will be processed as a tidylink first and will be broken. - crossref_re = @options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP + crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP @markup.add_regexp_handling crossref_re, :CROSSREF end @@ -83,7 +87,7 @@ def cross_reference(name, text = nil, code = true, rdoc_ref: false) def handle_regexp_CROSSREF(name) return convert_string(name) if in_tidylink_label? - return name if @options.autolink_excluded_words&.include?(name) + return name if @autolink_excluded_words&.include?(name) return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails @@ -159,7 +163,7 @@ def link(name, text, code = true, rdoc_ref: false) case ref when String then - if rdoc_ref && @options.warn_missing_rdoc_ref + if rdoc_ref && @warn_missing_rdoc_ref puts "#{@from_path}: `rdoc-ref:#{name}` can't be resolved for `#{text}`" end ref @@ -224,7 +228,7 @@ def apply_tidylink_label_special_handling(label, url) def tt_cross_reference(code) return if in_tidylink_label? - crossref_regexp = @options.hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP + crossref_regexp = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP match = crossref_regexp.match(code) return unless match && match.begin(1).zero? return unless match.post_match.match?(/\A[[:punct:]\s]*\z/) diff --git a/lib/rdoc/markup/to_html_snippet.rb b/lib/rdoc/markup/to_html_snippet.rb index 6f7740f28f..6687dc59f6 100644 --- a/lib/rdoc/markup/to_html_snippet.rb +++ b/lib/rdoc/markup/to_html_snippet.rb @@ -34,8 +34,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml # next word boundary after the given number of +characters+ or +paragraphs+ # of text have been encountered. - def initialize(options, characters = 100, paragraphs = 3) - super options + def initialize(characters = 100, paragraphs = 3) + super() @character_limit = characters @paragraph_limit = paragraphs diff --git a/lib/rdoc/markup/to_joined_paragraph.rb b/lib/rdoc/markup/to_joined_paragraph.rb index bdfd1fb436..27060e226c 100644 --- a/lib/rdoc/markup/to_joined_paragraph.rb +++ b/lib/rdoc/markup/to_joined_paragraph.rb @@ -8,11 +8,6 @@ # other markup syntax items will not work. class RDoc::Markup::ToJoinedParagraph < RDoc::Markup::Formatter - - def initialize # :nodoc: - super nil - end - def start_accepting # :nodoc: end diff --git a/lib/rdoc/markup/to_label.rb b/lib/rdoc/markup/to_label.rb index 80b6ede85c..ae11a5fe6b 100644 --- a/lib/rdoc/markup/to_label.rb +++ b/lib/rdoc/markup/to_label.rb @@ -15,7 +15,7 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter # Creates a new formatter that will output HTML-safe labels def initialize - super nil + super @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb index 095affd725..b788906d9c 100644 --- a/lib/rdoc/markup/to_rdoc.rb +++ b/lib/rdoc/markup/to_rdoc.rb @@ -53,7 +53,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter # Creates a new formatter that will output (mostly) \RDoc markup def initialize - super nil + super @markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF) @width = 78 diff --git a/lib/rdoc/markup/to_table_of_contents.rb b/lib/rdoc/markup/to_table_of_contents.rb index 3247bb8a73..31c849e7d6 100644 --- a/lib/rdoc/markup/to_table_of_contents.rb +++ b/lib/rdoc/markup/to_table_of_contents.rb @@ -25,7 +25,7 @@ def self.to_toc attr_accessor :omit_headings_below def initialize # :nodoc: - super nil + super @omit_headings_below = nil end diff --git a/lib/rdoc/markup/to_tt_only.rb b/lib/rdoc/markup/to_tt_only.rb index 1e97b78f5d..7f498003ec 100644 --- a/lib/rdoc/markup/to_tt_only.rb +++ b/lib/rdoc/markup/to_tt_only.rb @@ -15,13 +15,6 @@ class RDoc::Markup::ToTtOnly < RDoc::Markup::Formatter attr_reader :res - ## - # Creates a new tt-only formatter. - - def initialize - super nil - end - ## # Adds tts from +block_quote+ to the output diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 8beeac52f5..415abea520 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -140,7 +140,7 @@ def gather_files(files) # Turns RDoc from stdin into HTML def handle_pipe - @html = RDoc::Markup::ToHtml.new @options + @html = RDoc::Markup::ToHtml.new(pipe: @options.pipe, output_decoration: @options.output_decoration) parser = RDoc::Text::MARKUP_FORMAT[@options.markup] diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index a7cca6e38d..fc16211df1 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -149,7 +149,7 @@ def parse(text, format = 'rdoc') def snippet(text, limit = 100) document = parse text - RDoc::Markup::ToHtmlSnippet.new(options, limit).convert document + RDoc::Markup::ToHtmlSnippet.new(limit).convert document end ## diff --git a/test/rdoc/markup/formatter_test.rb b/test/rdoc/markup/formatter_test.rb index 6ee0479241..304eebff24 100644 --- a/test/rdoc/markup/formatter_test.rb +++ b/test/rdoc/markup/formatter_test.rb @@ -6,7 +6,7 @@ class RDocMarkupFormatterTest < RDoc::TestCase class ToTest < RDoc::Markup::Formatter def initialize(markup = nil) - super(nil) + super() @markup = markup if markup end diff --git a/test/rdoc/markup/markup_test.rb b/test/rdoc/markup/markup_test.rb index 815a52c6d1..659ea8fc94 100644 --- a/test/rdoc/markup/markup_test.rb +++ b/test/rdoc/markup/markup_test.rb @@ -24,7 +24,7 @@ def test_convert m = RDoc::Markup.new - tt = RDoc::Markup::ToTest.new nil + tt = RDoc::Markup::ToTest.new out = m.convert str, tt @@ -55,7 +55,7 @@ def test_convert_document m = RDoc::Markup.new - tt = RDoc::Markup::ToTest.new nil + tt = RDoc::Markup::ToTest.new out = m.convert doc, tt diff --git a/test/rdoc/markup/to_html_crossref_test.rb b/test/rdoc/markup/to_html_crossref_test.rb index 15a1d26913..9366de861e 100644 --- a/test/rdoc/markup/to_html_crossref_test.rb +++ b/test/rdoc/markup/to_html_crossref_test.rb @@ -7,10 +7,8 @@ class RDocMarkupToHtmlCrossrefTest < XrefTestCase def setup super - @options.hyperlink_all = true - @options.warn_missing_rdoc_ref = true - - @to = RDoc::Markup::ToHtmlCrossref.new @options, 'index.html', @c1 + @to = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1, + hyperlink_all: true, warn_missing_rdoc_ref: true end def test_convert_CROSSREF @@ -35,9 +33,7 @@ def test_convert_CROSSREF end def test_convert_CROSSREF_backslash_in_tt - @options.hyperlink_all = false - - formatter = RDoc::Markup::ToHtmlCrossref.new(@options, 'C9.html', @c9_b) + formatter = RDoc::Markup::ToHtmlCrossref.new('C9.html', @c9_b) result = formatter.convert 'C1' assert_equal para('C1'), result @@ -53,7 +49,9 @@ def test_convert_CROSSREF_backslash_in_tt end def test_convert_CROSSREF_ignored_excluded_words - @options.autolink_excluded_words = ['C1'] + @to = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1, + hyperlink_all: true, warn_missing_rdoc_ref: true, + autolink_excluded_words: ['C1'] result = @to.convert 'C1' assert_equal para("C1"), result @@ -285,7 +283,8 @@ def test_handle_regexp_HYPERLINK_rdoc readme = @store.add_file 'README.txt' readme.parser = RDoc::Parser::Simple - @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2 + @to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, + hyperlink_all: true, warn_missing_rdoc_ref: true link = @to.handle_regexp_HYPERLINK hyper 'C2::C3' @@ -304,7 +303,8 @@ def test_handle_TIDYLINK_rdoc readme = @store.add_file 'README.txt' readme.parser = RDoc::Parser::Simple - @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2 + @to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c2, + hyperlink_all: true, warn_missing_rdoc_ref: true link = @to.to_html tidy 'C2::C3' @@ -339,9 +339,7 @@ def test_convert_TIDYLINK_markdown_with_crossrefs end def test_to_html_CROSSREF_email - @options.hyperlink_all = false - - @to = RDoc::Markup::ToHtmlCrossref.new @options, 'index.html', @c1 + @to = RDoc::Markup::ToHtmlCrossref.new 'index.html', @c1 result = @to.to_html 'first.last@example.com' @@ -361,7 +359,8 @@ def test_link end def test_link_for_method_traverse - @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c9 + @to = RDoc::Markup::ToHtmlCrossref.new 'C2.html', @c9, + hyperlink_all: true, warn_missing_rdoc_ref: true assert_equal 'C9::B#foo', @to.link('C9::B#foo', 'C9::B#foo') end diff --git a/test/rdoc/markup/to_html_snippet_test.rb b/test/rdoc/markup/to_html_snippet_test.rb index ce9118a18c..b468b57474 100644 --- a/test/rdoc/markup/to_html_snippet_test.rb +++ b/test/rdoc/markup/to_html_snippet_test.rb @@ -8,7 +8,7 @@ class RDocMarkupToHtmlSnippetTest < RDoc::Markup::FormatterTestCase def setup super - @to = RDoc::Markup::ToHtmlSnippet.new @options, 100, 100 + @to = RDoc::Markup::ToHtmlSnippet.new 100, 100 @ellipsis = @to.to_html '...' end @@ -436,7 +436,7 @@ def test_accept_verbatim_ruby_error end def test_add_paragraph - @to = RDoc::Markup::ToHtmlSnippet.new @options, 0, 3 + @to = RDoc::Markup::ToHtmlSnippet.new 0, 3 assert_throws :done do @to.add_paragraph @to.add_paragraph @@ -488,7 +488,7 @@ def test_convert_limit_2 end def test_convert_limit_paragraphs - @to = RDoc::Markup::ToHtmlSnippet.new @options, 100, 3 + @to = RDoc::Markup::ToHtmlSnippet.new 100, 3 rdoc = <<-RDOC = \RDoc - Ruby Documentation System @@ -519,7 +519,7 @@ def test_convert_limit_paragraphs end def test_convert_limit_in_tag - @to = RDoc::Markup::ToHtmlSnippet.new @options, 4 + @to = RDoc::Markup::ToHtmlSnippet.new 4 rdoc = "* ab *c* d\n" expected = "

ab c #{@ellipsis}\n\n" @@ -598,7 +598,7 @@ def test_convert_limit_verbatim_multiline end def test_convert_limit_over - @to = RDoc::Markup::ToHtmlSnippet.new @options, 4 + @to = RDoc::Markup::ToHtmlSnippet.new 4 rdoc = "* text\n" * 2 expected = "

text\n" diff --git a/test/rdoc/markup/to_html_test.rb b/test/rdoc/markup/to_html_test.rb index 4e9ac38176..26d224eac2 100644 --- a/test/rdoc/markup/to_html_test.rb +++ b/test/rdoc/markup/to_html_test.rb @@ -8,7 +8,7 @@ class RDocMarkupToHtmlTest < RDoc::Markup::FormatterTestCase def setup super - @to = RDoc::Markup::ToHtml.new @options + @to = RDoc::Markup::ToHtml.new end def accept_blank_line @@ -351,7 +351,7 @@ def test_accept_heading_aref_method end def test_accept_heading_pipe - @options.pipe = true + @to = RDoc::Markup::ToHtml.new(pipe: true) @to.start_accepting @@ -451,7 +451,7 @@ def test_accept_paragraph_newline end def test_accept_heading_output_decoration - @options.output_decoration = false + @to = RDoc::Markup::ToHtml.new(output_decoration: false) @to.start_accepting @@ -461,8 +461,7 @@ def test_accept_heading_output_decoration end def test_accept_heading_output_decoration_with_pipe - @options.pipe = true - @options.output_decoration = false + @to = RDoc::Markup::ToHtml.new(pipe: true, output_decoration: false) @to.start_accepting @@ -520,7 +519,7 @@ def test_accept_verbatim_nl_after_backslash end def test_accept_verbatim_pipe - @options.pipe = true + @to = RDoc::Markup::ToHtml.new(pipe: true) verb = @RM::Verbatim.new("1 + 1\n") verb.format = :ruby diff --git a/test/rdoc/rdoc_markdown_test.rb b/test/rdoc/rdoc_markdown_test.rb index 2b47341796..eb7c487f27 100644 --- a/test/rdoc/rdoc_markdown_test.rb +++ b/test/rdoc/rdoc_markdown_test.rb @@ -14,7 +14,7 @@ def setup @parser = RDoc::Markdown.new - @to_html = RDoc::Markup::ToHtml.new(RDoc::Options.new) + @to_html = RDoc::Markup::ToHtml.new end def test_class_parse diff --git a/test/rdoc/rdoc_text_test.rb b/test/rdoc/rdoc_text_test.rb index 03c4167ac5..1230536542 100644 --- a/test/rdoc/rdoc_text_test.rb +++ b/test/rdoc/rdoc_text_test.rb @@ -577,7 +577,7 @@ def test_to_html_tt_tag_mismatch end def formatter - RDoc::Markup::ToHtml.new @options + RDoc::Markup::ToHtml.new end def options