From 431e31c6bce582cf41b186a3838734757971d336 2024-05-29 12:20:37 From: M Bussonnier Date: 2024-05-29 12:20:37 Subject: [PATCH] Use and depend on intersphinx_registry for doc building. We try to still work if intersphinx_registry is not importable as it might not be packaged yet, but it is now avail on conda forge, so it should not be too hard. --- diff --git a/docs/requirements.txt b/docs/requirements.txt index 15be426..9ffcdb1 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -9,4 +9,4 @@ matplotlib docrepr prompt_toolkit ipykernel -stack_data +intersphinx_registry diff --git a/docs/source/conf.py b/docs/source/conf.py index 0f22e54..1c1bc21 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -92,12 +92,36 @@ exec( locals().update(config["sphinx"]) -intersphinx_mapping = config["intersphinx_mapping"] -for k, v in intersphinx_mapping.items(): - intersphinx_mapping[k] = tuple( - [intersphinx_mapping[k]["url"], intersphinx_mapping[k]["fallback"]] +try: + from intersphinx_registry import get_intersphinx_mapping + + intersphinx_mapping = get_intersphinx_mapping( + packages={ + "python", + "rpy2", + "jupyterclient", + "jupyter", + "jedi", + "traitlets", + "ipykernel", + "prompt_toolkit", + "ipywidgets", + "ipyparallel", + "pip", + } ) +except ModuleNotFoundError: + # In case intersphinx_registry is not yet packages on current plaform + # as it is quite recent. + print("/!\\ intersphinx_registry not installed, relying on local mapping.") + intersphinx_mapping = config["intersphinx_mapping"] + for k, v in intersphinx_mapping.items(): + intersphinx_mapping[k] = tuple( + [intersphinx_mapping[k]["url"], intersphinx_mapping[k]["fallback"]] + ) + + # numpydoc config numpydoc_show_class_members = config["numpydoc"][ "numpydoc_show_class_members" diff --git a/pyproject.toml b/pyproject.toml index 671fc21..84bd8a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,7 @@ black = [ doc = [ "docrepr", "exceptiongroup", + "intersphinx_registry", "ipykernel", "ipython[test]", "matplotlib", @@ -70,7 +71,6 @@ doc = [ "sphinx-rtd-theme", "sphinx>=1.3", "sphinxcontrib-jquery", - "stack_data", "tomli ; python_version<'3.11'", "typing_extensions", ]