Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plugin.py to accept style path from config #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 6 additions & 5 deletions mkdocs_extra_sass_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from bs4 import BeautifulSoup
from livereload import Server
from mkdocs.config import Config
from mkdocs.config import config_options
from mkdocs.plugins import BasePlugin
from mkdocs.structure.pages import Page
from mkdocs.utils import normalize_url
Expand All @@ -18,7 +19,6 @@

_logger = logging.getLogger('mkdocs.extra-sass')


class ExtraSassPlugin(BasePlugin):
"""Extra Sass Plugin"""

Expand Down Expand Up @@ -66,7 +66,8 @@ def _entry_point(self, config: Config) -> _T_SassEntry:
return self.__entry_point

def _build_entry(self, config: Config) -> _T_SassEntry:
entry_point = _SassEntry.search_entry_point()
style_path = config["extra"].get("extra_sass_path") if config["extra"].get("extra_sass_path") else "extra_sass"
entry_point = _SassEntry.search_entry_point(style_path)
if entry_point.is_available:
try:
site_dir = config["site_dir"]
Expand All @@ -90,15 +91,15 @@ def _build_entry(self, config: Config) -> _T_SassEntry:

class _SassEntry(ABC):

_styles_dir = 'extra_sass'
_style_filenames = [
'style.css.sass', 'style.sass',
'style.css.scss', 'style.scss',
]

@classmethod
def search_entry_point(cls: Type[_T_SassEntry]) -> _T_SassEntry:
d = cls._styles_dir
def search_entry_point(cls: Type[_T_SassEntry], style_dir) -> _T_SassEntry:
_logger.info(style_dir)
d = style_dir
if os.path.isdir(d):
for f in cls._style_filenames:
path = os.path.join(d, f)
Expand Down