Skip to content

Commit

Permalink
Updates for building docs with Swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfairh committed Jun 22, 2024
1 parent bb87b03 commit 4f3203b
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
submodules: recursive
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 15.3
xcode-version: '16.0-beta'
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

##### Enhancements

* None.
* Support Swift 6.0 / Xcode 16.0
[John Fairhurst](https://github.com/johnfairh)

##### Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ git push
You'll need push access to the integration specs repo to do this. You can
request access from one of the maintainers when filing your PR.

You must have Xcode 15.3 installed to build the integration specs.
You must have Xcode 16.0 installed to build the integration specs.

## Making changes to SourceKitten

Expand Down
2 changes: 1 addition & 1 deletion lib/jazzy/podspec_documenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def self.github_file_prefix(podspec)
private_class_method :github_file_prefix

# Latest valid value for SWIFT_VERSION.
LATEST_SWIFT_VERSION = '5'
LATEST_SWIFT_VERSION = '6'

# All valid values for SWIFT_VERSION that are longer
# than a major version number. Ordered ascending.
Expand Down
9 changes: 9 additions & 0 deletions lib/jazzy/sourcekitten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,19 @@ def self.make_swift_declaration(doc, declaration)
# @available attrs only in compiler 'interface' style
extract_availability(doc['key.doc.declaration'] || '')
.concat(extract_documented_attributes(annotated_decl_attrs))
.concat(fabricate_spi_attributes(doc, annotated_decl_attrs))
.push(decl)
.join("\n")
end

# Swift 6 workaround: @_spi attribute & SPI group missing
def self.fabricate_spi_attributes(doc, attrs)
return [] unless spi_attribute?(doc)
return [] if attrs =~ /@_spi/

['@_spi(<<unknown>>)']
end

# Exclude non-async routines that accept async closures
def self.swift_async?(fully_annotated_decl)
document = REXML::Document.new(fully_annotated_decl)
Expand Down
18 changes: 11 additions & 7 deletions lib/jazzy/symbol_graph/ext_node.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'set'

module Jazzy
module SymbolGraph
# For extensions we need to track constraints of the extended type
Expand All @@ -26,7 +28,7 @@ class ExtNode < BaseNode
attr_accessor :real_usr
attr_accessor :name
attr_accessor :all_constraints # ExtConstraints
attr_accessor :conformances # array, can be empty
attr_accessor :conformances # set, can be empty

# Deduce an extension from a member of an unknown type or
# of known type with additional constraints
Expand Down Expand Up @@ -54,7 +56,7 @@ def initialize(usr, name, constraints)
self.usr = usr
self.name = name
self.all_constraints = constraints
self.conformances = []
self.conformances = Set.new
super()
end

Expand All @@ -65,13 +67,13 @@ def constraints
end

def add_conformance(protocol)
conformances.append(protocol).sort!
conformances.add(protocol)
end

def full_declaration
decl = "extension #{name}"
unless conformances.empty?
decl += " : #{conformances.join(', ')}"
decl += " : #{conformances.sort.join(', ')}"
end
decl + all_constraints.ext.to_where_clause
end
Expand All @@ -90,7 +92,7 @@ def to_sourcekit(module_name, ext_module_name)
}

unless conformances.empty?
hash['key.inheritedtypes'] = conformances.map do |conformance|
hash['key.inheritedtypes'] = conformances.sort.map do |conformance|
{ 'key.name' => conformance }
end
end
Expand All @@ -100,11 +102,13 @@ def to_sourcekit(module_name, ext_module_name)
hash
end

# Sort order - by type name then constraint
# Sort order - by type name then constraint then conformances
# Conformance check needed for stable order with Swift 5.9
# extension symbols that can't merge as well as previously.
include Comparable

def sort_key
name + constraints.map(&:to_swift).join
name + constraints.map(&:to_swift).join + conformances.sort.join
end

def <=>(other)
Expand Down
2 changes: 1 addition & 1 deletion lib/jazzy/symbol_graph/relationship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def extension_to?
# Protocol conformances added by compiler to actor decls that
# users aren't interested in.
def actor_protocol?
%w[Actor Sendable].include?(target_fallback)
%w[Actor AnyActor Sendable].include?(target_fallback)
end

def initialize(hash)
Expand Down
3 changes: 2 additions & 1 deletion spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def configure_cocoapods
behaves_like cli_spec 'misc_jazzy_symgraph_features',
'--swift-build-tool symbolgraph ' \
'--build-tool-arguments ' \
"-emit-extension-block-symbols,-I,#{module_path}"
'-emit-extension-block-symbols,-I,' \
"#{module_path.chomp}/Modules"
end

describe 'Creates docs for a multiple-module project' do
Expand Down
2 changes: 1 addition & 1 deletion spec/integration_specs
Submodule integration_specs updated 227 files

0 comments on commit 4f3203b

Please sign in to comment.