From bf628242b935ca4dcade77fbc65ef75b697b06c8 Mon Sep 17 00:00:00 2001 From: Remco de Boer Date: Mon, 31 Jan 2022 19:38:38 +0100 Subject: [PATCH] docs: show second level in left sidebar (#221) * docs: add numpy to intersphinx inventory --- docs/conf.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index c15b2b64f..889834664 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -199,6 +199,7 @@ def fetch_logo(url: str, output_path: str) -> None: "thebe": True, "thebelab": True, }, + "show_navbar_depth": 2, "theme_dev_mode": True, } html_title = "AmpForm" @@ -254,6 +255,19 @@ def get_version(package_name: str) -> str: return "stable" +def get_minor_version(package_name: str) -> str: + installed_version = get_version(package_name) + if installed_version == "stable": + return installed_version + matches = re.match(r"^([0-9]+\.[0-9]+).*$", installed_version) + if matches is None: + raise ValueError( + "Could not find documentation for" + f" {package_name} v{installed_version}" + ) + return matches[1] + + intersphinx_mapping = { "attrs": (f"https://www.attrs.org/en/{get_version('attrs')}", None), "compwa-org": ("https://compwa-org.readthedocs.io", None), @@ -270,6 +284,7 @@ def get_version(package_name: str) -> str: f"https://mpl-interactions.readthedocs.io/en/{get_version('mpl-interactions')}", None, ), + "numpy": (f"https://numpy.org/doc/{get_minor_version('numpy')}", None), "pwa": ("https://pwa.readthedocs.io", None), "python": ("https://docs.python.org/3", None), "qrules": (