Skip to content

Commit

Permalink
[Doc] Unbold "Use Cases" in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed Sep 6, 2023
1 parent 821b835 commit 9d00ac8
Showing 1 changed file with 75 additions and 51 deletions.
126 changes: 75 additions & 51 deletions doc/source/_static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,62 +28,86 @@ window.addEventListener("scroll", loadVisibleTermynals);
createTermynals();
loadVisibleTermynals();


// Reintroduce dropdown icons on the sidebar. This is a hack, as we can't
// programmatically figure out which nav items have children anymore.
document.addEventListener("DOMContentLoaded", function() {
let navItems = document.querySelectorAll(".bd-sidenav li");
for (let i = 0; i < navItems.length; i++) {
let navItem = navItems[i];
const stringList = [
"User Guides", "Examples",
// Ray Core
"Ray Core", "Ray Core API",
// Ray Cluster
"Ray Clusters", "Deploying on Kubernetes", "Deploying on VMs",
"Applications Guide", "Ray Cluster Management API",
"Getting Started with KubeRay", "KubeRay Ecosystem", "KubeRay Benchmarks", "KubeRay Troubleshooting",
// Ray AIR
"Ray AIR API",
// Ray Data
"Ray Data", "Ray Data API", "Integrations",
// Ray Train
"Ray Train", "More Frameworks",
"Advanced Topics", "Internals",
"Ray Train API",
// Ray Tune
"Ray Tune", "Ray Tune Examples", "Ray Tune API",
// Ray Serve
"Ray Serve", "Ray Serve API",
"Production Guide", "Advanced Guides",
"Deploy Many Models",
// Ray RLlib
"Ray RLlib", "Ray RLlib API",
// More libraries
"More Libraries", "Ray Workflows (Alpha)",
// Monitoring/debugging
"Monitoring and Debugging",
// References
"References", "Use Cases",
// Developer guides
"Developer Guides", "Getting Involved / Contributing",
];

const containsString = stringList.some(str => navItem.innerText ===str);

if (containsString && ! navItem.classList.contains('current')) {
if (navItem.classList.contains('toctree-l1')) {
navItem.style.fontWeight = "bold";
}
const href = navItem.querySelector("a").getAttribute("href");
navItem.innerHTML +=
'<a href="'+ href +'" style="display: none">'
+ '<input checked="" class="toctree-checkbox" id="toctree-checkbox-'
+ i + '" name="toctree-checkbox-' + i + '" type="button"></a>'
+ '<label for="toctree-checkbox-' + i + '">' +
'<i class="fas fa-chevron-down"></i></label>'
}

const defaultStyle = {"fontWeight": "bold"}

const stringList = [
{"text": "User Guides"},
{"text": "Examples"},
// Ray Core
{"text": "Ray Core"},
{"text": "Ray Core API"},
// Ray Cluster
{"text": "Ray Clusters"},
{"text": "Deploying on Kubernetes"},
{"text": "Deploying on VMs"},
{"text": "Applications Guide"},
{"text": "Ray Cluster Management API"},
{"text": "Getting Started with KubeRay"},
{"text": "KubeRay Ecosystem"},
{"text": "KubeRay Benchmarks"},
{"text": "KubeRay Troubleshooting"},
// Ray AIR
{"text": "Ray AIR API"},
// Ray Data
{"text": "Ray Data"},
{"text": "Ray Data API"},
{"text": "Integrations"},
// Ray Train
{"text": "Ray Train"},
{"text": "More Frameworks"},
{"text": "Advanced Topics"},
{"text": "Internals"},
{"text": "Ray Train API"},
// Ray Tune
{"text": "Ray Tune"},
{"text": "Ray Tune Examples"},
{"text": "Ray Tune API"},
// Ray Serve
{"text": "Ray Serve"},
{"text": "Ray Serve API"},
{"text": "Production Guide"},
{"text": "Advanced Guides"},
{"text": "Deploy Many Models"},
// Ray RLlib
{"text": "Ray RLlib"},
{"text": "Ray RLlib API"},
// More libraries
{"text": "More Libraries"},
{"text": "Ray Workflows (Alpha)"},
// Monitoring/debugging
{"text": "Monitoring and Debugging"},
// References
{"text": "References"},
{"text": "Use Cases", "style": {}}, // Don't use default style: https://github.com/ray-project/ray/issues/39172
// Developer guides
{"text": "Developer Guides"},
{"text": "Getting Involved / Contributing"},
];

Array.from(navItems).filter(
item => stringList.some(({text}) => item.innerText === text) && ! item.classList.contains('current')
).forEach((item, i) => {
if (item.classList.contains('toctree-l1')) {
const { style } = stringList.find(({text}) => item.innerText == text)

// Set the style on the menu items
Object.entries(style ?? defaultStyle).forEach(([key, value]) => {
item.style[key] = value
})

}
item.innerHTML +=
`<a href="${item.querySelector("a").getAttribute("href")}" style="display: none">`
+ '<input checked="" class="toctree-checkbox" id="toctree-checkbox-'
+ i + '" name="toctree-checkbox-' + i + '" type="button"></a>'
+ '<label for="toctree-checkbox-' + i + '">' +
'<i class="fas fa-chevron-down"></i></label>'
})
});

// Dynamically adjust the height of all panel elements in a gallery to be the same as
Expand Down

0 comments on commit 9d00ac8

Please sign in to comment.