Skip to content

Commit ec9f798

Browse files
committed
Since we'll be bikeshedding texts, pull strings out
1 parent 6b79efb commit ec9f798

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

docs/site/03-compatibility.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ img.pylogo {
2121

2222
<script src="{{ '/assets/js/check_compatibility_helpers.js' | relative_url }}"></script>
2323
<script>
24+
DB.ANY_VERSION = "any";
25+
DB.INSTALLS_BUT_FAILS_TESTS = "The package installs, but the test suite was not set up for GraalPy.";
26+
DB.FAILS_TO_INSTALL = "The package fails to build or install.";
27+
DB.UNSUPPORTED = "The package is unsupported.";
28+
DB.PERCENT_PASSING = (pct) => `${pct}% of the tests are passing on GraalPy.`;
29+
const PATCH_AVAILABLE = "GraalPy will automatically apply a patch when installing this package to improve compatibility.";
30+
const LOWER_PRIORITY = "This version works, but there is no reason to prefer it over more recent versions.";
31+
const BUILD_SCRIPT_AVAILABLE = (url) => `If you have trouble building this package, there is a <a href='${url}'>script</a>.`
32+
2433
const default_version = 'v242';
2534
const show_percentages = true;
2635
const dbs = {};
@@ -39,8 +48,8 @@ img.pylogo {
3948
for (const item of contents) {
4049
const parts = item.name.split('.');
4150
const package_name = parts[0];
42-
const version = parts.slice(1, -1).join('.') || "any";
43-
packages.push(`${package_name},${version},0,GraalPy provides a script to build this package from <a href='${item.html_url}'>source</a>.`);
51+
const version = parts.slice(1, -1).join('.') || DB.ANY_VERSION;
52+
packages.push(`${package_name},${version},0,${BUILD_SCRIPT_AVAILABLE(item.html_url)}`);
4453
}
4554
resolve(packages.join("\n"));
4655
} else {
@@ -70,11 +79,11 @@ img.pylogo {
7079
[currentPatch.name,
7180
currentPatch.version,
7281
0,
73-
currentPatch.comment || "GraalPy automatically applies a patch to run this package."].join(",")
82+
currentPatch.comment || PATCH_AVAILABLE].join(",")
7483
)
7584
}
7685
let pkgName = line.substring(2, line.indexOf(".")).trim();
77-
currentPatch = {name: pkgName, version: "any"};
86+
currentPatch = {name: pkgName, version: DB.ANY_VERSION};
7887
} else if (line.startsWith('#')) {
7988
if (!currentPatch.comment) {
8089
currentPatch.comment = line.substring(1).trim();
@@ -89,9 +98,9 @@ img.pylogo {
8998
if (!currentPatch.comment.endsWith(".")) {
9099
currentPatch.comment += ".";
91100
}
92-
currentPatch.comment += " This version works, but another should be chosen if possible.";
101+
currentPatch.comment += " " + LOWER_PRIORITY;
93102
} else {
94-
currentPatch.comment = "GraalPy provides a patch for this version, but it is recommended to use another if possible.";
103+
currentPatch.comment = LOWER_PRIORITY;
95104
}
96105
}
97106
}
@@ -101,7 +110,7 @@ img.pylogo {
101110
[currentPatch.name,
102111
currentPatch.version,
103112
0,
104-
currentPatch.comment || "GraalPy provides a patch to make this package work."].join(",")
113+
currentPatch.comment || PATCH_AVAILABLE].join(",")
105114
)
106115
}
107116
resolve(patches.join("\n"));
@@ -287,6 +296,7 @@ img.pylogo {
287296
</tr>`);
288297
}
289298
}
299+
$('#compatibility_page__search-field').trigger("input");
290300
updateStatistics(count, countCompatible, countUntested, countIncompatible, countNotSupported);
291301
updatePagination(true);
292302
});
@@ -361,14 +371,26 @@ img.pylogo {
361371
$(".compatibility_page-item").click(function () {
362372
$(this).addClass("compatibility_page-active").siblings().removeClass("compatibility_page-active");
363373
const graalpyModuleValue = $(".compatibility_page-item.compatibility_page-module.compatibility_page-active").attr("data-filter");
364-
window.history.pushState("", window.location.title, `?version=${graalpyModuleValue}`);
374+
let search = window.location.search;
375+
if (search) {
376+
search = search.replace(/version=[^&]+/, "");
377+
if (search != "?") {
378+
search += "&";
379+
}
380+
} else {
381+
search = "?";
382+
}
383+
search += `version=${graalpyModuleValue}`;
384+
window.history.pushState("", window.location.title, search);
365385
updatePageData();
366386
});
367387
function setFilters() {
368388
const params = new URLSearchParams(window.location.search);
369389
const graalpyModuleValue = params.get('version') || default_version;
370390
const moduleFilterElement = $(`.compatibility_page-module[data-filter=${graalpyModuleValue}]`);
371391
moduleFilterElement.addClass("compatibility_page-active").siblings().removeClass("compatibility_page-active");
392+
const packages = params.get('packages') || "";
393+
$('#compatibility_page__search-field').val(packages);
372394
}
373395
setFilters();
374396
});

docs/site/assets/js/check_compatibility_helpers.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ class DBEntry {
2323
if (this.is_test_percentage()) {
2424
if (this.has_no_test_results()) {
2525
if (this.test_status < 2) {
26-
notes = "The package installs, but the test suite was not set up for GraalPy.";
26+
notes = DB.INSTALLS_BUT_FAILS_TESTS;
2727
} else if (this.test_status == 2) {
28-
notes = "The package fails to build or install.";
28+
notes = DB.FAILS_TO_INSTALL;
2929
} else {
30-
notes = "The package is unsupported.";
30+
notes = DB.UNSUPPORTED;
3131
}
3232
} else {
33-
notes = notes + "% of the tests are passing on GraalPy.";
33+
notes = DB.PERCENT_PASSING(notes);
3434
}
3535
}
3636
if (!notes.endsWith(".")) {
@@ -58,7 +58,7 @@ class DB {
5858
this.db[entry.name] ||= {};
5959
this.db[entry.name][entry.version] = merge_entries(entry, this.db[entry.name][entry.version]);
6060

61-
if (entry.version == "any") {
61+
if (entry.version == DB.ANY_VERSION) {
6262
any_versions[entry.name] = this.db[entry.name][entry.version];
6363
}
6464
}

0 commit comments

Comments
 (0)