From c6e368813e6ed123b3b1520a3c4cc888cd2dfbb0 Mon Sep 17 00:00:00 2001 From: AnalogFeelings <51166756+AnalogFeelings@users.noreply.github.com> Date: Mon, 16 Sep 2024 23:45:33 +0200 Subject: [PATCH 1/2] 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. --- docs/README.md | 2 +- docs/_template/material/public/main.js | 23 ++++++----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/docs/README.md b/docs/README.md index 20e41f6afd..493bdbe06a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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` diff --git a/docs/_template/material/public/main.js b/docs/_template/material/public/main.js index facbb6394c..b9fac37fd5 100644 --- a/docs/_template/material/public/main.js +++ b/docs/_template/material/public/main.js @@ -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]; @@ -56,7 +45,7 @@ } }); - if(scrollValue && scrollValue >= 0) + if (scrollValue && scrollValue >= 0) { tocDiv.scroll(0, scrollValue); } From 07bf2e826798ff91ce4b33c2f42ed6b786fc0728 Mon Sep 17 00:00:00 2001 From: AnalogFeelings <51166756+AnalogFeelings@users.noreply.github.com> Date: Tue, 17 Sep 2024 00:02:10 +0200 Subject: [PATCH 2/2] Update docs workflow. --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0e8dd09df1..d911354779 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -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