Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify attribute exclusiveness conditions #851

Merged
merged 2 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 4 additions & 24 deletions lib/rdoc/markup/attribute_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,7 @@ def convert_attrs(str, attrs, exclusive = false)
def convert_attrs_matching_word_pairs(str, attrs, exclusive)
# first do matching ones
tags = @matching_word_pairs.select { |start, bitmap|
if exclusive && exclusive?(bitmap)
true
elsif !exclusive && !exclusive?(bitmap)
true
else
false
end
exclusive == exclusive?(bitmap)
}.keys
return if tags.empty?
all_tags = @matching_word_pairs.keys
Expand All @@ -176,11 +170,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive)
# then non-matching
unless @word_pair_map.empty? then
@word_pair_map.each do |regexp, attr|
if !exclusive
next if exclusive?(attr)
else
next if !exclusive?(attr)
end
next unless exclusive == exclusive?(attr)
1 while str.gsub!(regexp) { |orig|
updated = attrs.set_attrs($`.length + $1.length, $2.length, attr)
if updated
Expand All @@ -198,13 +188,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive)

def convert_html(str, attrs, exclusive = false)
tags = @html_tags.select { |start, bitmap|
if exclusive && exclusive?(bitmap)
true
elsif !exclusive && !exclusive?(bitmap)
true
else
false
end
exclusive == exclusive?(bitmap)
}.keys.join '|'

1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig|
Expand All @@ -221,11 +205,7 @@ def convert_html(str, attrs, exclusive = false)

def convert_regexp_handlings str, attrs, exclusive = false
@regexp_handlings.each do |regexp, attribute|
if exclusive
next if !exclusive?(attribute)
else
next if exclusive?(attribute)
end
next unless exclusive == exclusive?(attribute)
str.scan(regexp) do
capture = $~.size == 1 ? 0 : 1

Expand Down
3 changes: 2 additions & 1 deletion lib/rdoc/parser/c.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,8 @@ def handle_method(type, var_name, meth_name, function, param_count,
elsif p_count == -1 then # argc, argv
rb_scan_args body
else
"(#{(1..p_count).map { |i| "p#{i}" }.join ', '})"
args = (1..p_count).map { |i| "p#{i}" }
"(#{args.join ', '})"
end


Expand Down
2 changes: 1 addition & 1 deletion test/rdoc/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def test_parse_class_lower_name_warning
@parser.parse_class @top_level, RDoc::Parser::Ruby::NORMAL, tk, @comment
end
err = stds[1]
assert_match(/Expected class name or '<<'\. Got/, err)
assert_match(/Expected class name or '<<\'\. Got/, err)
end

def test_parse_syntax_error_code
Expand Down