Skip to content

Commit 6e1f1db

Browse files
committed
fix javadocs
1 parent a753e53 commit 6e1f1db

6 files changed

Lines changed: 668 additions & 0 deletions

File tree

scripts/update-javadoc-indexes.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
7+
JAVADOC_DIR="${REPO_ROOT}/site/static/javadoc"
8+
OLD_DIR="${JAVADOC_DIR}/old"
9+
10+
if [[ ! -d "${JAVADOC_DIR}" ]]; then
11+
echo "Javadoc directory '${JAVADOC_DIR}' does not exist." >&2
12+
exit 1
13+
fi
14+
15+
if [[ ! -d "${OLD_DIR}" ]]; then
16+
echo "Legacy javadoc directory '${OLD_DIR}' does not exist." >&2
17+
exit 1
18+
fi
19+
20+
export JAVADOC_DIR OLD_DIR
21+
22+
python3 <<'PY'
23+
import datetime
24+
import json
25+
import os
26+
import re
27+
from pathlib import Path
28+
29+
javadoc_dir = Path(os.environ["JAVADOC_DIR"])
30+
old_dir = Path(os.environ["OLD_DIR"])
31+
32+
def isoformat(timestamp: float) -> str:
33+
return datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc).isoformat().replace("+00:00", "Z")
34+
35+
def natural_key(value: str):
36+
return [int(part) if part.isdigit() else part.lower() for part in re.split(r"(\d+)", value)]
37+
38+
directories = [
39+
{
40+
"name": path.name,
41+
"href": f"{path.name}/",
42+
"lastModified": isoformat(path.stat().st_mtime),
43+
}
44+
for path in javadoc_dir.iterdir()
45+
if path.is_dir() and not path.name.startswith(".")
46+
]
47+
48+
directories.sort(key=lambda item: natural_key(item["name"]), reverse=True)
49+
50+
files = [
51+
{
52+
"name": path.name,
53+
"href": path.name,
54+
"size": path.stat().st_size,
55+
"lastModified": isoformat(path.stat().st_mtime),
56+
}
57+
for path in old_dir.iterdir()
58+
if path.is_file() and not path.name.startswith(".")
59+
]
60+
61+
files.sort(key=lambda item: natural_key(item["name"]), reverse=True)
62+
63+
(javadoc_dir / "manifest.json").write_text(
64+
json.dumps(directories, indent=2) + "\n", encoding="utf-8"
65+
)
66+
67+
(old_dir / "files.json").write_text(
68+
json.dumps(files, indent=2) + "\n", encoding="utf-8"
69+
)
70+
PY
71+
72+
echo "Updated ${JAVADOC_DIR}/manifest.json"
73+
echo "Updated ${OLD_DIR}/files.json"

site/static/javadoc/index.html

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>RDF4J Javadoc Archives</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<style>
8+
:root {
9+
color-scheme: light dark;
10+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
11+
line-height: 1.5;
12+
}
13+
body {
14+
margin: 2rem auto;
15+
max-width: 48rem;
16+
padding: 0 1.5rem;
17+
}
18+
h1 {
19+
font-size: 2rem;
20+
margin-bottom: 0.5rem;
21+
}
22+
p.description {
23+
margin-top: 0;
24+
margin-bottom: 1.5rem;
25+
color: #555;
26+
}
27+
ul {
28+
list-style: none;
29+
padding: 0;
30+
margin: 0;
31+
}
32+
li + li {
33+
margin-top: 0.75rem;
34+
}
35+
a {
36+
color: inherit;
37+
text-decoration: none;
38+
border-bottom: 1px solid currentColor;
39+
}
40+
a:hover,
41+
a:focus {
42+
border-bottom-width: 2px;
43+
}
44+
.meta {
45+
display: block;
46+
font-size: 0.875rem;
47+
color: #666;
48+
margin-top: 0.15rem;
49+
}
50+
.empty {
51+
color: #666;
52+
font-style: italic;
53+
}
54+
</style>
55+
</head>
56+
<body>
57+
<main>
58+
<h1>RDF4J Javadoc Archives</h1>
59+
<p class="description">
60+
Available Javadoc directories are detected automatically. Choose a version below to open the extracted documentation.
61+
</p>
62+
<ul id="javadoc-list">
63+
<li class="empty">Loading available directories…</li>
64+
</ul>
65+
<p class="description">
66+
Looking for older archive files? See the <a href="old/">legacy downloads</a>.
67+
</p>
68+
</main>
69+
<script>
70+
(function () {
71+
const list = document.getElementById('javadoc-list');
72+
73+
function renderEntries(entries) {
74+
list.innerHTML = '';
75+
if (!entries || entries.length === 0) {
76+
list.innerHTML = '<li class="empty">No directories are currently available.</li>';
77+
return;
78+
}
79+
80+
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
81+
entries
82+
.slice()
83+
.sort((a, b) => collator.compare(a.name, b.name))
84+
.forEach((entry) => {
85+
const item = document.createElement('li');
86+
const link = document.createElement('a');
87+
link.href = entry.href;
88+
link.textContent = entry.name;
89+
link.setAttribute('rel', 'noopener');
90+
link.setAttribute('target', '_blank');
91+
item.appendChild(link);
92+
93+
if (entry.lastModified) {
94+
const meta = document.createElement('span');
95+
meta.className = 'meta';
96+
const date = new Date(entry.lastModified);
97+
if (!Number.isNaN(date.valueOf())) {
98+
meta.textContent = `Last modified ${date.toLocaleString()}`;
99+
} else {
100+
meta.textContent = `Last modified ${entry.lastModified}`;
101+
}
102+
item.appendChild(meta);
103+
}
104+
105+
list.appendChild(item);
106+
});
107+
}
108+
109+
function handleError(error) {
110+
console.error('Failed to load manifest.json', error);
111+
list.innerHTML = '<li class="empty">Unable to load directory listing.</li>';
112+
}
113+
114+
fetch('manifest.json', { cache: 'no-store' })
115+
.then((response) => {
116+
if (!response.ok) {
117+
throw new Error(`Unexpected response: ${response.status} ${response.statusText}`);
118+
}
119+
return response.json();
120+
})
121+
.then(renderEntries)
122+
.catch(handleError);
123+
})();
124+
</script>
125+
</body>
126+
</html>

site/static/javadoc/manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"name": "old",
4+
"href": "old/",
5+
"lastModified": "2025-11-02T11:23:57.731915Z"
6+
}
7+
]

0 commit comments

Comments
 (0)