Skip to content

Commit

Permalink
Style for Antora
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Dec 18, 2024
1 parent 12057bf commit 28bb43c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export const FALLBACK_DOCTOOL = "fallback";
export const SPHINX_ALABASTER = "alabaster";
export const SPHINX_FURO = "furo";
export const SPHINX_READTHEDOCS = "readthedocs";
export const SPHINX_IMMATERIAL = "immaterial";
11 changes: 11 additions & 0 deletions src/flyout.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ small a {
/* Specific styles */
div[tool="mkdocs-material"] {
--addons-flyout-font-size: 0.65rem;
line-height: 0.8rem;
}

div[tool="antora"] {
--addons-flyout-font-size: 0.7rem;
line-height: 0.9rem;
}

div[tool="mdbook"] {
Expand All @@ -169,3 +175,8 @@ div[tool="mdbook"] {
div[tool="sphinx"][tool-theme="furo"] {
--addons-flyout-font-size: 0.75rem;
}

div[tool="sphinx"][tool-theme="immaterial"] {
--addons-flyout-font-size: 0.65rem;
line-height: 0.8rem;
}
32 changes: 31 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
SPHINX_FURO,
SPHINX_ALABASTER,
SPHINX_READTHEDOCS,
SPHINX_IMMATERIAL,
MDBOOK,
MKDOCS,
MKDOCS_MATERIAL,
Expand Down Expand Up @@ -420,6 +421,10 @@ export class DocumentationTool {
return MDBOOK;
}

if (this.isAntora()) {
return ANTORA;
}

console.debug("We were not able to detect the documentation tool.");
return null;
}
Expand All @@ -435,13 +440,25 @@ export class DocumentationTool {
return SPHINX_READTHEDOCS;
} else if (this.isSphinxFuroLikeTheme()) {
return SPHINX_FURO;
} else if (this.isSphinxImmaterialLikeTheme()) {
return SPHINX_IMMATERIAL;
}
}

// TODO: add the other known themes
return null;
}

isAntora() {
if (
document.querySelectorAll('meta[name="generator"][content^="Antora"]')
.length
) {
return true;
}
return false;
}

isMdBook() {
// <head>
// <!-- Book generated using mdBook -->
Expand Down Expand Up @@ -469,7 +486,8 @@ export class DocumentationTool {
this.isSphinxAlabasterLikeTheme() ||
this.isSphinxReadTheDocsLikeTheme() ||
this.isSphinxFuroLikeTheme() ||
this.isSphinxBookThemeLikeTheme()
this.isSphinxBookThemeLikeTheme() ||
this.isSphinxImmaterialLikeTheme()
);
}

Expand Down Expand Up @@ -573,6 +591,18 @@ export class DocumentationTool {
return false;
}

isSphinxImmaterialLikeTheme() {
if (
document.querySelectorAll(
'link[href^="_static/sphinx_immaterial_theme"]',
'a[href="https://github.com/jbms/sphinx-immaterial/"][rel="noopener"]',
).length
) {
return true;
}
return false;
}

isMaterialMkDocsTheme() {
if (
document.querySelectorAll(
Expand Down

0 comments on commit 28bb43c

Please sign in to comment.