Skip to content

Commit 0888311

Browse files
vinistockst0012
andcommitted
Revert Markup::Heading type back to a struct
We cannot change the constant from a Struct to a class because that breaks Marshal serialization. It can only be changed after RDoc's serialization does not use Marshal Co-authored-by: Stan Lo <st0012@users.noreply.github.com>
1 parent 0602d13 commit 0888311

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

lib/rdoc/markup/heading.rb

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ class Markup
1313
# # Heading 1
1414
# ## Heading 2
1515
# ### Heading 3
16-
class Heading < Element
17-
#: String
18-
attr_reader :text
19-
20-
#: Integer
21-
attr_accessor :level
22-
16+
#
17+
# IMPORTANT! Do not change this to a regular class until serialization is no longer using Marshal. If the constant
18+
# changes type then deserializing the Marshal data for older Ruby versions will fail
19+
Heading = Struct.new(:level, :text) do
2320
# A singleton RDoc::Markup::ToLabel formatter for headings.
2421
#: () -> RDoc::Markup::ToLabel
2522
def self.to_label
@@ -43,19 +40,6 @@ def to_html.handle_regexp_CROSSREF(target)
4340
end
4441
end
4542

46-
#: (Integer, String) -> void
47-
def initialize(level, text)
48-
super()
49-
50-
@level = level
51-
@text = text
52-
end
53-
54-
#: (Object) -> bool
55-
def ==(other)
56-
other.is_a?(Heading) && other.level == @level && other.text == @text
57-
end
58-
5943
# @override
6044
#: (untyped) -> void
6145
def accept(visitor)

0 commit comments

Comments
 (0)