From 7728656ba0e2714c05bbf22c83e17d567d289f8a Mon Sep 17 00:00:00 2001 From: John Fairhurst Date: Mon, 8 Nov 2021 12:21:35 +0000 Subject: [PATCH] Work around Swift 5.6 modulename change (#1288) --- CHANGELOG.md | 5 ++++- lib/jazzy/source_declaration.rb | 6 ++++-- lib/jazzy/sourcekitten.rb | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e4dc42d0..8ec65d424 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ ##### Breaking -* None. +* When building with Swift 5.6 and not passing `—module` to Jazzy, declarations + may not be correctly identified as undocumented and docs may include unwanted + extensions. Pass `—-module MyModuleName` to fix this. + [John Fairhurst](https://github.com/johnfairh) ##### Enhancements diff --git a/lib/jazzy/source_declaration.rb b/lib/jazzy/source_declaration.rb index f31a6b6ee..7643b3351 100644 --- a/lib/jazzy/source_declaration.rb +++ b/lib/jazzy/source_declaration.rb @@ -183,10 +183,12 @@ def other_inherited_types?(unwanted) inherited_types.any? { |t| !unwanted.include?(t) } end - # SourceKit only sets modulename for imported modules + # Pre-Swift 5.6: SourceKit only sets modulename for imported modules + # Swift 5.6+: modulename is always set def type_from_doc_module? !type.extension? || - (swift? && usr && modulename.nil?) + (swift? && usr && + (modulename.nil? || modulename == Config.instance.module_name)) end # Info text for contents page by collapsed item name diff --git a/lib/jazzy/sourcekitten.rb b/lib/jazzy/sourcekitten.rb index 8cbc45eda..0ca79d34c 100644 --- a/lib/jazzy/sourcekitten.rb +++ b/lib/jazzy/sourcekitten.rb @@ -355,7 +355,9 @@ def self.should_document_swift_extension?(doc) # Call things undocumented if they were compiled properly # and came from our module. def self.should_mark_undocumented(declaration) - declaration.usr && !declaration.modulename + declaration.usr && + (declaration.modulename.nil? || + declaration.modulename == Config.instance.module_name) end def self.process_undocumented_token(doc, declaration)