From 63b235ac62c5fb7ce3633d22a3fc9129bb48c804 Mon Sep 17 00:00:00 2001
From: Laurent Wouters
Date: Wed, 11 Sep 2024 12:08:27 +0200
Subject: [PATCH] fix: fixing display of documentation data in web app (#8)
---
src/webapp/crate.html | 67 ++++++++++++++++++++++------------
src/webapp/index-outdated.html | 4 +-
src/webapp/index.html | 4 +-
3 files changed, 48 insertions(+), 27 deletions(-)
diff --git a/src/webapp/crate.html b/src/webapp/crate.html
index d9a9539..12421be 100644
--- a/src/webapp/crate.html
+++ b/src/webapp/crate.html
@@ -123,7 +123,9 @@
Documentation
-
+
Owners
@@ -141,7 +143,7 @@
Version
- Status
+ Targets / Status
|
Actions
@@ -315,12 +317,22 @@ Remove this ta
document.getElementById("meta-uploaded-by").appendChild(document.createTextNode(currentVersion.uploadedBy.name));
document.getElementById("meta-uploaded-by").href = `mailto:${currentVersion.uploadedBy.email}`;
document.getElementById("meta-install").appendChild(document.createTextNode(`${currentVersion.index.name} = { version = "${currentVersion.index.vers}", registry = "${registryInfo.registryName}" }`));
- if (currentVersion.hasDocs) {
- const crateRustName = currentVersion.index.name.replaceAll("-", "_");
- const link = document.createElement("a");
- link.appendChild(document.createTextNode(`v${currentVersion.index.vers}`));
- link.setAttribute("href", `/docs/${currentVersion.index.name}/${currentVersion.index.vers}/${crateRustName}/index.html`);
- document.getElementById("meta-docs").appendChild(link);
+ for (const doc of currentVersion.docs) {
+ if (doc.isPresent) {
+ const crateRustName = currentVersion.index.name.replaceAll("-", "_");
+ const link = document.createElement("a");
+ if (doc.target === registryInfo.toolchainHost) {
+ // default target
+ link.appendChild(document.createTextNode(`v${currentVersion.index.vers}`));
+ link.setAttribute("href", `/docs/${currentVersion.index.name}/${currentVersion.index.vers}/${crateRustName}/index.html`);
+ } else {
+ link.appendChild(document.createTextNode(`v${currentVersion.index.vers} - ${doc.target}`));
+ link.setAttribute("href", `/docs/${currentVersion.index.name}/${currentVersion.index.vers}/${doc.target}/${crateRustName}/index.html`);
+ }
+ const li = document.createElement("li");
+ li.appendChild(link);
+ document.getElementById("meta-docs").appendChild(li);
+ }
}
document.getElementById("tab-readme-dl-total").appendChild(document.createTextNode(
crate.versions.reduce((acc, v) => acc + v.downloadCount, 0).toString()
@@ -693,32 +705,41 @@ Remove this ta
}
function renderDocsVersion(version) {
- const linkEl = document.createElement("a");
- if (version.hasDocs) {
- const crateRustName = version.index.name.replaceAll("-", "_");
- linkEl.setAttribute("href", `/docs/${version.index.name}/${version.index.vers}/${crateRustName}/index.html`);
- }
- linkEl.className = "font-medium text-blue-600 dark:text-blue-500 hover:underline";
- linkEl.appendChild(document.createTextNode(version.index.vers));
+ const hasMissing = version.docs.length === 0 || version.docs.reduce((acc, doc) => acc || !doc.isPresent, false);
- const color = version.hasDocs ? "green" : "red";
- const statusEl = document.createElement("span");
- statusEl.className = `bg-${color}-100 text-${color}-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-${color}-900 dark:text-${color}-300`;
- statusEl.style.display = "inline-block";
- statusEl.appendChild(document.createTextNode(version.hasDocs ? "available" : "missing"));
+ const versionEl = document.createElement("span");
+ versionEl.className = "font-medium text-blue-600 dark:text-blue-500";
+ versionEl.appendChild(document.createTextNode(version.index.vers));
const row = document.createElement("tr");
const cell1 = document.createElement("th");
cell1.setAttribute("scope", "row");
cell1.className = "px-6 py-4 font-medium";
- cell1.appendChild(linkEl);
+ cell1.appendChild(versionEl);
const cell2 = document.createElement("td");
cell2.className = "px-6 py-4";
- cell2.appendChild(statusEl);
const cell3 = document.createElement("td");
cell3.className = "px-6 py-4";
- if (!version.hasDocs) {
+ for (const doc of version.docs) {
+ const color = doc.isPresent ? "green" : "red";
+ const statusEl = document.createElement("span");
+ statusEl.className = `mx-3 bg-${color}-100 text-${color}-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-${color}-900 dark:text-${color}-300`;
+ statusEl.appendChild(document.createTextNode(doc.isPresent ? "available" : "missing"));
+
+ const crateRustName = version.index.name.replaceAll("-", "_");
+ const linkEl = document.createElement("a");
+ linkEl.appendChild(document.createTextNode(doc.target));
+ linkEl.setAttribute("href", `/docs/${version.index.name}/${version.index.vers}/${doc.target}/${crateRustName}/index.html`);
+
+ const wrapper = document.createElement("div");
+ wrapper.appendChild(linkEl);
+ wrapper.appendChild(statusEl);
+ wrapper.style.display = "inline-block";
+ cell2.appendChild(wrapper);
+ }
+
+ if (hasMissing) {
//
const refreshEl = document.createElement("button");
refreshEl.type = "button";
diff --git a/src/webapp/index-outdated.html b/src/webapp/index-outdated.html
index 10a3163..c84b18e 100644
--- a/src/webapp/index-outdated.html
+++ b/src/webapp/index-outdated.html
@@ -64,10 +64,10 @@ |