Skip to content
Open
19 changes: 15 additions & 4 deletions sphinx_simplepdf/builders/simplepdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
from typing import Any, Dict
import subprocess
from importlib import import_module
import weasyprint

import sass
Expand Down Expand Up @@ -44,7 +45,7 @@ def __init__(self, *args, **kwargs):

debug_sphinx = {
"version": __version__,
"confidr": self.app.confdir,
"confdir": self.app.confdir,
"srcdir": self.app.srcdir,
"outdir": self.app.outdir,
"extensions": self.app.config.extensions,
Expand All @@ -55,9 +56,19 @@ def __init__(self, *args, **kwargs):
# Generate main.css
logger.info("Generating css files from scss-templates")
css_folder = os.path.join(self.app.outdir, f"_static")
scss_folder = os.path.join(
os.path.dirname(__file__), "..", "themes", "simplepdf_theme", "static", "styles", "sources"
)

theme_folder = os.path.join(os.path.dirname(__file__), "..", "themes", "simplepdf_theme")

if self.app.config.simplepdf_theme is not None:
try:
theme_folder = os.path.dirname(import_module(self.app.config.html_theme).__file__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be simplepdf_theme instead of html_theme?

except ImportError:
logger.warning(f"Could not import {self.app.config.html_theme}")
# use built-in theme
pass

scss_folder = os.path.join(theme_folder, "static", "styles", "sources")

sass.compile(
dirname=(scss_folder, css_folder),
output_style="nested",
Expand Down