Skip to content

Commit bc0c76f

Browse files
authored
Merge pull request #19 from tayloraswift/tag-api
Merge PackageDB into UnidocDB
2 parents 875408d + 02f88fb commit bc0c76f

File tree

80 files changed

+814
-896
lines changed

Some content is hidden

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

80 files changed

+814
-896
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div align="center">
22

3-
<strong><em><code>unidoc</code></em></strong><br><small><code>0.2.4</code></small>
3+
<strong><em><code>unidoc</code></em></strong><br><small><code>0.2.5</code></small>
44

55
[![ci build status](https://github.com/kelvin13/swift-unidoc/actions/workflows/build.yml/badge.svg)](https://github.com/kelvin13/swift-unidoc/actions/workflows/build.yml)
66

Sources/UnidocAnalysis/Volume (ext).swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ extension Volume
1010
func siteMap() -> SiteMap<PackageIdentifier>
1111
{
1212
var lines:[UInt8] = []
13-
for master:Volume.Master in self.vertices
13+
for vertex:Vertex in self.vertices
1414
{
15-
switch master
15+
switch vertex
1616
{
17-
case .culture(let master):
18-
master.shoot.serialize(into: &lines) ; lines.append(0x0A)
17+
case .culture(let vertex):
18+
vertex.shoot.serialize(into: &lines) ; lines.append(0x0A)
1919

20-
case .article(let master):
21-
master.shoot.serialize(into: &lines) ; lines.append(0x0A)
20+
case .article(let vertex):
21+
vertex.shoot.serialize(into: &lines) ; lines.append(0x0A)
2222

23-
case .decl(let master):
24-
master.shoot.serialize(into: &lines) ; lines.append(0x0A)
23+
case .decl(let vertex):
24+
vertex.shoot.serialize(into: &lines) ; lines.append(0x0A)
2525

2626
case .file, .meta:
2727
continue
@@ -37,27 +37,27 @@ extension Volume
3737
var procs:[Unidoc.Scalar: [Shoot]] = [:]
3838
var types:Types = .init()
3939

40-
for master:Master in self.vertices
40+
for vertex:Vertex in self.vertices
4141
{
42-
switch master
42+
switch vertex
4343
{
44-
case .culture(let master):
45-
modules[master.id] = master.module.id
44+
case .culture(let vertex):
45+
modules[vertex.id] = vertex.module.id
4646

47-
case .article(let master):
48-
types[master.culture, master.id] = .init(shoot: master.shoot)
47+
case .article(let vertex):
48+
types[vertex.culture, vertex.id] = .init(shoot: vertex.shoot)
4949

50-
case .decl(let master):
51-
switch master.phylum
50+
case .decl(let vertex):
51+
switch vertex.phylum
5252
{
5353
case .actor, .class, .struct, .enum, .protocol, .macro(.attached):
54-
types[master.culture, master.id] = .init(
55-
shoot: master.shoot,
56-
scope: master.scope.last)
54+
types[vertex.culture, vertex.id] = .init(
55+
shoot: vertex.shoot,
56+
scope: vertex.scope.last)
5757

5858
case .func(nil), .var(nil), .macro(.freestanding):
5959
// Global procedures show up in search, but not in the type tree.
60-
procs[master.culture, default: []].append(master.shoot)
60+
procs[vertex.culture, default: []].append(vertex.shoot)
6161

6262
case _:
6363
continue
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import MongoDB
2+
3+
public
4+
protocol DatabaseCollation
5+
{
6+
static
7+
var spec:Mongo.Collation { get }
8+
}

Sources/UnidocDB/DatabaseCollection.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ extension DatabaseCollection
6363

6464
print("note: recreated \(response.indexesAfter - 1) indexes in \(Self.name)")
6565
}
66+
67+
/// Drops the collection and reinitializes it by calling ``setup(with:)``.
68+
func replace(with session:Mongo.Session) async throws
69+
{
70+
try await session.run(
71+
command: Mongo.Drop.init(Self.name),
72+
against: self.database)
73+
try await self.setup(with: session)
74+
}
6675
}
6776
extension DatabaseCollection
6877
{
@@ -380,14 +389,3 @@ extension DatabaseCollection<Unidoc.Scalar>
380389
let _:Mongo.Deletions = try response.deletions()
381390
}
382391
}
383-
extension DatabaseCollection
384-
{
385-
/// Drops the collection and reinitializes it by calling ``setup(with:)``.
386-
func replace(with session:Mongo.Session) async throws
387-
{
388-
try await session.run(
389-
command: Mongo.Drop.init(Self.name),
390-
against: self.database)
391-
try await self.setup(with: session)
392-
}
393-
}

Sources/UnidocDB/DatabaseModel.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,11 @@ import MongoQL
44
public
55
protocol DatabaseModel:Identifiable<Mongo.Database>, Equatable, Sendable
66
{
7-
static
8-
var collation:Mongo.Collation { get }
9-
107
init(id:Mongo.Database)
118

129
func setup(with session:Mongo.Session) async throws
1310
}
1411
extension DatabaseModel
15-
{
16-
@inlinable public static
17-
var collation:Mongo.Collation
18-
{
19-
.init(locale: "simple", normalization: true) // normalize unicode on insert
20-
}
21-
}
22-
extension DatabaseModel
2312
{
2413
public static
2514
func setup(as id:Mongo.Database, in pool:__owned Mongo.SessionPool) async -> Self

Sources/UnidocDB/DatabaseQuery.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import BSONDecoding
22
import MongoDB
33

44
public
5-
protocol DatabaseQuery<Database, Output>:Sendable
5+
protocol DatabaseQuery<Collation, Output>:Sendable
66
{
7-
associatedtype Database:DatabaseModel
7+
associatedtype Collation:DatabaseCollation
88
associatedtype Output:BSONDocumentDecodable
99

1010
func build(pipeline:inout Mongo.Pipeline)
@@ -19,7 +19,7 @@ extension DatabaseQuery
1919
{
2020
.init(self.origin, pipeline: .init(with: self.build(pipeline:)))
2121
{
22-
$0[.collation] = Database.collation
22+
$0[.collation] = Collation.spec
2323
$0[.hint] = self.hint
2424
}
2525
}

Sources/UnidocDB/Packages/PackageDatabase.swift

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

0 commit comments

Comments
 (0)