Skip to content

Commit b01ef2b

Browse files
committed
finish replacing Unidoc.PackageMetadata.Repo with Unidoc.PackageRepo
1 parent 2fbbd90 commit b01ef2b

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

Sources/SwiftinitPages/Contexts/IdentifiablePageContext.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class IdentifiablePageContext<ID> where ID:Hashable
1818
private
1919
var cache:Cache
2020

21-
let repo:Unidoc.PackageMetadata.Repo?
21+
let repo:Unidoc.PackageRepo?
2222

2323
private
24-
init(cache:Cache, repo:Unidoc.PackageMetadata.Repo?)
24+
init(cache:Cache, repo:Unidoc.PackageRepo?)
2525
{
2626
self.outlines = []
2727
self.cache = cache
@@ -49,7 +49,7 @@ extension IdentifiablePageContext
4949
extension IdentifiablePageContext<Unidoc.Scalar>
5050
{
5151
convenience
52-
init(principal scalar:Unidoc.Scalar, volume:Unidoc.VolumeMetadata, repo:Unidoc.PackageMetadata.Repo?)
52+
init(principal scalar:Unidoc.Scalar, volume:Unidoc.VolumeMetadata, repo:Unidoc.PackageRepo?)
5353
{
5454
self.init(cache: .init(
5555
vertices: .init(principal: scalar),
@@ -60,7 +60,7 @@ extension IdentifiablePageContext<Unidoc.Scalar>
6060
extension IdentifiablePageContext<Never?>
6161
{
6262
convenience
63-
init(principal volume:Unidoc.VolumeMetadata, repo:Unidoc.PackageMetadata.Repo?)
63+
init(principal volume:Unidoc.VolumeMetadata, repo:Unidoc.PackageRepo?)
6464
{
6565
self.init(cache: .init(
6666
vertices: .init(principal: nil),
@@ -165,19 +165,19 @@ extension IdentifiablePageContext where ID:VersionedPageIdentifier
165165
}
166166
func link(file:Unidoc.Scalar, line:Int? = nil) -> Swiftinit.SourceLink?
167167
{
168-
if let origin:Unidoc.PackageMetadata.Repo.Origin = self.repo?.origin,
168+
if let origin:Unidoc.PackageRepo.AnyOrigin = self.repo?.origin,
169169
let refname:String = self.volumes[file.edition]?.refname,
170-
let file:Unidoc.Vertex.File = self.vertices[file]?.file,
171-
let blob:String = origin.blob(refname: refname, file: file.symbol)
170+
let file:Unidoc.Vertex.File = self.vertices[file]?.file
172171
{
173-
.init(
172+
let blob:String = origin.blob(refname: refname, file: file.symbol)
173+
return .init(
174174
file: file.symbol.last,
175175
line: line,
176176
target: line.map { "\(blob)#L\($0 + 1)" } ?? blob)
177177
}
178178
else
179179
{
180-
nil
180+
return nil
181181
}
182182
}
183183
}

Sources/SwiftinitPages/Surfaces/Vertices/Swiftinit.Docs.PackagePage.swift

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extension Swiftinit.Docs
4040
extension Swiftinit.Docs.PackagePage
4141
{
4242
private
43-
var repo:Unidoc.PackageMetadata.Repo? { self.context.repo }
43+
var repo:Unidoc.PackageRepo? { self.context.repo }
4444
}
4545
extension Swiftinit.Docs.PackagePage:Swiftinit.RenderablePage
4646
{
@@ -103,46 +103,44 @@ extension Swiftinit.Docs.PackagePage:Swiftinit.VersionedPage
103103

104104
$0[.h1] = self.title
105105

106-
switch self.repo
106+
switch self.repo?.origin
107107
{
108-
case .github(let repo)?:
109-
$0[.p] = repo.about
108+
case .github(let origin)?:
109+
$0[.p] = origin.about
110110

111-
case nil:
112-
break
113-
}
114-
if let refname:String = self.volume.refname
115-
{
116-
switch self.repo?.origin
111+
guard
112+
let refname:String = self.volume.refname
113+
else
117114
{
118-
case .github(let path)?:
119-
$0 += Swiftinit.SourceLink.init(file: path.dropFirst(),
120-
target: "https://github.com\(path)/tree/\(refname)")
121-
122-
case nil:
123115
break
124116
}
117+
118+
$0 += Swiftinit.SourceLink.init(file: "\(origin.owner)/\(origin.name)",
119+
target: "\(origin.https)/tree/\(refname)")
120+
121+
case nil:
122+
break
125123
}
126124
}
127125

128126
main[.section] { $0.class = "notice canonical" } = self.canonical
129127

130128
main[.section, { $0.class = "details" }]
131129
{
132-
if let repo:Unidoc.PackageMetadata.Repo = self.repo
130+
if let repo:Unidoc.PackageRepo = self.repo
133131
{
134132
let heading:AutomaticHeading = .packageRepository
135133
$0[.h2] { $0.id = heading.id } = heading
136134

137135
$0[.dl]
138136
{
139-
switch repo
137+
switch repo.origin
140138
{
141-
case .github(let repo):
139+
case .github(let origin):
142140
$0[.dt] = "Provider"
143141
$0[.dd] = "GitHub"
144142

145-
if let license:GitHub.Repo.License = repo.license
143+
if let license:Unidoc.PackageLicense = repo.license
146144
{
147145
$0[.dt] = "License"
148146
$0[.dd] = license.name
@@ -155,10 +153,10 @@ extension Swiftinit.Docs.PackagePage:Swiftinit.VersionedPage
155153
}
156154

157155
// If the repo belongs to a person, show the owner.
158-
if repo.owner.login != "apple"
156+
if origin.owner != "apple"
159157
{
160158
$0[.dt] = "Owner"
161-
$0[.dd] = repo.owner
159+
$0[.dd] = origin.owner
162160
}
163161
}
164162
}

Sources/UnidocQueries/Volumes/Unidoc.PrincipalOutput.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@ extension Unidoc
1212
struct PrincipalOutput:Equatable, Sendable
1313
{
1414
public
15-
let matches:[Unidoc.Vertex]
15+
let matches:[Vertex]
1616

1717
public
18-
let vertex:Unidoc.Vertex?
18+
let vertex:Vertex?
1919
public
20-
let vertexInLatest:Unidoc.Vertex?
20+
let vertexInLatest:Vertex?
2121

2222
public
23-
let groups:[Unidoc.Group]
23+
let groups:[Group]
2424

2525
public
26-
let volume:Unidoc.VolumeMetadata
26+
let volume:VolumeMetadata
2727
public
28-
let volumeOfLatest:Unidoc.VolumeMetadata?
28+
let volumeOfLatest:VolumeMetadata?
2929

3030
public
31-
let repo:PackageMetadata.Repo?
31+
let repo:PackageRepo?
3232

3333
public
34-
let tree:Unidoc.TypeTree?
34+
let tree:TypeTree?
3535

3636
@inlinable internal
3737
init(
38-
matches:[Unidoc.Vertex],
39-
vertex:Unidoc.Vertex?,
40-
vertexInLatest:Unidoc.Vertex?,
41-
groups:[Unidoc.Group],
42-
volume:Unidoc.VolumeMetadata,
43-
volumeOfLatest:Unidoc.VolumeMetadata?,
44-
repo:PackageMetadata.Repo?,
45-
tree:Unidoc.TypeTree?)
38+
matches:[Vertex],
39+
vertex:Vertex?,
40+
vertexInLatest:Vertex?,
41+
groups:[Group],
42+
volume:VolumeMetadata,
43+
volumeOfLatest:VolumeMetadata?,
44+
repo:PackageRepo?,
45+
tree:TypeTree?)
4646
{
4747
self.matches = matches
4848

0 commit comments

Comments
 (0)