From b6caf9602aa50f7892518213e31afde2d45cf036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 3 Jan 2017 03:35:43 -0800 Subject: [PATCH 1/2] Autolink more Objective-C methods --- CHANGELOG.md | 2 +- lib/jazzy/sourcekitten.rb | 12 +++++++++--- spec/integration_specs | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1b8b61de..241ddfa59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ [#361](https://github.com/realm/jazzy/issues/361) [#547](https://github.com/realm/jazzy/issues/547) -* Fully qualified references to Objective-C methods are now autolinked. +* References to Objective-C methods are now autolinked. [Minh Nguyễn](https://github.com/1ec5) [#362](https://github.com/realm/jazzy/issues/362) diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 30486261c..bf537deff 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -534,12 +534,12 @@ def self.autolink_text(text, doc, root_decls, after_highlight = false) # Traverse children via subsequence components, if any name_traversal(parts, name_root) - end.autolink_block(doc.url, '[+-]\[\w+ [\w:]+\]', + end.autolink_block(doc.url, '[+-]\[\w+(?: ?\(\w+\))? [\w:]+\]', after_highlight) do |raw_name| - match = raw_name.match(/([+-])\[(\w+) ([\w:]+)\]/) + match = raw_name.match(/([+-])\[(\w+(?: ?\(\w+\))?) ([\w:]+)\]/) # Subject component can match any ancestor or top-level doc - subject = match[2] + subject = match[2].gsub(' ', '') name_root = ancestor_name_match(subject, doc) || name_match(subject, root_decls) @@ -548,6 +548,12 @@ def self.autolink_text(text, doc, root_decls, after_highlight = false) verb = match[1] + match[3] name_match(verb, name_root.children) end + end.autolink_block(doc.url, '[+-]\w[\w:]*', + after_highlight) do |raw_name| + match = raw_name.match(/([+-])(\w[\w:]*)/) + + verb = match[1] + match[2] + name_match(verb, doc.children) end end diff --git a/spec/integration_specs b/spec/integration_specs index 1fdea5730..37ebd2224 160000 --- a/spec/integration_specs +++ b/spec/integration_specs @@ -1 +1 @@ -Subproject commit 1fdea573086d24cfedf80d1c76cf061ff947d0ff +Subproject commit 37ebd222427336a865549fda800fabb25a7f371c From 7d6a5564c030b8b86b7cb68e95e14674a210ed96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Tue, 3 Jan 2017 04:20:03 -0800 Subject: [PATCH 2/2] Fixed RuboCop errors --- lib/jazzy/sourcekitten.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index bf537deff..4ffe0d094 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -539,21 +539,16 @@ def self.autolink_text(text, doc, root_decls, after_highlight = false) match = raw_name.match(/([+-])\[(\w+(?: ?\(\w+\))?) ([\w:]+)\]/) # Subject component can match any ancestor or top-level doc - subject = match[2].gsub(' ', '') + subject = match[2].delete(' ') name_root = ancestor_name_match(subject, doc) || name_match(subject, root_decls) if name_root # Look up the verb in the subject’s children - verb = match[1] + match[3] - name_match(verb, name_root.children) + name_match(match[1] + match[3], name_root.children) end - end.autolink_block(doc.url, '[+-]\w[\w:]*', - after_highlight) do |raw_name| - match = raw_name.match(/([+-])(\w[\w:]*)/) - - verb = match[1] + match[2] - name_match(verb, doc.children) + end.autolink_block(doc.url, '[+-]\w[\w:]*', after_highlight) do |raw_name| + name_match(raw_name, doc.children) end end