Skip to content

Commit 4630bed

Browse files
committed
improve handling of protocols that have conforming types that reference the protocol itself
1 parent 1e20647 commit 4630bed

File tree

56 files changed

+786
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+786
-408
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/SwiftinitPages/CanonicalVersion.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct CanonicalVersion
2929
}
3030
extension CanonicalVersion
3131
{
32-
init?(principal:Unidoc.PrincipalOutput)
32+
init?(principal:Unidoc.PrincipalOutput, layer:(some Swiftinit.VertexLayer).Type)
3333
{
3434
guard
3535
let volumeOfLatest:Unidoc.VolumeMetadata = principal.volumeOfLatest,
@@ -62,22 +62,22 @@ extension CanonicalVersion
6262
switch vertex
6363
{
6464
case .article(let vertex):
65-
target = .article(Swiftinit.Docs[volumeOfLatest, vertex.route])
65+
target = .article(layer[volumeOfLatest, vertex.route])
6666

6767
case .culture(let vertex):
68-
target = .culture(Swiftinit.Docs[volumeOfLatest, vertex.route])
68+
target = .culture(layer[volumeOfLatest, vertex.route])
6969

7070
case .decl(let vertex):
71-
target = .decl(Swiftinit.Docs[volumeOfLatest, vertex.route])
71+
target = .decl(layer[volumeOfLatest, vertex.route])
7272

7373
case .file:
7474
return nil
7575

7676
case .product(let vertex):
77-
target = .product(Swiftinit.Docs[volumeOfLatest, vertex.route])
77+
target = .product(layer[volumeOfLatest, vertex.route])
7878

7979
case .foreign(let vertex):
80-
target = .foreign(Swiftinit.Docs[volumeOfLatest, vertex.route])
80+
target = .foreign(layer[volumeOfLatest, vertex.route])
8181

8282
case .global:
8383
target = .global
@@ -99,7 +99,7 @@ extension CanonicalVersion
9999

100100
self.init(relationship: relationship,
101101
package: volumeOfLatest.title,
102-
volume: Swiftinit.Docs[volumeOfLatest],
102+
volume: Swiftinit.Docs[volumeOfLatest], // this does *not* use `layer`!
103103
target: target)
104104
}
105105
}

Sources/SwiftinitPages/Contexts/IdentifiablePageContext.Cache.swift

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ extension IdentifiablePageContext
88
struct Cache
99
{
1010
var vertices:Vertices
11-
var volumes:Volumes
11+
var volumes:Swiftinit.Volumes
1212

1313
private
1414
var uris:[Unidoc.Scalar: String]
1515

16-
init(vertices:Vertices, volumes:Volumes, uris:[Unidoc.Scalar: String] = [:])
16+
init(vertices:Vertices, volumes:Swiftinit.Volumes, uris:[Unidoc.Scalar: String] = [:])
1717
{
1818
self.vertices = vertices
1919
self.volumes = volumes
2020
self.uris = uris
2121
}
2222
}
2323
}
24-
extension IdentifiablePageContext.Cache where ID:Swiftinit.VertexPageIdentifier
24+
extension IdentifiablePageContext.Cache
2525
{
2626
mutating
2727
func load(_ scalar:Unidoc.Scalar, by uri:(Unidoc.VolumeMetadata) -> URI?) -> String?
@@ -46,18 +46,19 @@ extension IdentifiablePageContext.Cache where ID:Swiftinit.VertexPageIdentifier
4646
} (&self.uris[scalar])
4747
}
4848
}
49-
extension IdentifiablePageContext.Cache where ID:Swiftinit.VertexPageIdentifier
49+
extension IdentifiablePageContext.Cache
5050
{
5151
subscript(culture scalar:Unidoc.Scalar) -> (vertex:Unidoc.CultureVertex, url:String?)?
5252
{
5353
mutating get
5454
{
55-
if case .culture(let vertex)? = self.vertices[scalar]
55+
switch self.vertices[scalar]
5656
{
57+
case (.culture(let vertex), principal: true)?:
58+
(vertex, nil)
59+
case (.culture(let vertex), principal: false)?:
5760
(vertex, self.load(scalar) { Swiftinit.Docs[$0, vertex.route] })
58-
}
59-
else
60-
{
61+
default:
6162
nil
6263
}
6364
}
@@ -67,12 +68,13 @@ extension IdentifiablePageContext.Cache where ID:Swiftinit.VertexPageIdentifier
6768
{
6869
mutating get
6970
{
70-
if case .article(let vertex)? = self.vertices[scalar]
71+
switch self.vertices[scalar]
7172
{
73+
case (.article(let vertex), principal: true)?:
74+
(vertex, nil)
75+
case (.article(let vertex), principal: false)?:
7276
(vertex, self.load(scalar) { Swiftinit.Docs[$0, vertex.route] })
73-
}
74-
else
75-
{
77+
default:
7678
nil
7779
}
7880
}
@@ -82,12 +84,13 @@ extension IdentifiablePageContext.Cache where ID:Swiftinit.VertexPageIdentifier
8284
{
8385
mutating get
8486
{
85-
if case .decl(let vertex)? = self.vertices[scalar]
87+
switch self.vertices[scalar]
8688
{
89+
case (.decl(let vertex), principal: true)?:
90+
(vertex, nil)
91+
case (.decl(let vertex), principal: false)?:
8792
(vertex, self.load(scalar) { Swiftinit.Docs[$0, vertex.route] })
88-
}
89-
else
90-
{
93+
default:
9194
nil
9295
}
9396
}
@@ -100,23 +103,28 @@ extension IdentifiablePageContext.Cache where ID:Swiftinit.VertexPageIdentifier
100103
{
101104
self.vertices[scalar].map
102105
{
103-
(vertex:Unidoc.AnyVertex) in
104-
105-
let url:String? = self.load(scalar)
106+
switch $0
106107
{
107-
switch vertex
108+
case (let vertex, principal: false):
109+
let url:String? = self.load(scalar)
108110
{
109-
case .article(let vertex): Swiftinit.Docs[$0, vertex.route]
110-
case .culture(let vertex): Swiftinit.Docs[$0, vertex.route]
111-
case .decl(let vertex): Swiftinit.Docs[$0, vertex.route]
112-
case .file: nil
113-
case .product(let vertex): Swiftinit.Docs[$0, vertex.route]
114-
case .foreign(let vertex): Swiftinit.Docs[$0, vertex.route]
115-
case .global: Swiftinit.Docs[$0]
111+
switch vertex
112+
{
113+
case .article(let vertex): Swiftinit.Docs[$0, vertex.route]
114+
case .culture(let vertex): Swiftinit.Docs[$0, vertex.route]
115+
case .decl(let vertex): Swiftinit.Docs[$0, vertex.route]
116+
case .file: nil
117+
case .product(let vertex): Swiftinit.Docs[$0, vertex.route]
118+
case .foreign(let vertex): Swiftinit.Docs[$0, vertex.route]
119+
case .global: Swiftinit.Docs[$0]
120+
}
116121
}
117-
}
118122

119-
return (vertex, url)
123+
return (vertex, url)
124+
125+
case (let vertex, principal: true):
126+
return (vertex, nil)
127+
}
120128
}
121129
}
122130
}

Sources/SwiftinitPages/Contexts/IdentifiablePageContext.Vertices.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)