Skip to content

Commit 9f38548

Browse files
committed
improve styling of terms lists, and add more tests for doclink resolution
1 parent fa01e4c commit 9f38548

File tree

14 files changed

+156
-88
lines changed

14 files changed

+156
-88
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/MarkdownParsing/Shims/Markdown.InlineElement (ext).swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ extension Markdown.InlineElement:ParsableAsInlineMarkup
6262
Markdown.InlineSpan.init(from: $0, in: source)
6363
}
6464
if let destination:String = link.destination,
65-
let colon:String.Index = destination.firstIndex(of: ":"),
66-
destination[..<colon] == "doc",
6765
elements.count == 1,
6866
elements[0] == .text(destination)
6967
{
7068
// exclude the angle brackets from the source range
7169
let link:Markdown.InlineAutolink = .doc(
72-
link: String.init(destination[destination.index(after: colon)...]),
70+
link: destination,
7371
at: .init(trimming: 1, from: link.range, in: copy source))
7472

7573
self = .autolink(link)

Sources/SwiftinitPages/Surfaces/Vertices/Swiftinit.Blog.ArticlePage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extension Swiftinit.Blog.ArticlePage:Swiftinit.StaticPage
6060
$0[.h1] = self.vertex.headline.safe
6161

6262
}
63-
$0[.section, { $0.class = "details" }]
63+
$0[.section, { $0.class = "details literature" }]
6464
{
6565
$0 ?= (self.vertex.overview?.markdown).map(self.context.prose(_:))
6666
$0 ?= (self.vertex.details?.markdown).map(self.context.prose(_:))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ extension Swiftinit.Docs.ArticlePage:Swiftinit.VertexPage
8282

8383
main[.section] { $0.class = "notice canonical" } = self.canonical
8484

85-
main[.section, { $0.class = "details" }] =
85+
main[.section, { $0.class = "details literature" }] =
8686
(self.vertex.details?.markdown).map(self.context.prose(_:))
8787

8888
main += self.groups

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ extension Swiftinit.Docs.DeclPage:Swiftinit.VertexPage
254254
}
255255
}
256256

257-
main[.section, { $0.class = "details" }]
257+
main[.section, { $0.class = "details literature" }]
258258
{
259259
if case .protocol = self.vertex.phylum
260260
{

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ extension Swiftinit.Docs.ModulePage:Swiftinit.VertexPage
172172
default:
173173
break
174174
}
175-
176-
$0 ?= (self.vertex.details?.markdown).map(self.context.prose(_:))
177175
}
178176

177+
main[.section, { $0.class = "details literature" }] =
178+
(self.vertex.details?.markdown).map(self.context.prose(_:))
179+
179180
main += self.groups
180181
}
181182
}

Sources/SymbolGraphLinker/Resolution/SSGC.Outliner.swift

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,43 @@ extension SSGC.Outliner
106106
return self.outline(link: link, code: true)
107107

108108
case .link(let link):
109-
if let colon:String.Index = link.string.firstIndex(of: ":"),
109+
guard
110+
let colon:String.Index = link.string.firstIndex(of: ":")
111+
else
112+
{
113+
return self.outline(link: link, code: false)
114+
}
115+
116+
switch link.string[..<colon]
117+
{
118+
case "doc":
119+
let trimmed:String = .init(link.string[link.string.index(after: colon)...])
120+
let link:Markdown.SourceString = .init(
121+
source: link.source,
122+
string: trimmed)
123+
124+
return self.outline(link: link, code: false)
125+
126+
case "http", "https":
127+
guard
110128
let start:String.Index = link.string.index(colon,
111129
offsetBy: 3,
112130
limitedBy: link.string.endIndex)
113-
{
114-
var url:Substring { link.string[start...] }
115-
116-
switch link.string[..<start]
131+
else
117132
{
118-
case "https://": return self.outline(translating: link, to: url)
119-
case "http://": return self.outline(translating: link, to: url)
120-
default: break
133+
break
121134
}
135+
136+
return self.outline(translating: link, to: link.string[start...])
137+
138+
default:
139+
break
122140
}
123141

124-
return self.outline(link: link, code: false)
142+
self.resolver.diagnostics[link.source] =
143+
InvalidAutolinkError<SSGC.Symbolicator>.init(link)
144+
145+
return nil
125146

126147
case .file(let link):
127148
name = link
@@ -303,7 +324,7 @@ extension SSGC.Outliner
303324

304325
for link:Markdown.InlineAutolink in topic.members
305326
{
306-
let _:Int? = self.outline(link: link.text, code: link.code)
327+
let _:Int? = self.outline(reference: .init(link))
307328
}
308329

309330
let members:[SymbolGraph.Outline] = self.cache.clear()

Sources/UnidocQueryTests/Tests/SymbolQueries.swift

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,33 @@ struct SymbolQueries:UnidocDatabaseTestBattery
228228
/// The type itself lives in ``BarbieHousing``, but it is namespaced to
229229
/// ``BarbieCore.Barbie``, and its codelinks should resolve relative to that
230230
/// namespace.
231-
if let tests:TestGroup = tests / "Barbie" / "Dreamhouse"
231+
for case (let tests?, let path, let expected) in
232+
[
233+
(
234+
tests / "Barbie" / "Dreamhouse",
235+
["barbiecore", "barbie", "dreamhouse"][...],
236+
[
237+
"Int": [1],
238+
"Int max": [2],
239+
"ID": [1],
240+
"Barbie": [1],
241+
"Barbie ID": [2],
242+
"BarbieCore Barbie ID": [3],
243+
] as [String: [Int]]
244+
),
245+
(
246+
tests / "Barbie" / "Dreamhouse" / "Keys",
247+
["barbiecore", "barbie", "dreamhouse", "keys"][...],
248+
[
249+
"Int": [1],
250+
"max": [2], // expands to two components because it is a vector symbol
251+
"ID": [1, 1, 1],
252+
"Barbie": [1],
253+
] as [String: [Int]]
254+
),
255+
]
232256
{
233-
let query:Unidoc.VertexQuery<Unidoc.LookupAdjacent> = .init(
234-
"swift-malibu", ["barbiecore", "barbie", "dreamhouse"])
257+
let query:Unidoc.VertexQuery<Unidoc.LookupAdjacent> = .init("swift-malibu", path)
235258
await tests.do
236259
{
237260
if let output:Unidoc.VertexOutput = tests.expect(
@@ -285,7 +308,7 @@ struct SymbolQueries:UnidocDatabaseTestBattery
285308
])
286309

287310
let secondaries:Set<Unidoc.Scalar> = .init(output.vertices.lazy.map(\.id))
288-
let lengths:[String: Int] = overview.outlines.reduce(into: [:])
311+
let lengths:[String: [Int]] = overview.outlines.reduce(into: [:])
289312
{
290313
guard
291314
case .path(let words, let path) = $1
@@ -299,19 +322,12 @@ struct SymbolQueries:UnidocDatabaseTestBattery
299322
tests.expect(true: secondaries.contains(id))
300323
}
301324

302-
$0[words, default: 0] += path.count
325+
$0[words, default: []].append(path.count)
303326
}
304327
// The ``Int.max`` test case is especially valuable because not only is it
305328
// a multi-component cross-package reference, but the `max` member is also
306329
// being inherited from ``SignedInteger``.
307-
tests.expect(lengths ==? [
308-
"Int": 1,
309-
"Int max": 2,
310-
"ID": 1,
311-
"Barbie": 1,
312-
"Barbie ID": 2,
313-
"BarbieCore Barbie ID": 3,
314-
])
330+
tests.expect(lengths ==? expected)
315331
}
316332
}
317333
}

Stylesheets/Main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@import 'section.group';
2727
@import 'section.group.dense';
2828
@import 'section.introduction';
29+
@import 'section.literature';
2930
@import 'section.metadata';
3031
@import 'Sidebar';
3132
@import 'Tables';

0 commit comments

Comments
 (0)