Skip to content

Commit

Permalink
Simplify syntax (no-op change)
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Oct 11, 2020
1 parent 50aa74d commit 227e486
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/compiler/crystal/tools/doc/markdown/doc_renderer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class Crystal::Doc::Markdown::DocRenderer < Crystal::Doc::Markdown::HTMLRenderer

def detect_code_link(text : String) : String
# Check method reference (without #, but must be the whole text)
if text =~ /\A((?:\w|\<|\=|\>|\+|\-|\*|\/|\[|\]|\&|\||\?|\!|\^|\~)+(?:\?|\!)?)(\(.+?\))?\Z/
if text =~ /\A([\w<=>+\-*\/\[\]&|?!^~]+[?!]?)(\(.+?\))?\Z/
name = $1
args = $~.not_nil![2]? || ""
args = $2? || ""

method = lookup_method @type, name, args
if method
Expand All @@ -47,13 +47,13 @@ class Crystal::Doc::Markdown::DocRenderer < Crystal::Doc::Markdown::HTMLRenderer
end

# Check Type#method(...) or Type or #method(...)
text = text.gsub /\b
((?:\:\:)?[A-Z]\w+(?:\:\:[A-Z]\w+)*(?:\#|\.)(?:\w|\<|\=|\>|\+|\-|\*|\/|\[|\]|\&|\||\?|\!|\^|\~)+(?:\?|\!)?(?:\(.+?\))?)
text.gsub %r(\b
((?:\:\:)?[A-Z]\w+(?:\:\:[A-Z]\w+)*[#\.][\w<=>+\-*\/\[\]&|?!^~]+[?!]?(?:\(.+?\))?)
|
((?:\:\:)?[A-Z]\w+(?:\:\:[A-Z]\w+)*)
|
((?:\#|\.)(?:\w|\<|\=|\>|\+|\-|\*|\/|\[|\]|\&|\||\?|\!|\^|\~)+(?:\?|\!)?(?:\(.+?\))?)
/x do |match_text, match|
([#\.][\w<=>+\-*\/\[\]&|?!^~]+[?!]?(?:\(.+?\))?)
)x do |match_text, match|
sharp_index = match_text.index('#')
dot_index = match_text.index('.')
kind = sharp_index ? :instance : :class
Expand Down

0 comments on commit 227e486

Please sign in to comment.