Skip to content

Commit

Permalink
Check crate version compatibility in docs.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed Jun 22, 2024
1 parent 39cd589 commit ab5eb48
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions extension/script/docs-rs-check-crate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(function () {
if (!window.searchState?.descShards) {
let button = document.querySelector(".add-to-extension");
if (button) {
button.classList.add("add-to-extension-disabled");
button.onclick = (event) => {
// Prevent click event propagation to parent element.
event.stopImmediatePropagation();
};
}
let content = document.querySelector(".add-to-extension-content");
if (content) {
content.innerHTML = `<p>This crate version is not supported by Rust Search Extension. <br><br>After Rust Search Extension v2.0 has been released, we only support crate published after 2024-04-20.</p>`;
}
console.log("No searchState.descShards found, cannot add this crate to Rust Search Extension.");
}
})();
6 changes: 6 additions & 0 deletions extension/script/docs-rs.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ div.nav-container form.landing-search-form-nav {
margin: 5.4px 16px 4.4px;
}

.add-to-extension-disabled {
background-color: #edebe7 !important;
cursor: not-allowed !important;
color: #666 !important;
}

.add-to-extension:hover {
color: #121212;
background-color: #F9BB2D;
Expand Down
1 change: 1 addition & 0 deletions extension/script/docs-rs.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ document.addEventListener("DOMContentLoaded", async () => {
} else {
insertAddToExtensionElement("need-to-install");
}
injectScripts(["script/docs-rs-check-crate.js"]);
}


Expand Down

0 comments on commit ab5eb48

Please sign in to comment.