Skip to content

Commit 77a80c7

Browse files
committed
Drop unused markup parameter from Formatter hierarchy
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.
1 parent 5214a30 commit 77a80c7

File tree

14 files changed

+22
-24
lines changed

14 files changed

+22
-24
lines changed

lib/rdoc/markup/formatter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def self.gen_relative_url(path, target)
4848
##
4949
# Creates a new Formatter
5050

51-
def initialize(options, markup = nil)
51+
def initialize(options)
5252
@options = options
5353

54-
@markup = markup || RDoc::Markup.new
54+
@markup = RDoc::Markup.new
5555

5656
@from_path = '.'
5757
end

lib/rdoc/markup/heading.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ def self.to_label
5252
#: () -> RDoc::Markup::ToHtml
5353
def self.to_html
5454
@to_html ||= begin
55-
markup = Markup.new
56-
markup.add_regexp_handling CrossReference::CROSSREF_REGEXP, :CROSSREF
57-
5855
to_html = Markup::ToHtml.new nil
5956

6057
def to_html.handle_regexp_CROSSREF(text)

lib/rdoc/markup/to_ansi.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class RDoc::Markup::ToAnsi < RDoc::Markup::ToRdoc
77
##
88
# Creates a new ToAnsi visitor that is ready to output vibrant ANSI color!
99

10-
def initialize(markup = nil)
10+
def initialize
1111
super
1212

1313
@headings.clear

lib/rdoc/markup/to_bs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class RDoc::Markup::ToBs < RDoc::Markup::ToRdoc
1010
##
1111
# Returns a new ToBs that is ready for hot backspace action!
1212

13-
def initialize(markup = nil)
13+
def initialize
1414
super
1515

1616
@in_b = false

lib/rdoc/markup/to_html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
4343
##
4444
# Creates a new formatter that will output HTML
4545

46-
def initialize(options, markup = nil)
46+
def initialize(options)
4747
super
4848

4949
@code_object = nil

lib/rdoc/markup/to_html_crossref.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
2929
# references are removed unless +show_hash+ is true. Only method names
3030
# preceded by '#' or '::' are linked, unless +hyperlink_all+ is true.
3131

32-
def initialize(options, from_path, context, markup = nil)
32+
def initialize(options, from_path, context)
3333
raise ArgumentError, 'from_path cannot be nil' if from_path.nil?
3434

35-
super options, markup
35+
super options
3636

3737
@context = context
3838
@from_path = from_path

lib/rdoc/markup/to_html_snippet.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml
3434
# next word boundary after the given number of +characters+ or +paragraphs+
3535
# of text have been encountered.
3636

37-
def initialize(options, characters = 100, paragraphs = 3, markup = nil)
38-
super options, markup
37+
def initialize(options, characters = 100, paragraphs = 3)
38+
super options
3939

4040
@character_limit = characters
4141
@paragraph_limit = paragraphs

lib/rdoc/markup/to_label.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class RDoc::Markup::ToLabel < RDoc::Markup::Formatter
1414
##
1515
# Creates a new formatter that will output HTML-safe labels
1616

17-
def initialize(markup = nil)
18-
super nil, markup
17+
def initialize
18+
super nil
1919

2020
@markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
2121

lib/rdoc/markup/to_markdown.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class RDoc::Markup::ToMarkdown < RDoc::Markup::ToRdoc
99
##
1010
# Creates a new formatter that will output Markdown format text
1111

12-
def initialize(markup = nil)
12+
def initialize
1313
super
1414

1515
@headings[1] = ['# ', '']

lib/rdoc/markup/to_rdoc.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
5252
##
5353
# Creates a new formatter that will output (mostly) \RDoc markup
5454

55-
def initialize(markup = nil)
56-
super nil, markup
55+
def initialize
56+
super nil
5757

5858
@markup.add_regexp_handling(/\\\S/, :SUPPRESSED_CROSSREF)
5959
@width = 78

0 commit comments

Comments
 (0)