Skip to content

Commit 3bb0862

Browse files
committed
draft implementation of product vertices + product pages
1 parent 04fa09c commit 3bb0862

File tree

64 files changed

+535
-177
lines changed

Some content is hidden

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

64 files changed

+535
-177
lines changed

Sources/SwiftinitPages/CanonicalVersion.Target.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extension CanonicalVersion
88
case article(URI?)
99
case culture(URI?)
1010
case decl(URI?)
11+
case product(URI?)
1112
case foreign(URI?)
1213
case global
1314
}
@@ -21,6 +22,7 @@ extension CanonicalVersion.Target
2122
case .article: "An"
2223
case .culture: "A"
2324
case .decl: "A"
25+
case .product: "A"
2426
case .foreign: "An"
2527
case .global: "A"
2628
}
@@ -32,6 +34,7 @@ extension CanonicalVersion.Target
3234
case .article: "article"
3335
case .culture: "module"
3436
case .decl: "symbol"
37+
case .product: "package product"
3538
case .foreign: "extension overlay"
3639
case .global: "package"
3740
}
@@ -43,6 +46,7 @@ extension CanonicalVersion.Target
4346
case .article: "name"
4447
case .culture: "name"
4548
case .decl: "signature"
49+
case .product: "name"
4650
case .foreign: "base declaration"
4751
case .global: "identity"
4852
}
@@ -55,6 +59,7 @@ extension CanonicalVersion.Target
5559
case .article(let uri): uri
5660
case .culture(let uri): uri
5761
case .decl(let uri): uri
62+
case .product(let uri): uri
5863
case .foreign(let uri): uri
5964
case .global: nil
6065
}

Sources/SwiftinitPages/CanonicalVersion.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ extension CanonicalVersion
7373
case .file:
7474
return nil
7575

76+
case .product(let vertex):
77+
target = .product(Swiftinit.Docs[volumeOfLatest, vertex.shoot])
78+
7679
case .foreign(let vertex):
7780
target = .foreign(Swiftinit.Docs[volumeOfLatest, vertex.shoot])
7881

@@ -88,6 +91,7 @@ extension CanonicalVersion
8891
case .culture?: target = .culture(nil)
8992
case .decl?: target = .decl(nil)
9093
case .file?, nil: return nil
94+
case .product?: target = .product(nil)
9195
case .foreign?: target = .foreign(nil)
9296
case .global?: target = .global
9397
}
@@ -109,6 +113,7 @@ extension CanonicalVersion
109113
case .article(let uri): uri
110114
case .culture(let uri): uri
111115
case .decl(let uri): uri
116+
case .product(let uri): uri
112117
case .foreign(let uri): uri
113118
case .global: self.volume
114119
}

Sources/SwiftinitPages/Contexts/IdentifiablePageContext.Cache.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension IdentifiablePageContext.Cache where ID:VersionedPageIdentifier
3232
return target
3333
}
3434
else if
35-
let volume:Unidoc.VolumeMetadata = self.volumes[scalar.zone],
35+
let volume:Unidoc.VolumeMetadata = self.volumes[scalar.edition],
3636
let uri:URI = uri(volume)
3737
{
3838
let target:String = "\(uri)"
@@ -110,6 +110,7 @@ extension IdentifiablePageContext.Cache where ID:VersionedPageIdentifier
110110
case .culture(let vertex): Swiftinit.Docs[$0, vertex.shoot]
111111
case .decl(let vertex): Swiftinit.Docs[$0, vertex.shoot]
112112
case .file: nil
113+
case .product(let vertex): Swiftinit.Docs[$0, vertex.shoot]
113114
case .foreign(let vertex): Swiftinit.Docs[$0, vertex.shoot]
114115
case .global: Swiftinit.Docs[$0]
115116
}

Sources/SwiftinitPages/Contexts/IdentifiablePageContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ extension IdentifiablePageContext where ID:VersionedPageIdentifier
166166
func link(file:Unidoc.Scalar, line:Int? = nil) -> Swiftinit.SourceLink?
167167
{
168168
if let origin:Unidoc.PackageMetadata.Repo.Origin = self.repo?.origin,
169-
let refname:String = self.volumes[file.zone]?.refname,
169+
let refname:String = self.volumes[file.edition]?.refname,
170170
let file:Unidoc.Vertex.File = self.vertices[file]?.file,
171171
let blob:String = origin.blob(refname: refname, file: file.symbol)
172172
{

Sources/SwiftinitPages/Sections/AutomaticHeading.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ enum AutomaticHeading
88
case packageDependencies
99
case platformRequirements
1010
case snapshotInformation
11+
case allProducts
1112
case allModules
1213

1314
case miscellaneous
15+
case otherProducts
1416
case otherModules
1517
case otherMembers
1618

@@ -40,9 +42,11 @@ extension AutomaticHeading:Identifiable
4042
case .packageDependencies: "ss:package-dependencies"
4143
case .platformRequirements: "ss:platform-requirements"
4244
case .snapshotInformation: "ss:snapshot-information"
45+
case .allProducts: "ss:all-products"
4346
case .allModules: "ss:all-modules"
4447

4548
case .miscellaneous: "ss:misc"
49+
case .otherProducts: "ss:other-products"
4650
case .otherModules: "ss:other-modules"
4751
case .otherMembers: "ss:other-members"
4852

@@ -73,9 +77,11 @@ extension AutomaticHeading:CustomStringConvertible
7377
case .packageDependencies: "Package Dependencies"
7478
case .platformRequirements: "Platform Requirements"
7579
case .snapshotInformation: "Snapshot Information"
80+
case .allProducts: "Products"
7681
case .allModules: "Modules"
7782

7883
case .miscellaneous: "Miscellaneous"
84+
case .otherProducts: "Other Products"
7985
case .otherModules: "Other Modules"
8086
case .otherMembers: "Other Members in Extension"
8187

Sources/SwiftinitPages/Sections/GroupList.Card.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ extension GroupList.Card:HyperTextOutputStreamable
6464
$0 ?= self.overview
6565
}
6666

67+
case .product(let vertex):
68+
html[.li, { $0.class = "product" }]
69+
{
70+
$0[link: self.target] = vertex.symbol
71+
72+
// Should always be nil right now, but eventually we want to support this.
73+
$0 ?= self.overview
74+
}
75+
6776
case .file, .foreign, .global:
6877
// unimplemented
6978
break

Sources/SwiftinitPages/Sections/GroupSections.swift

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ extension GroupSections
6161
bias:Unidoc.Scalar? = nil,
6262
mode:Mode? = nil)
6363
{
64-
let container:Unidoc.Scalar?
64+
let container:Unidoc.Group.ID?
6565
let generics:Generics
6666
if let vertex:Unidoc.Vertex.Decl = copy vertex
6767
{
@@ -100,7 +100,7 @@ extension GroupSections
100100
continue
101101
}
102102

103-
let partisanship:Partisanship = self.context.volumes.secondary[group.id.zone]
103+
let partisanship:Partisanship = self.context.volumes.secondary[group.id.edition]
104104
.map
105105
{
106106
.third($0.symbol.package)
@@ -113,9 +113,7 @@ extension GroupSections
113113

114114
extensions.append((group, partisanship, genericness))
115115

116-
case .automatic(let group):
117-
// Guess what kind of autogroup this is by looking at the bit pattern of
118-
// the first member of the group.
116+
case .polygon(let group):
119117
guard
120118
let first:Unidoc.Scalar = group.members.first,
121119
let plane:SymbolGraph.Plane = .of(first.citizen)
@@ -127,17 +125,20 @@ extension GroupSections
127125
if first == self.context.id,
128126
group.members.count == 1
129127
{
130-
// This is an automatic group that contains this page only.
128+
// This is a polygon that contains this page only.
131129
continue
132130
}
133131

132+
// Guess what kind of polygon this is by looking at the bit pattern of its
133+
// first vertex.
134134
let heading:AutomaticHeading
135-
136135
switch (plane, self.mode)
137136
{
137+
case (.product, .meta): heading = .allProducts
138+
case (.product, _): heading = .otherProducts
138139
case (.module, .meta): heading = .allModules
139140
case (.module, _): heading = .otherModules
140-
case (_, _): heading = .miscellaneous
141+
default: heading = .miscellaneous
141142
}
142143

143144
self.other.append((heading, group.members))
@@ -181,11 +182,11 @@ extension GroupSections
181182
func heading(for extension:Unidoc.Group.Extension) -> ExtensionHeading
182183
{
183184
let display:String
184-
switch (self.bias, self.bias?.zone)
185+
switch (self.bias, self.bias?.edition)
185186
{
186-
case (`extension`.culture?, _): display = "Citizens in "
187-
case (_, `extension`.id.zone?): display = "Available in "
188-
case (_, _): display = "Extension in "
187+
case (`extension`.culture?, _): display = "Citizens in "
188+
case (_, `extension`.id.edition?): display = "Available in "
189+
case (_, _): display = "Extension in "
189190
}
190191

191192
return .init(self.context,

Sources/SwiftinitPages/Surfaces/Vertices/Swiftinit.Docs (ext).swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ extension Swiftinit.Docs:Swiftinit.VolumeRoot
6464
case .file:
6565
throw Unidoc.VertexTypeError.file
6666

67+
case .product(let vertex):
68+
let groups:GroupSections = .init(context.page,
69+
organizing: consume groups,
70+
bias: vertex.id,
71+
mode: nil)
72+
let page:Product = .init(context.page,
73+
canonical: context.canonical,
74+
vertex: vertex,
75+
groups: groups)
76+
resource = page.resource(format: context.format)
77+
6778
case .foreign(let vertex):
6879
let groups:GroupSections = .init(context.page,
6980
organizing: consume groups,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extension Swiftinit.Docs.Foreign:Swiftinit.ApplicationPage
6565
}
6666
extension Swiftinit.Docs.Foreign:Swiftinit.VersionedPage
6767
{
68-
var sidebar:Swiftinit.Sidebar<Swiftinit.Docs>? { .package(volume: self.context.volume) }
68+
var sidebar:Swiftinit.Sidebar<Swiftinit.Docs>? { .package(volume: self.volume) }
6969

7070
func main(_ main:inout HTML.ContentEncoder, format:Swiftinit.RenderFormat)
7171
{
@@ -84,7 +84,7 @@ extension Swiftinit.Docs.Foreign:Swiftinit.VersionedPage
8484
}
8585

8686
let extendee:HTML.Link<String>? = self.context.link(decl: self.vertex.extendee)
87-
if let other:Unidoc.VolumeMetadata = self.context.volumes[self.vertex.extendee.zone]
87+
if let other:Unidoc.VolumeMetadata = self.context.volumes[self.vertex.extendee.edition]
8888
{
8989
main[.section, { $0.class = "notice extendee" }]
9090
{
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import HTML
2+
import SwiftinitRender
3+
import UnidocRecords
4+
import URI
5+
6+
extension Swiftinit.Docs
7+
{
8+
struct Product
9+
{
10+
let context:IdentifiablePageContext<Unidoc.Scalar>
11+
12+
let canonical:CanonicalVersion?
13+
14+
private
15+
let vertex:Unidoc.Vertex.Product
16+
private
17+
let groups:GroupSections
18+
19+
init(_ context:IdentifiablePageContext<Unidoc.Scalar>,
20+
canonical:CanonicalVersion?,
21+
vertex:Unidoc.Vertex.Product,
22+
groups:GroupSections)
23+
{
24+
self.context = context
25+
self.canonical = canonical
26+
self.vertex = vertex
27+
self.groups = groups
28+
}
29+
}
30+
}
31+
extension Swiftinit.Docs.Product:Swiftinit.RenderablePage
32+
{
33+
var title:String { "\(self.vertex.symbol) · \(self.volume.title) Products" }
34+
35+
var description:String?
36+
{
37+
"""
38+
\(self.vertex.symbol) is a product available in the package \(self.volume.title)").
39+
"""
40+
}
41+
}
42+
extension Swiftinit.Docs.Product:Swiftinit.StaticPage
43+
{
44+
var location:URI { Swiftinit.Docs[self.volume, self.vertex.shoot] }
45+
}
46+
extension Swiftinit.Docs.Product:Swiftinit.ApplicationPage
47+
{
48+
typealias Navigator = HTML.Logo
49+
}
50+
extension Swiftinit.Docs.Product:Swiftinit.VersionedPage
51+
{
52+
var sidebar:Swiftinit.Sidebar<Swiftinit.Docs>? { .package(volume: self.volume) }
53+
54+
func main(_ main:inout HTML.ContentEncoder, format:Swiftinit.RenderFormat)
55+
{
56+
// TODO: unimplemented
57+
}
58+
}

0 commit comments

Comments
 (0)