From 3f67a953540450e9c552255471e4f074f3ec35c2 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 16 Dec 2025 16:04:45 +0100 Subject: [PATCH 1/3] Detect Sphinx PyData theme Related #666 --- src/utils.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 0f154bde..f66bff15 100644 --- a/src/utils.js +++ b/src/utils.js @@ -709,7 +709,8 @@ export class DocumentationTool { this.isSphinxReadTheDocsLikeTheme() || this.isSphinxFuroLikeTheme() || this.isSphinxBookThemeLikeTheme() || - this.isSphinxImmaterialLikeTheme() + this.isSphinxImmaterialLikeTheme() || + this.isSphinxPyDataLikeTheme() ); } @@ -829,6 +830,17 @@ export class DocumentationTool { return false; } + isSphinxPyDataLikeTheme() { + if ( + document.querySelectorAll( + 'link[href*="_static/styles/pydata-sphinx-theme.css"]', + ).length === 1 + ) { + return true; + } + return false; + } + isMaterialMkDocsTheme() { if ( document.querySelectorAll( From a86119e20dd8ceb008f890c7bd15214654b78337 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 16 Dec 2025 16:08:35 +0100 Subject: [PATCH 2/3] Detect the theme as well --- src/constants.js | 1 + src/utils.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/constants.js b/src/constants.js index d81a69bd..e6b26609 100644 --- a/src/constants.js +++ b/src/constants.js @@ -18,6 +18,7 @@ export const SPHINX_ALABASTER = "alabaster"; export const SPHINX_FURO = "furo"; export const SPHINX_READTHEDOCS = "readthedocs"; export const SPHINX_IMMATERIAL = "immaterial"; +export const SPHINX_PYDATA = "pydata"; // API URLs export const EMBED_API_ENDPOINT = "/_/api/v3/embed/"; diff --git a/src/utils.js b/src/utils.js index f66bff15..bdf145f7 100644 --- a/src/utils.js +++ b/src/utils.js @@ -6,6 +6,7 @@ import { SPHINX_ALABASTER, SPHINX_READTHEDOCS, SPHINX_IMMATERIAL, + SPHINX_PYDATA, MDBOOK, MKDOCS, MKDOCS_MATERIAL, @@ -608,6 +609,8 @@ export class DocumentationTool { return SPHINX_FURO; } else if (this.isSphinxImmaterialLikeTheme()) { return SPHINX_IMMATERIAL; + } else if (this.isSphinxPyDataLikeTheme()) { + return SPHINX_PYDATA; } } From 54e795656ab1380773dc06a756d075aa2ec01f74 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 16 Dec 2025 16:14:05 +0100 Subject: [PATCH 3/3] Add test case --- tests/utils.test.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/utils.test.html b/tests/utils.test.html index 079bc430..b8f1dc58 100644 --- a/tests/utils.test.html +++ b/tests/utils.test.html @@ -179,6 +179,26 @@ ); }); + it("Sphinx PyData", async () => { + element = document.createElement("link"); + element.href = "_static/styles/pydata-sphinx-theme.css"; + document.head.appendChild(element); + + const tool = new utils.DocumentationTool(); + + expect(tool.isMkDocs()).to.be.false; + expect(tool.getDocumentationTool()).to.be.equal("sphinx"); + expect(tool.isSphinx()).to.be.true; + expect(tool.isSphinxAlabasterLikeTheme()).to.be.false; + expect(tool.isSphinxReadTheDocsLikeTheme()).to.be.false; + expect(tool.isSphinxFuroLikeTheme()).to.be.false; + expect(tool.isSphinxPyDataLikeTheme()).to.be.true; + expect(tool.getRootSelector()).to.be.equal("[role=main]"); + expect(tool.getLinkSelector()).to.be.equal( + "[role=main] a.internal", + ); + }); + it("Sphinx Read the Docs", async () => { element = document.createElement("script"); element.src = "_static/js/theme.js";