From f2a852b414b77c79c6c68bfdf4b5fc285fb75c9f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 6 Aug 2024 00:25:11 +0530 Subject: [PATCH 1/3] Fix Sphinx 8 deprecation warning --- jupyterlite_sphinx/jupyterlite_sphinx.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jupyterlite_sphinx/jupyterlite_sphinx.py b/jupyterlite_sphinx/jupyterlite_sphinx.py index 08029b9..366b0e9 100644 --- a/jupyterlite_sphinx/jupyterlite_sphinx.py +++ b/jupyterlite_sphinx/jupyterlite_sphinx.py @@ -4,7 +4,7 @@ import shutil import glob import re -from typing import Dict, Any +from typing import Dict, Any, List from pathlib import Path @@ -608,9 +608,9 @@ def run(self): return [content_container_node, notebook_container, script_node] -def _process_docstring_examples(app, docname, source): - source_path = app.env.doc2path(docname) - if source_path.endswith(".py"): +def _process_docstring_examples(app: Sphinx, docname: str, source: List[str]) -> None: + source_path: os.PathLike = Path(app.env.doc2path(docname)) + if source_path.suffix == ".py": source[0] = insert_try_examples_directive(source[0]) From 43e6eeeb46ee3a5e84fb5d386b294f4566beb404 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:19:46 +0530 Subject: [PATCH 2/3] Apply suggestions from code review Convert `_StrPath` to `str` instead --- jupyterlite_sphinx/jupyterlite_sphinx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jupyterlite_sphinx/jupyterlite_sphinx.py b/jupyterlite_sphinx/jupyterlite_sphinx.py index 366b0e9..b0c1cf9 100644 --- a/jupyterlite_sphinx/jupyterlite_sphinx.py +++ b/jupyterlite_sphinx/jupyterlite_sphinx.py @@ -609,8 +609,8 @@ def run(self): def _process_docstring_examples(app: Sphinx, docname: str, source: List[str]) -> None: - source_path: os.PathLike = Path(app.env.doc2path(docname)) - if source_path.suffix == ".py": + source_path: str = str(app.env.doc2path(docname)) + if source_path.endswith(".py"): source[0] = insert_try_examples_directive(source[0]) From 13a3631b8e3f52e232a910eb284e6597f94894c3 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:39:35 +0530 Subject: [PATCH 3/3] Use `Path.suffix()`, don't cast `doc2path` to `str` --- jupyterlite_sphinx/jupyterlite_sphinx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jupyterlite_sphinx/jupyterlite_sphinx.py b/jupyterlite_sphinx/jupyterlite_sphinx.py index b0c1cf9..9385165 100644 --- a/jupyterlite_sphinx/jupyterlite_sphinx.py +++ b/jupyterlite_sphinx/jupyterlite_sphinx.py @@ -609,8 +609,8 @@ def run(self): def _process_docstring_examples(app: Sphinx, docname: str, source: List[str]) -> None: - source_path: str = str(app.env.doc2path(docname)) - if source_path.endswith(".py"): + source_path: str = app.env.doc2path(docname) + if source_path.suffix == ".py": source[0] = insert_try_examples_directive(source[0])