diff options
author | Peter Zhu <peter@peterzhu.ca> | 2022-03-08 17:02:35 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2022-03-09 23:38:45 +0900 |
commit | f62f91313259539e8f0884a0ca99deb3ab8b87d3 (patch) | |
tree | 0a84c4597cdaaa579ffe884fcc2cbe9eb84a2071 /lib/rdoc/cross_reference.rb | |
parent | 77f3f8a1d4f45d06df6cfea2bac3a67867c19efb (diff) |
[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:
<p><a href=\"C1.html#method-i-m\"><code>C1#m</code></a>(a, b)</p>
Which places the method arguments outside of the link.
Now it generates this HTML:
<a href=\"C1.html#method-i-m\"><code>C1#m(a, b)</code></a>
https://github.com/ruby/rdoc/commit/05a2b2222b
Diffstat (limited to 'lib/rdoc/cross_reference.rb')
-rw-r--r-- | lib/rdoc/cross_reference.rb | 12 |
1 files changed, 11 insertions, 1 deletions
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 @@ -15,11 +15,21 @@ 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 |