Skip to content

Commit 1126607

Browse files
authored
docs: fix navigation links on left sidebar (#1622)
1 parent a9b3f1a commit 1126607

File tree

4 files changed

+25
-147
lines changed

4 files changed

+25
-147
lines changed

buildSrc/src/main/kotlin/dokka-convention.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,15 @@ tasks.register("trimNavigationFiles") {
9797
val navigation = moduleDir.resolve("navigation.html").toFile()
9898
val doc = Jsoup.parse(navigation)
9999

100-
// Fix navigation links
101-
doc.select("a[href^='../../../../']").forEach { anchor ->
102-
val originalHref = anchor.attr("href")
103-
val trimmedHref = originalHref.replace("../../../../", "")
104-
anchor.attr("href", trimmedHref)
100+
// Remove all parent directory elements from all navigation links
101+
doc.select("a[href^=../]").forEach { anchor ->
102+
var href = anchor.attr("href")
103+
104+
while (href.startsWith("../")) {
105+
href = href.removePrefix("../")
106+
}
107+
108+
anchor.attr("href", href)
105109
}
106110

107111
// Trim side menus

docs/dokka-presets/scripts/custom-navigation-loader.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
* https://sdk.amazonaws.com/kotlin/api/latest/index.html -> index.html
66
* https://sdk.amazonaws.com/kotlin/api/latest/s3/index.html -> s3
77
* https://sdk.amazonaws.com/kotlin/api/latest/s3/aws.sdk.kotlin.services.s3/index.html -> s3
8+
* https://sdk.amazonaws.com/kotlin/api/1.4.109/s3/index.html -> s3
89
*/
910
function extractModulePath(href) {
1011
try {
11-
const url = new URL(href, window.location.origin);
12-
const pathSegments = url.pathname.split('/').filter(Boolean);
13-
14-
var moduleIndex = -1;
15-
16-
for (let i = 1; i < pathSegments.length; i++) {
17-
if (pathSegments[i].includes('.')) {
18-
moduleIndex = i-1;
19-
break;
20-
}
12+
const segments = new URL(href, window.location.origin)
13+
.pathname
14+
.split('/')
15+
.filter(Boolean); // drop empty parts
16+
17+
// the URL pattern is always ".../kotlin/api/<version>/..." in production
18+
const apiIndex = segments.indexOf('api');
19+
20+
if (apiIndex !== -1) {
21+
// segment after "api" is the version ("latest", "1.4.109", etc.)
22+
// segment after _that_ is the module name (or "index.html" if we're at the root)
23+
return segments[apiIndex + 2] ?? 'index.html';
2124
}
2225

23-
if (moduleIndex === -1) {
24-
return "index.html";
25-
} else {
26-
return pathSegments.slice(0, moduleIndex + 1).join("/");
27-
}
28-
} catch (error) {
26+
// locally-hosted docs don't have /kotlin/api segment
27+
return segments[0] ?? 'index.html';
28+
} catch {
2929
return null;
3030
}
3131
}

services/timestreamquery/e2eTest/src/EndpointDiscoveryTest.kt

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

services/timestreamwrite/e2eTest/src/EndpointDiscoveryTest.kt

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

0 commit comments

Comments
 (0)