From 6dcfbba3ace96197112c9c00611f6ea263485f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niko=20F=C3=B6hr?= Date: Sun, 18 Feb 2024 14:00:03 +0200 Subject: [PATCH 1/5] remove unused _static path --- docs/source/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 92bf82c1..98c3a783 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -63,7 +63,6 @@ # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] -html_static_path = ["_static"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. From 55eccbc52331384bd7bc9f0dce69f0091806a52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niko=20F=C3=B6hr?= Date: Tue, 5 Mar 2024 21:02:35 +0200 Subject: [PATCH 2/5] use a numpydoc 1.7.0rc0.dev0 This has a fix for NamedTuple documentation (https://github.com/numpy/numpydoc/pull/527) --- docs/source/conf.py | 6 ++++-- pyproject.toml | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 98c3a783..c8a6fe68 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,10 +22,12 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - # Markdown (MyST) format support for Sphinx - "myst_parser", # Adds support for NumPy style docstrings for autodoc + # Note: numpydoc must be listed before myst_parser in order to make the + # NamedTuples fix (https://github.com/numpy/numpydoc/pull/527) work. "numpydoc", + # Markdown (MyST) format support for Sphinx + "myst_parser", # Sphinx Design adds some sphinx directives for UI components # See: https://sphinx-design.readthedocs.io/ "sphinx_design", diff --git a/pyproject.toml b/pyproject.toml index b8feba4d..ba8a064d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,9 @@ doc = [ "sphinx-copybutton~=0.5.2", "myst-parser~=2.0.0", "sphinx-book-theme~=1.1.0", - "numpydoc" + # a numpydoc 1.7.0rc0.dev0. This one has https://github.com/numpy/numpydoc/pull/527 merged + # At some point: Can use 1.7.0 (which is not available in PyPI at the time of writing) + "numpydoc @ git+https://github.com/numpy/numpydoc.git@46f532a824639a97479039fc122533915cdfa10f" ] dev = [ "sphinx-autobuild", From 52e7defe1e961f9b36a9cce678ef6dc3cc666312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niko=20F=C3=B6hr?= Date: Tue, 5 Mar 2024 22:57:14 +0200 Subject: [PATCH 3/5] add dummy custom js file --- docs/source/_static/wakepy.js | 1 + docs/source/conf.py | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 docs/source/_static/wakepy.js diff --git a/docs/source/_static/wakepy.js b/docs/source/_static/wakepy.js new file mode 100644 index 00000000..be19a41d --- /dev/null +++ b/docs/source/_static/wakepy.js @@ -0,0 +1 @@ +console.log("bar") \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index c8a6fe68..99de3611 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -71,6 +71,8 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [] +html_static_path = ["_static"] +html_js_files = ["wakepy.js"] # -- Options for HTML output ------------------------------------------------- From d74bd88d9e3ead1b2d0383e1d0497cbba5092fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niko=20F=C3=B6hr?= Date: Wed, 6 Mar 2024 00:02:08 +0200 Subject: [PATCH 4/5] fix the API Reference page sidebar TOC --- docs/source/_static/wakepy.js | 63 ++++++++++++++++++++++++++++++++++- docs/source/api-reference.md | 3 +- docs/source/conf.py | 5 ++- 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/docs/source/_static/wakepy.js b/docs/source/_static/wakepy.js index be19a41d..583a97e8 100644 --- a/docs/source/_static/wakepy.js +++ b/docs/source/_static/wakepy.js @@ -1 +1,62 @@ -console.log("bar") \ No newline at end of file + +/** + * Function to check if we are on the API Reference page + * @returns {bool} True of on API Reference page. False otherwise. + */ +function shouldDisableScrollSpy() { + // The API Reference page has

API Reference

as the first h1 element + var h1Elements = document.querySelectorAll("h1"); + var h1Array = Array.from(h1Elements); + var isOnApiReferencePage = h1Array[0].textContent.trim() == 'API Reference' + return isOnApiReferencePage +} + +/** + * Function to diable the Bootstrap Scroll Spy. + */ +function disableScrollSpy() { + var scrollSpyBody = document.querySelector('body[data-bs-spy="scroll"][data-bs-target=".bd-toc-nav"]'); + if (scrollSpyBody) { + scrollSpyBody.removeAttribute('data-bs-spy'); + scrollSpyBody.removeAttribute('data-bs-target'); + } +} + +/** + * Make TOC
  • elemenents active; + * Add CSS class "active" to all the >
      >
    • elements. + */ +function makeTocLiElementsActive() { + // The sidebar TOC is