Skip to content

Commit

Permalink
[Docs] Update docfx and remove tocFilter hack. (#3010)
Browse files Browse the repository at this point in the history
* Update docfx and remove tocFilter hack.

docfx PR 9912 fixed the TOC filter value not being kept between page loads.
This removes the hack I used to get around it, but keeps the scroll code.

* Update docs workflow.
  • Loading branch information
AnalogFeelings authored Sep 17, 2024
1 parent 433bdc2 commit de8da0d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
dotnet-version: 8.0.x

- name: Setup DocFX
run: dotnet tool install -g docfx --version 2.76.0
run: dotnet tool install -g docfx --version 2.77.0

- name: Build DNet docs
run: docfx docs/docfx.json
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The documentation for the Discord.Net library uses [DocFX][docfx-main].
Instructions for installing this tool can be found [here][docfx-installing].

> [!IMPORTANT]
> You must use DocFX version **2.76.0** for everything to work correctly.
> You must use DocFX version **2.77.0** for everything to work correctly.
1. Navigate to the root of the repository.
2. Build the docs using `docfx docs/docfx.json`. Add the `--serve`
Expand Down
23 changes: 6 additions & 17 deletions docs/_template/material/public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,18 @@
{
// Ugly hack to improve toc filter.
let target = document.getElementById("toc");
if(!target) return;

if (!target) return;

let config = { attributes: false, childList: true, subtree: true };
let observer = new MutationObserver((list) =>
{
for(const mutation of list)
for (const mutation of list)
{
if(mutation.type === "childList" && mutation.target == target)
if (mutation.type === "childList" && mutation.target == target)
{
let filter = target.getElementsByClassName("form-control")[0];

let filterValue = localStorage.getItem("tocFilter");
let scrollValue = localStorage.getItem("tocScroll");

if(filterValue && filterValue !== "")
{
filter.value = filterValue;

let inputEvent = new Event("input");
filter.dispatchEvent(inputEvent);
}

// Add event to store scroll pos.
let tocDiv = target.getElementsByClassName("flex-fill")[0];

Expand All @@ -56,7 +45,7 @@
}
});

if(scrollValue && scrollValue >= 0)
if (scrollValue && scrollValue >= 0)
{
tocDiv.scroll(0, scrollValue);
}
Expand Down

0 comments on commit de8da0d

Please sign in to comment.