mirror of
https://github.com/huhu/rust-search-extension
synced 2024-11-14 15:47:12 +00:00
33 lines
No EOL
1.2 KiB
JavaScript
33 lines
No EOL
1.2 KiB
JavaScript
// https://doc.rust-lang.org/reference/attributes.html
|
|
// https://doc.rust-lang.org/nightly/reference/attributes.html
|
|
const attributeMap = {
|
|
doc: [
|
|
"- Specifies documentation.",
|
|
"https://doc.rust-lang.org/rustdoc/the-doc-attribute.html",
|
|
],
|
|
features: [
|
|
"- Used to enable unstable or experimental compiler features.",
|
|
"https://doc.rust-lang.org/unstable-book/index.html",
|
|
],
|
|
};
|
|
let attributeIndex = document.querySelectorAll("main>ul:last-child>li");
|
|
for (let node of attributeIndex) {
|
|
let title = node.firstChild;
|
|
if (["documentation", "features"].includes(title.textContent.toLowerCase().trim()))
|
|
continue;
|
|
let attributes = node.lastElementChild.querySelectorAll("ul>li");
|
|
attributes.forEach(attribute => {
|
|
let description = "";
|
|
|
|
attribute.childNodes.forEach(childNode => {
|
|
if (childNode.nodeName !== "A" && childNode.textContent.trim().length > 1) {
|
|
description += childNode.textContent;
|
|
}
|
|
});
|
|
attribute.querySelectorAll("a").forEach(a => {
|
|
attributeMap[a.firstChild.textContent] = [description.trim(), a.getAttribute("href")];
|
|
});
|
|
});
|
|
}
|
|
|
|
console.log(JSON.stringify(attributeMap)); |