Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down
17 changes: 16 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
SPHINX_ALABASTER,
SPHINX_READTHEDOCS,
SPHINX_IMMATERIAL,
SPHINX_PYDATA,
MDBOOK,
MKDOCS,
MKDOCS_MATERIAL,
Expand Down Expand Up @@ -608,6 +609,8 @@ export class DocumentationTool {
return SPHINX_FURO;
} else if (this.isSphinxImmaterialLikeTheme()) {
return SPHINX_IMMATERIAL;
} else if (this.isSphinxPyDataLikeTheme()) {
return SPHINX_PYDATA;
}
}

Expand Down Expand Up @@ -709,7 +712,8 @@ export class DocumentationTool {
this.isSphinxReadTheDocsLikeTheme() ||
this.isSphinxFuroLikeTheme() ||
this.isSphinxBookThemeLikeTheme() ||
this.isSphinxImmaterialLikeTheme()
this.isSphinxImmaterialLikeTheme() ||
this.isSphinxPyDataLikeTheme()
);
}

Expand Down Expand Up @@ -829,6 +833,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(
Expand Down
20 changes: 20 additions & 0 deletions tests/utils.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down