Skip to content

Commit

Permalink
Work around Swift 5.6 modulename change (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfairh committed Nov 8, 2021
1 parent 7e80a36 commit 7728656
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions lib/jazzy/source_declaration.rb
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/jazzy/sourcekitten.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 7728656

Please sign in to comment.