Skip to content

Commit 81932c9

Browse files
committed
implement a way to view tagless docs in the tags page
1 parent 72e785b commit 81932c9

22 files changed

+480
-345
lines changed

Assets/css/Main.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/css/Main.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/SwiftinitPages/Surfaces/Editions/Swiftinit.EditionsPage.Row.swift

Lines changed: 0 additions & 77 deletions
This file was deleted.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import HTML
2+
import SemanticVersions
3+
import SHA1
4+
import UnidocDB
5+
import UnidocQueries
6+
import UnidocRecords
7+
8+
extension Swiftinit.TagsPage
9+
{
10+
struct Row
11+
{
12+
let volume:Unidoc.VolumeMetadata?
13+
let graph:Unidoc.PackageQuery.Graph?
14+
let type:RowType
15+
16+
init(
17+
volume:Unidoc.VolumeMetadata?,
18+
graph:Unidoc.PackageQuery.Graph?,
19+
type:RowType)
20+
{
21+
self.volume = volume
22+
self.graph = graph
23+
self.type = type
24+
}
25+
}
26+
}
27+
extension Swiftinit.TagsPage.Row:HyperTextOutputStreamable
28+
{
29+
static
30+
func += (tr:inout HTML.ContentEncoder, self:Self)
31+
{
32+
let version:PatchVersion
33+
34+
switch self.type
35+
{
36+
case .tagged(let name, let commit, let docs, release: _):
37+
let sha1:String? = commit?.description
38+
tr[.td] { $0.class = "refname" } = name
39+
tr[.td]
40+
{
41+
$0.class = "commit"
42+
$0.title = sha1
43+
44+
} = sha1?.prefix(7) ?? ""
45+
46+
version = docs
47+
48+
case .tagless:
49+
tr[.td]
50+
tr[.td]
51+
52+
version = .v(0, 0, 0)
53+
}
54+
55+
tr[.td, { $0.class = "version" }]
56+
{
57+
if let volume:Unidoc.VolumeMetadata = self.volume
58+
{
59+
$0[.a] { $0.href = "\(Swiftinit.Docs[volume])" } = "\(version)"
60+
}
61+
else
62+
{
63+
$0[.span]
64+
{
65+
$0.title = "No documentation has been generated for this version."
66+
} = "\(version)"
67+
68+
return
69+
}
70+
71+
switch self.type
72+
{
73+
case .tagged(_, _, _, release: true):
74+
break
75+
76+
case .tagged(_, _, _, release: false):
77+
$0 += " "
78+
$0[.span]
79+
{
80+
$0.class = "parenthetical"
81+
$0.title = "This documentation is a prerelease version."
82+
} = "prerelease"
83+
84+
case .tagless:
85+
$0 += " "
86+
$0[.span]
87+
{
88+
$0.class = "parenthetical"
89+
$0.title = "This documentation is unversioned."
90+
} = "unversioned"
91+
}
92+
}
93+
tr[.td, { $0.class = "graph" }]
94+
{
95+
if let graph:Unidoc.PackageQuery.Graph = self.graph
96+
{
97+
$0[.span]
98+
{
99+
$0.class = graph.uplinking ? "abi uplinking" : "abi"
100+
$0.title = graph.uplinking ? """
101+
This symbol graph is currently queued for documentation generation.
102+
""" : nil
103+
} = "\(graph.abi)"
104+
105+
$0 += " "
106+
107+
$0[.span]
108+
{
109+
$0.class = "kb"
110+
$0.title = "\(graph.bytes) bytes"
111+
112+
} = "(\(graph.bytes >> 10) kb)"
113+
}
114+
else
115+
{
116+
$0[.span]
117+
{
118+
$0.title = "No symbol graph has been built for this version."
119+
}
120+
}
121+
}
122+
}
123+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import SHA1
2+
import SemanticVersions
3+
4+
extension Swiftinit.TagsPage
5+
{
6+
enum RowType
7+
{
8+
case tagged(String, SHA1?, PatchVersion, release:Bool)
9+
case tagless
10+
}
11+
}

0 commit comments

Comments
 (0)