From ac55e5d3d6aa8d9f92703806f3447035c96c4f1b Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Fri, 7 Aug 2015 23:20:11 -0500 Subject: [PATCH 01/11] Merge extensions into the type they extend --- lib/jazzy/source_declaration/type.rb | 4 ++++ lib/jazzy/sourcekitten.rb | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/jazzy/source_declaration/type.rb b/lib/jazzy/source_declaration/type.rb index 81888df2e..c12c5b865 100644 --- a/lib/jazzy/source_declaration/type.rb +++ b/lib/jazzy/source_declaration/type.rb @@ -61,6 +61,10 @@ def extension? kind =~ /^source\.lang\.swift\.decl\.extension.*/ end + def extensible? + kind =~ /^source\.lang\.swift\.decl\.(class|struct|protocol|enum)$/ + end + def param? # SourceKit strangely categorizes initializer parameters as local # variables, so both kinds represent a parameter in jazzy. diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 3cb3bd355..04942a5ee 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -302,15 +302,33 @@ def self.doc_coverage (@undocumented_tokens.count + @documented_count) end + # Merges multiple extensions of the same entity into a single document. + # + # Merges extensions into the protocol/class/struct/enum they extend, if it + # occurs in the same project. + # + # Merges redundant declarations when documenting podspecs. def self.deduplicate_declarations(declarations) - duplicates = declarations.group_by { |d| [d.usr, d.type.kind] }.values + duplicates = declarations.group_by { |d| deduplication_key(d) }.values + duplicates.map do |decls| + # Put extended type (if present) before extensions + decls = decls.partition { |d| d.type.extensible? }.flatten decls.first.tap do |d| d.children = deduplicate_declarations(decls.flat_map(&:children).uniq) end end end + # Two declarations get merged if they have the same deduplication key. + def self.deduplication_key(decl) + if decl.type.extensible? || decl.type.extension? + [decl.usr] + else + [decl.usr, decl.type.kind] + end + end + def self.filter_excluded_files(json) excluded_files = Config.instance.excluded_files json.map do |doc| From c722c0d79233c10b3c95363a76771b97911e67ee Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Thu, 13 Aug 2015 23:16:10 -0500 Subject: [PATCH 02/11] Merge default implementations into protocols --- lib/jazzy/assets/css/jazzy.css.scss | 5 ++++ lib/jazzy/doc_builder.rb | 1 + lib/jazzy/source_declaration.rb | 1 + lib/jazzy/source_declaration/type.rb | 4 +++ lib/jazzy/sourcekitten.rb | 40 +++++++++++++++++++++++----- lib/jazzy/templates/task.mustache | 11 ++++++++ 6 files changed, 56 insertions(+), 6 deletions(-) diff --git a/lib/jazzy/assets/css/jazzy.css.scss b/lib/jazzy/assets/css/jazzy.css.scss index 0ea17016a..3b92564dd 100644 --- a/lib/jazzy/assets/css/jazzy.css.scss +++ b/lib/jazzy/assets/css/jazzy.css.scss @@ -311,6 +311,11 @@ header { padding-left: 3px; margin-left: 15px; } + .has_default_implementation { + font-size: .85em; + color: rgba(128,128,128,1); + font-style: italic; + } } .pointer-container { diff --git a/lib/jazzy/doc_builder.rb b/lib/jazzy/doc_builder.rb index 3b63f2a6d..db028810c 100644 --- a/lib/jazzy/doc_builder.rb +++ b/lib/jazzy/doc_builder.rb @@ -242,6 +242,7 @@ def self.render_item(item, source_module) } gh_token_url = gh_token_url(item, source_module) item_render[:github_token_url] = gh_token_url + item_render[:default_impl_abstract] = Jazzy.markdown.render(item.default_impl_abstract) if item.default_impl_abstract item_render[:return] = Jazzy.markdown.render(item.return) if item.return item_render[:parameters] = item.parameters if item.parameters.any? item_render[:url] = item.url if item.children.any? diff --git a/lib/jazzy/source_declaration.rb b/lib/jazzy/source_declaration.rb index 2ee79402b..3afa290ff 100644 --- a/lib/jazzy/source_declaration.rb +++ b/lib/jazzy/source_declaration.rb @@ -14,6 +14,7 @@ class SourceDeclaration attr_accessor :name attr_accessor :declaration attr_accessor :abstract + attr_accessor :default_impl_abstract attr_accessor :discussion attr_accessor :return attr_accessor :children diff --git a/lib/jazzy/source_declaration/type.rb b/lib/jazzy/source_declaration/type.rb index c12c5b865..09413c0cc 100644 --- a/lib/jazzy/source_declaration/type.rb +++ b/lib/jazzy/source_declaration/type.rb @@ -65,6 +65,10 @@ def extensible? kind =~ /^source\.lang\.swift\.decl\.(class|struct|protocol|enum)$/ end + def protocol? + kind =~ /^source\.lang\.swift\.decl\.protocol$/ + end + def param? # SourceKit strangely categorizes initializer parameters as local # variables, so both kinds represent a parameter in jazzy. diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 04942a5ee..2532d3ede 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -309,14 +309,11 @@ def self.doc_coverage # # Merges redundant declarations when documenting podspecs. def self.deduplicate_declarations(declarations) - duplicates = declarations.group_by { |d| deduplication_key(d) }.values + duplicate_groups = declarations.group_by { |d| deduplication_key(d) }.values - duplicates.map do |decls| + duplicate_groups.map do |group| # Put extended type (if present) before extensions - decls = decls.partition { |d| d.type.extensible? }.flatten - decls.first.tap do |d| - d.children = deduplicate_declarations(decls.flat_map(&:children).uniq) - end + merge_declarations(group) end end @@ -329,6 +326,37 @@ def self.deduplication_key(decl) end end + # Merges all of the given types and extensions into a single document. + def self.merge_declarations(decls) + extensions, types = decls.partition { |d| d.type.extension? } + + types.select { |t| t.type.protocol? }.each do |protocol| + merge_default_implementations_into_protocol(protocol, extensions) + end + + decls = types + extensions + decls.first.tap do |d| + d.children = deduplicate_declarations(decls.flat_map(&:children).uniq) + end + end + + # If any of the extensions provide default implementations for methods in the + # given protocol, merge those members into the protocol doc instead of keeping + # them on the extension. + def self.merge_default_implementations_into_protocol(protocol, extensions) + protocol.children.each do |proto_method| + extensions.each do |ext| + defaults, ext.children = ext.children.partition do |ext_member| + ext_member.name == proto_method.name + end + unless defaults.empty? + proto_method.default_impl_abstract = + defaults.flat_map { |d| [d.abstract, d.discussion] }.join("\n\n") + end + end + end + end + def self.filter_excluded_files(json) excluded_files = Config.instance.excluded_files json.map do |doc| diff --git a/lib/jazzy/templates/task.mustache b/lib/jazzy/templates/task.mustache index 19cf1f86f..181029418 100755 --- a/lib/jazzy/templates/task.mustache +++ b/lib/jazzy/templates/task.mustache @@ -17,6 +17,11 @@ {{name}} + {{#default_impl_abstract}} + + Default implementation + + {{/default_impl_abstract}}
@@ -30,6 +35,12 @@ {{/url}}
{{/abstract}} + {{#default_impl_abstract}} +

Default Implementation

+
+ {{{default_impl_abstract}}} +
+ {{/default_impl_abstract}} {{#declaration}}

Declaration

From 29ee7c6479bfcdee641dea9d0badebfcf42dd7fd Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Fri, 14 Aug 2015 01:11:37 -0500 Subject: [PATCH 03/11] Visually distinguish required & ext members in protocol --- lib/jazzy/sourcekitten.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 2532d3ede..b98a2bece 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -328,13 +328,28 @@ def self.deduplication_key(decl) # Merges all of the given types and extensions into a single document. def self.merge_declarations(decls) - extensions, types = decls.partition { |d| d.type.extension? } + extensions, typedecls = decls.partition { |d| d.type.extension? } - types.select { |t| t.type.protocol? }.each do |protocol| - merge_default_implementations_into_protocol(protocol, extensions) + if typedecls.size > 1 + warn "Found conflicting type declarations with the same name, which " + + "may indicate a build issue or a bug in Jazzy: " + + types.map { |t| "#{t.type.name.downcase} #{t.name}" }.join(', ') end + typedecl = typedecls.first - decls = types + extensions + if typedecl && typedecl.type.protocol? + merge_default_implementations_into_protocol(typedecl, extensions) + extensions.reject! { |ext| ext.children.empty? } + + ext_mark = SourceMark.new('- Extension Members') + extensions.each do |ext| + ext.children.each do |ext_member| + ext_member.mark = ext_mark + end + end + end + + decls = typedecls + extensions decls.first.tap do |d| d.children = deduplicate_declarations(decls.flat_map(&:children).uniq) end From 09a7c5d43fade359433ee5715762c6cb5fa76676 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Wed, 26 Aug 2015 16:22:46 -0700 Subject: [PATCH 04/11] typo --- lib/jazzy/sourcekitten.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index b98a2bece..30663779d 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -333,7 +333,7 @@ def self.merge_declarations(decls) if typedecls.size > 1 warn "Found conflicting type declarations with the same name, which " + "may indicate a build issue or a bug in Jazzy: " + - types.map { |t| "#{t.type.name.downcase} #{t.name}" }.join(', ') + typedecls.map { |t| "#{t.type.name.downcase} #{t.name}" }.join(', ') end typedecl = typedecls.first From 896dedfd374200b7db49596766be0e2f4384c7bd Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Fri, 30 Oct 2015 13:56:06 -0500 Subject: [PATCH 05/11] Declaration note instead of generated mark for protocol extension members --- lib/jazzy/assets/css/jazzy.css.scss | 2 +- lib/jazzy/doc_builder.rb | 1 + lib/jazzy/source_declaration.rb | 1 + lib/jazzy/sourcekitten.rb | 3 +-- lib/jazzy/templates/task.mustache | 7 ++++++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/jazzy/assets/css/jazzy.css.scss b/lib/jazzy/assets/css/jazzy.css.scss index 3b92564dd..3df5755bf 100644 --- a/lib/jazzy/assets/css/jazzy.css.scss +++ b/lib/jazzy/assets/css/jazzy.css.scss @@ -311,7 +311,7 @@ header { padding-left: 3px; margin-left: 15px; } - .has_default_implementation { + .declaration-note { font-size: .85em; color: rgba(128,128,128,1); font-style: italic; diff --git a/lib/jazzy/doc_builder.rb b/lib/jazzy/doc_builder.rb index db028810c..dc24cf468 100644 --- a/lib/jazzy/doc_builder.rb +++ b/lib/jazzy/doc_builder.rb @@ -243,6 +243,7 @@ def self.render_item(item, source_module) gh_token_url = gh_token_url(item, source_module) item_render[:github_token_url] = gh_token_url item_render[:default_impl_abstract] = Jazzy.markdown.render(item.default_impl_abstract) if item.default_impl_abstract + item_render[:merged_from_protocol_extension] = item.merged_from_protocol_extension item_render[:return] = Jazzy.markdown.render(item.return) if item.return item_render[:parameters] = item.parameters if item.parameters.any? item_render[:url] = item.url if item.children.any? diff --git a/lib/jazzy/source_declaration.rb b/lib/jazzy/source_declaration.rb index 3afa290ff..c78f5a9be 100644 --- a/lib/jazzy/source_declaration.rb +++ b/lib/jazzy/source_declaration.rb @@ -15,6 +15,7 @@ class SourceDeclaration attr_accessor :declaration attr_accessor :abstract attr_accessor :default_impl_abstract + attr_accessor :merged_from_protocol_extension attr_accessor :discussion attr_accessor :return attr_accessor :children diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 30663779d..29229a286 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -341,10 +341,9 @@ def self.merge_declarations(decls) merge_default_implementations_into_protocol(typedecl, extensions) extensions.reject! { |ext| ext.children.empty? } - ext_mark = SourceMark.new('- Extension Members') extensions.each do |ext| ext.children.each do |ext_member| - ext_member.mark = ext_mark + ext_member.merged_from_protocol_extension = true end end end diff --git a/lib/jazzy/templates/task.mustache b/lib/jazzy/templates/task.mustache index 181029418..48ea1a139 100755 --- a/lib/jazzy/templates/task.mustache +++ b/lib/jazzy/templates/task.mustache @@ -18,10 +18,15 @@ {{name}} {{#default_impl_abstract}} - + Default implementation {{/default_impl_abstract}} + {{#merged_from_protocol_extension}} + + Extension method + + {{/merged_from_protocol_extension}}
From 000126430cb52e61ce405bb56ba7ed91a9c0518d Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Mon, 9 Nov 2015 22:56:34 -0600 Subject: [PATCH 06/11] Mopped up item_render, made rubocop happier --- lib/jazzy/doc_builder.rb | 31 +++++++++++++++++-------------- lib/jazzy/source_declaration.rb | 2 +- lib/jazzy/sourcekitten.rb | 2 +- lib/jazzy/templates/task.mustache | 4 ++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/jazzy/doc_builder.rb b/lib/jazzy/doc_builder.rb index dc24cf468..6bc20d0ec 100644 --- a/lib/jazzy/doc_builder.rb +++ b/lib/jazzy/doc_builder.rb @@ -234,24 +234,27 @@ def self.render_item(item, source_module) # Combine abstract and discussion into abstract abstract = (item.abstract || '') + (item.discussion || '') item_render = { - name: item.name, - abstract: Jazzy.markdown.render(abstract), - declaration: item.declaration, - usr: item.usr, - dash_type: item.type.dash_type, + name: item.name, + abstract: render_markdown(abstract), + declaration: item.declaration, + usr: item.usr, + dash_type: item.type.dash_type, + github_token_url: gh_token_url(item, source_module), + default_impl_abstract: render_markdown(item.default_impl_abstract), + from_protocol_extension: item.from_protocol_extension, + return: render_markdown(item.return), + parameters: (item.parameters if item.parameters.any?), + url: (item.url if item.children.any?), + start_line: item.start_line, + end_line: item.end_line, } - gh_token_url = gh_token_url(item, source_module) - item_render[:github_token_url] = gh_token_url - item_render[:default_impl_abstract] = Jazzy.markdown.render(item.default_impl_abstract) if item.default_impl_abstract - item_render[:merged_from_protocol_extension] = item.merged_from_protocol_extension - item_render[:return] = Jazzy.markdown.render(item.return) if item.return - item_render[:parameters] = item.parameters if item.parameters.any? - item_render[:url] = item.url if item.children.any? - item_render[:start_line] = item.start_line - item_render[:end_line] = item.end_line item_render.reject { |_, v| v.nil? } end + def self.render_markdown(markdown) + Jazzy.markdown.render(markdown) if markdown + end + def self.make_task(mark, uid, items) { name: mark.name, diff --git a/lib/jazzy/source_declaration.rb b/lib/jazzy/source_declaration.rb index c78f5a9be..ce6244110 100644 --- a/lib/jazzy/source_declaration.rb +++ b/lib/jazzy/source_declaration.rb @@ -15,7 +15,7 @@ class SourceDeclaration attr_accessor :declaration attr_accessor :abstract attr_accessor :default_impl_abstract - attr_accessor :merged_from_protocol_extension + attr_accessor :from_protocol_extension attr_accessor :discussion attr_accessor :return attr_accessor :children diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 29229a286..f858743af 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -343,7 +343,7 @@ def self.merge_declarations(decls) extensions.each do |ext| ext.children.each do |ext_member| - ext_member.merged_from_protocol_extension = true + ext_member.from_protocol_extension = true end end end diff --git a/lib/jazzy/templates/task.mustache b/lib/jazzy/templates/task.mustache index 48ea1a139..a02a1135b 100755 --- a/lib/jazzy/templates/task.mustache +++ b/lib/jazzy/templates/task.mustache @@ -22,11 +22,11 @@ Default implementation {{/default_impl_abstract}} - {{#merged_from_protocol_extension}} + {{#from_protocol_extension}} Extension method - {{/merged_from_protocol_extension}} + {{/from_protocol_extension}}
From db728036a4b22e45b9977d5feccf530742083db7 Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Mon, 9 Nov 2015 22:59:56 -0600 Subject: [PATCH 07/11] Rubocop minutiae --- lib/jazzy/sourcekitten.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index f858743af..46cee99b7 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -309,7 +309,9 @@ def self.doc_coverage # # Merges redundant declarations when documenting podspecs. def self.deduplicate_declarations(declarations) - duplicate_groups = declarations.group_by { |d| deduplication_key(d) }.values + duplicate_groups = declarations + .group_by { |d| deduplication_key(d) } + .values duplicate_groups.map do |group| # Put extended type (if present) before extensions @@ -331,8 +333,8 @@ def self.merge_declarations(decls) extensions, typedecls = decls.partition { |d| d.type.extension? } if typedecls.size > 1 - warn "Found conflicting type declarations with the same name, which " + - "may indicate a build issue or a bug in Jazzy: " + + warn 'Found conflicting type declarations with the same name, which ' \ + 'may indicate a build issue or a bug in Jazzy: ' + typedecls.map { |t| "#{t.type.name.downcase} #{t.name}" }.join(', ') end typedecl = typedecls.first @@ -354,9 +356,9 @@ def self.merge_declarations(decls) end end - # If any of the extensions provide default implementations for methods in the - # given protocol, merge those members into the protocol doc instead of keeping - # them on the extension. + # If any of the extensions provide default implementations for methods in + # the given protocol, merge those members into the protocol doc instead of + # keeping them on the extension. def self.merge_default_implementations_into_protocol(protocol, extensions) protocol.children.each do |proto_method| extensions.each do |ext| From 7466648f9d2640399c72913cc2ea6750f84acd66 Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Tue, 10 Nov 2015 00:16:24 -0600 Subject: [PATCH 08/11] Updated integration specs --- spec/integration_specs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/integration_specs b/spec/integration_specs index c853aca51..9c7d20955 160000 --- a/spec/integration_specs +++ b/spec/integration_specs @@ -1 +1 @@ -Subproject commit c853aca510d889b64615b3e5b3850c895bffdb21 +Subproject commit 9c7d2095516cec44a8b557dd120d1bc1a08faa3c From a083b9e8f37a65cbfb3b18f6e86aae3248febc7d Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Tue, 10 Nov 2015 14:16:28 -0600 Subject: [PATCH 09/11] swift_ prefixes for new type tests --- lib/jazzy/source_declaration/type.rb | 8 ++++---- lib/jazzy/sourcekitten.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/jazzy/source_declaration/type.rb b/lib/jazzy/source_declaration/type.rb index 09413c0cc..1988c4fc9 100644 --- a/lib/jazzy/source_declaration/type.rb +++ b/lib/jazzy/source_declaration/type.rb @@ -57,16 +57,16 @@ def declaration? kind.start_with?('sourcekitten.source.lang.objc.decl') end - def extension? + def swift_extension? kind =~ /^source\.lang\.swift\.decl\.extension.*/ end - def extensible? + def swift_extensible? kind =~ /^source\.lang\.swift\.decl\.(class|struct|protocol|enum)$/ end - def protocol? - kind =~ /^source\.lang\.swift\.decl\.protocol$/ + def swift_protocol? + kind == 'source.lang.swift.decl.protocol' end def param? diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 46cee99b7..8d924dda8 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -161,7 +161,7 @@ def self.should_document?(doc) # Document extensions & enum elements, since we can't tell their ACL. type = SourceDeclaration::Type.new(doc['key.kind']) return true if type.swift_enum_element? - if type.extension? + if type.swift_extension? return Array(doc['key.substructure']).any? do |subdoc| should_document?(subdoc) end @@ -321,7 +321,7 @@ def self.deduplicate_declarations(declarations) # Two declarations get merged if they have the same deduplication key. def self.deduplication_key(decl) - if decl.type.extensible? || decl.type.extension? + if decl.type.swift_extensible? || decl.type.swift_extension? [decl.usr] else [decl.usr, decl.type.kind] @@ -330,7 +330,7 @@ def self.deduplication_key(decl) # Merges all of the given types and extensions into a single document. def self.merge_declarations(decls) - extensions, typedecls = decls.partition { |d| d.type.extension? } + extensions, typedecls = decls.partition { |d| d.type.swift_extension? } if typedecls.size > 1 warn 'Found conflicting type declarations with the same name, which ' \ @@ -339,7 +339,7 @@ def self.merge_declarations(decls) end typedecl = typedecls.first - if typedecl && typedecl.type.protocol? + if typedecl && typedecl.type.swift_protocol? merge_default_implementations_into_protocol(typedecl, extensions) extensions.reject! { |ext| ext.children.empty? } From 9cf9534ff360638143cabcacab030b27a6137e1c Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Tue, 10 Nov 2015 14:38:23 -0600 Subject: [PATCH 10/11] Minor refactoring & comments for readability --- lib/jazzy/sourcekitten.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 8d924dda8..fb4ee165f 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -341,13 +341,8 @@ def self.merge_declarations(decls) if typedecl && typedecl.type.swift_protocol? merge_default_implementations_into_protocol(typedecl, extensions) + mark_members_from_protocol_extension(extensions) extensions.reject! { |ext| ext.children.empty? } - - extensions.each do |ext| - ext.children.each do |ext_member| - ext_member.from_protocol_extension = true - end - end end decls = typedecls + extensions @@ -358,7 +353,8 @@ def self.merge_declarations(decls) # If any of the extensions provide default implementations for methods in # the given protocol, merge those members into the protocol doc instead of - # keeping them on the extension. + # keeping them on the extension. These get a “Default implementation” + # annotation in the generated docs. def self.merge_default_implementations_into_protocol(protocol, extensions) protocol.children.each do |proto_method| extensions.each do |ext| @@ -373,6 +369,17 @@ def self.merge_default_implementations_into_protocol(protocol, extensions) end end + # Protocol methods provided only in an extension and not in the protocol + # itself are a special beast: they do not use dynamic dispatch. These get an + # “Extension method” annotation in the generated docs. + def self.mark_members_from_protocol_extension(extensions) + extensions.each do |ext| + ext.children.each do |ext_member| + ext_member.from_protocol_extension = true + end + end + end + def self.filter_excluded_files(json) excluded_files = Config.instance.excluded_files json.map do |doc| From c0ee2fb263a538414ddc7a34e5d6726cd96ff5d4 Mon Sep 17 00:00:00 2001 From: Paul Cantrell Date: Tue, 10 Nov 2015 16:35:04 -0600 Subject: [PATCH 11/11] Attempted indentation fix for rubocop --- lib/jazzy/sourcekitten.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index fb4ee165f..5d6a69bac 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -310,8 +310,8 @@ def self.doc_coverage # Merges redundant declarations when documenting podspecs. def self.deduplicate_declarations(declarations) duplicate_groups = declarations - .group_by { |d| deduplication_key(d) } - .values + .group_by { |d| deduplication_key(d) } + .values duplicate_groups.map do |group| # Put extended type (if present) before extensions