From 2953114487fd25ff0968eb3c6b9f1e4fba2b2f72 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sat, 8 Aug 2026 17:58:10 +0100 Subject: [PATCH 1/4] Make Raw inherit from Element --- lib/rdoc/markup/raw.rb | 2 +- test/rdoc/markup/raw_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/markup/raw.rb b/lib/rdoc/markup/raw.rb index 441a496ef5..5cb987fd31 100644 --- a/lib/rdoc/markup/raw.rb +++ b/lib/rdoc/markup/raw.rb @@ -3,7 +3,7 @@ module RDoc class Markup # A section of text that is added to the output document as-is - class Raw + class Raw < Element # The component parts of the list #: Array[String] attr_reader :parts diff --git a/test/rdoc/markup/raw_test.rb b/test/rdoc/markup/raw_test.rb index c52bab4f45..ea68532af3 100644 --- a/test/rdoc/markup/raw_test.rb +++ b/test/rdoc/markup/raw_test.rb @@ -9,6 +9,10 @@ def setup @p = @RM::Raw.new end + def test_inherits_markup_element + assert_operator @RM::Raw, :<, @RM::Element + end + def test_push @p.push 'hi', 'there' From 4959b92bbc3e0748218707275952966607bc035a Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 9 Aug 2026 11:40:47 +0100 Subject: [PATCH 2/4] Make list markup inherit from Element Co-authored-by: Vinicius Stock --- lib/rdoc/markup/list.rb | 2 +- lib/rdoc/markup/list_item.rb | 2 +- test/rdoc/markup/raw_test.rb | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/rdoc/markup/list.rb b/lib/rdoc/markup/list.rb index 9196904d5e..c6453480ba 100644 --- a/lib/rdoc/markup/list.rb +++ b/lib/rdoc/markup/list.rb @@ -21,7 +21,7 @@ # describe multiple terms. See RDoc::Markup::ListItem for how labels and # definition are stored as list items. -class RDoc::Markup::List +class RDoc::Markup::List < RDoc::Markup::Element ## # The list's type diff --git a/lib/rdoc/markup/list_item.rb b/lib/rdoc/markup/list_item.rb index 54a52f7a5e..4f9014daa2 100644 --- a/lib/rdoc/markup/list_item.rb +++ b/lib/rdoc/markup/list_item.rb @@ -9,7 +9,7 @@ # * an Array of Strings for a list item with multiple terms # * nil for an extra description attached to a previously labeled list item -class RDoc::Markup::ListItem +class RDoc::Markup::ListItem < RDoc::Markup::Element ## # The label for the ListItem diff --git a/test/rdoc/markup/raw_test.rb b/test/rdoc/markup/raw_test.rb index ea68532af3..c52bab4f45 100644 --- a/test/rdoc/markup/raw_test.rb +++ b/test/rdoc/markup/raw_test.rb @@ -9,10 +9,6 @@ def setup @p = @RM::Raw.new end - def test_inherits_markup_element - assert_operator @RM::Raw, :<, @RM::Element - end - def test_push @p.push 'hi', 'there' From c162cac17e7668dfa931a0d4c4f46c89c5103541 Mon Sep 17 00:00:00 2001 From: st0012 Date: Sun, 9 Aug 2026 11:54:46 +0100 Subject: [PATCH 3/4] Standardize List and ListItem markup Co-authored-by: Vinicius Stock --- lib/rdoc/markup/list.rb | 168 +++++++++++++++++------------------ lib/rdoc/markup/list_item.rb | 158 +++++++++++++++----------------- 2 files changed, 153 insertions(+), 173 deletions(-) diff --git a/lib/rdoc/markup/list.rb b/lib/rdoc/markup/list.rb index c6453480ba..5c927caa57 100644 --- a/lib/rdoc/markup/list.rb +++ b/lib/rdoc/markup/list.rb @@ -1,101 +1,93 @@ # frozen_string_literal: true -## -# A List is a homogeneous set of ListItems. -# -# The supported list types include: -# -# :BULLET:: -# An unordered list -# :LABEL:: -# An unordered definition list, but using an alternate RDoc::Markup syntax -# :LALPHA:: -# An ordered list using increasing lowercase English letters -# :NOTE:: -# An unordered definition list -# :NUMBER:: -# An ordered list using increasing Arabic numerals -# :UALPHA:: -# An ordered list using increasing uppercase English letters -# -# Definition lists behave like HTML definition lists. Each list item can -# describe multiple terms. See RDoc::Markup::ListItem for how labels and -# definition are stored as list items. -class RDoc::Markup::List < RDoc::Markup::Element - - ## - # The list's type - - attr_accessor :type - - ## - # Items in the list - - attr_reader :items - - ## - # Creates a new list of +type+ with +items+. Valid list types are: - # +:BULLET+, +:LABEL+, +:LALPHA+, +:NOTE+, +:NUMBER+, +:UALPHA+ - - def initialize(type = nil, *items) - @type = type - @items = [] - @items.concat items - end - - ## - # Appends +item+ to the list - - def <<(item) - @items << item - end - - def ==(other) # :nodoc: - self.class == other.class and - @type == other.type and - @items == other.items - end - - ## - # Runs this list and all its #items through +visitor+ - - def accept(visitor) - visitor.accept_list_start self +module RDoc + class Markup + # A List is a homogeneous set of ListItems. + # + # The supported list types include: + # + # :BULLET:: + # An unordered list + # :LABEL:: + # An unordered definition list, but using an alternate RDoc::Markup syntax + # :LALPHA:: + # An ordered list using increasing lowercase English letters + # :NOTE:: + # An unordered definition list + # :NUMBER:: + # An ordered list using increasing Arabic numerals + # :UALPHA:: + # An ordered list using increasing uppercase English letters + # + # Definition lists behave like HTML definition lists. Each list item can + # describe multiple terms. See RDoc::Markup::ListItem for how labels and + # definitions are stored as list items. + class List < Element + # The list's type + #: Symbol? + attr_accessor :type + + # Items in the list + #: Array[ListItem] + attr_reader :items + + # Creates a new list of +type+ with +items+. Valid list types are: + # +:BULLET+, +:LABEL+, +:LALPHA+, +:NOTE+, +:NUMBER+, +:UALPHA+ + #: (Symbol?, *ListItem) -> void + def initialize(type = nil, *items) + @type = type + @items = items + end - @items.each do |item| - item.accept visitor - end + # Appends +item+ to the list + #: (ListItem) -> void + def <<(item) + @items << item + end - visitor.accept_list_end self - end + #: (top) -> bool + def ==(other) # :nodoc: + self.class == other.class && + @type == other.type && + @items == other.items + end - ## - # Is the list empty? + # Runs this list and all its #items through +visitor+ + # @override + #: (untyped) -> void + def accept(visitor) + visitor.accept_list_start(self) + @items.each { |item| item.accept(visitor) } + visitor.accept_list_end(self) + end - def empty? - @items.empty? - end + # Is the list empty? + #: () -> bool + def empty? + @items.empty? + end - ## - # Returns the last item in the list + # Returns the last item in the list + #: () -> ListItem? + def last + @items.last + end - def last - @items.last - end + # @override + #: (PP) -> void + def pretty_print(q) # :nodoc: + q.group(2, "[list: #{@type} ", ']') do + q.seplist(@items) do |item| + q.pp(item) + end + end + end - def pretty_print(q) # :nodoc: - q.group 2, "[list: #{@type} ", ']' do - q.seplist @items do |item| - q.pp item + # Appends +items+ to the list + #: (*ListItem) -> void + def push(*items) + @items.concat(items) end end end - - ## - # Appends +items+ to the list - - def push(*items) - @items.concat items - end - end diff --git a/lib/rdoc/markup/list_item.rb b/lib/rdoc/markup/list_item.rb index 4f9014daa2..2ff283b734 100644 --- a/lib/rdoc/markup/list_item.rb +++ b/lib/rdoc/markup/list_item.rb @@ -1,99 +1,87 @@ # frozen_string_literal: true -## -# An item within a List that contains paragraphs, headings, etc. -# -# For BULLET, NUMBER, LALPHA and UALPHA lists, the label will always be nil. -# For NOTE and LABEL lists, the list label may contain: -# -# * a single String for a single label -# * an Array of Strings for a list item with multiple terms -# * nil for an extra description attached to a previously labeled list item -class RDoc::Markup::ListItem < RDoc::Markup::Element - - ## - # The label for the ListItem - - attr_accessor :label - - ## - # Parts of the ListItem - - attr_reader :parts - - ## - # Creates a new ListItem with an optional +label+ containing +parts+ - - def initialize(label = nil, *parts) - @label = label - @parts = [] - @parts.concat parts - end - - ## - # Appends +part+ to the ListItem - - def <<(part) - @parts << part - end - - def ==(other) # :nodoc: - self.class == other.class and - @label == other.label and - @parts == other.parts - end - - ## - # Runs this list item and all its #parts through +visitor+ - - def accept(visitor) - visitor.accept_list_item_start self - - @parts.each do |part| - part.accept visitor - end +module RDoc + class Markup + # An item within a List that contains paragraphs, headings, etc. + # + # For BULLET, NUMBER, LALPHA and UALPHA lists, the label will always be nil. + # For NOTE and LABEL lists, the list label may contain: + # + # * a single String for a single label + # * an Array of Strings for a list item with multiple terms + # * nil for an extra description attached to a previously labeled list item + class ListItem < Element + # The label for the ListItem + #: (Array[String] | String)? + attr_accessor :label + + # Parts of the ListItem + #: Array[untyped] + attr_reader :parts + + # Creates a new ListItem with an optional +label+ containing +parts+ + #: ((Array[String] | String)?, *untyped) -> void + def initialize(label = nil, *parts) + @label = label + @parts = parts + end - visitor.accept_list_item_end self - end + # Appends +part+ to the ListItem + #: (untyped) -> void + def <<(part) + @parts << part + end - ## - # Is the ListItem empty? + #: (top) -> bool + def ==(other) # :nodoc: + self.class == other.class && + @label == other.label && + @parts == other.parts + end - def empty? - @parts.empty? - end + # Runs this list item and all its #parts through +visitor+ + # @override + #: (untyped) -> void + def accept(visitor) + visitor.accept_list_item_start(self) + @parts.each { |part| part.accept(visitor) } + visitor.accept_list_item_end(self) + end - ## - # Length of parts in the ListItem + # Is the ListItem empty? + #: () -> bool + def empty? + @parts.empty? + end - def length - @parts.length - end + # Length of parts in the ListItem + #: () -> Integer + def length + @parts.length + end - def pretty_print(q) # :nodoc: - q.group 2, '[item: ', ']' do - case @label - when Array then - q.pp @label - q.text ';' - q.breakable - when String then - q.pp @label - q.text ';' - q.breakable + # @override + #: (PP) -> void + def pretty_print(q) # :nodoc: + q.group(2, '[item: ', ']') do + case @label + when Array, String + q.pp(@label) + q.text(';') + q.breakable + end + + q.seplist(@parts) do |part| + q.pp(part) + end + end end - q.seplist @parts do |part| - q.pp part + # Adds +parts+ to the ListItem + #: (*untyped) -> void + def push(*parts) + @parts.concat(parts) end end end - - ## - # Adds +parts+ to the ListItem - - def push(*parts) - @parts.concat parts - end - end From 3974b74a784ff637d542e63ad125533fe11ed766 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 9 Aug 2026 12:12:04 +0100 Subject: [PATCH 4/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- lib/rdoc/markup/raw.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/markup/raw.rb b/lib/rdoc/markup/raw.rb index 5cb987fd31..28fee6c488 100644 --- a/lib/rdoc/markup/raw.rb +++ b/lib/rdoc/markup/raw.rb @@ -4,7 +4,7 @@ module RDoc class Markup # A section of text that is added to the output document as-is class Raw < Element - # The component parts of the list + # The component parts of the raw text #: Array[String] attr_reader :parts