From f62f91313259539e8f0884a0ca99deb3ab8b87d3 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 8 Mar 2022 17:02:35 -0500 Subject: [ruby/rdoc] Support crossref of methods with multiple arguments For example, consider the following markup: C1#m(a, b) Before this patch, it generated this HTML:

C1#m(a, b)

Which places the method arguments outside of the link. Now it generates this HTML: C1#m(a, b) https://github.com/ruby/rdoc/commit/05a2b2222b --- lib/rdoc/cross_reference.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/rdoc/cross_reference.rb') diff --git a/lib/rdoc/cross_reference.rb b/lib/rdoc/cross_reference.rb index 7c0b405f3a..0f301dcbb3 100644 --- a/lib/rdoc/cross_reference.rb +++ b/lib/rdoc/cross_reference.rb @@ -14,12 +14,22 @@ class RDoc::CrossReference CLASS_REGEXP_STR = '\\\\?((?:\:{2})?[A-Z]\w*(?:\:\:\w+)*)' + ## + # Regular expression to match a single method argument. + + METHOD_ARG_REGEXP_STR = '[\w.+*/=<>-]+' + + ## + # Regular expression to match method arguments. + + METHOD_ARGS_REGEXP_STR = /(?:\((?:#{METHOD_ARG_REGEXP_STR}(?:,\s*#{METHOD_ARG_REGEXP_STR})*)?\))?/.source + ## # Regular expression to match method references. # # See CLASS_REGEXP_STR - METHOD_REGEXP_STR = '([A-Za-z]\w*[!?=]?|%|=(?:==?|~)|![=~]|\[\]=?|<(?:<|=>?)?|>[>=]?|[-+!]@?|\*\*?|[/%`|&^~])(?:\([\w.+*/=<>-]*\))?' + METHOD_REGEXP_STR = /([A-Za-z]\w*[!?=]?|%|=(?:==?|~)|![=~]|\[\]=?|<(?:<|=>?)?|>[>=]?|[-+!]@?|\*\*?|[\/%`|&^~])#{METHOD_ARGS_REGEXP_STR}/.source ## # Regular expressions matching text that should potentially have -- cgit v1.2.3