Skip to content

Commit

Permalink
Bump up v0.4.8: create cache folder depending on the PROCESS_JUVIX en…
Browse files Browse the repository at this point in the history
…v variable
  • Loading branch information
jonaprieto committed Dec 5, 2024
1 parent 61308c1 commit 441ea2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions mkdocs_juvix/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ENV:
ROOT_PATH: Path
DOCS_DIRNAME: str = getenv("DOCS_DIRNAME", "docs")
DOCS_PATH: Path
CACHE_DIRNAME: str = getenv("CACHE_DIRNAME", ".cache-juvix-mkdocs")
CACHE_DIRNAME: str
CACHE_PATH: Path
DIFF_ENABLED: bool
DIFF_BIN: str
Expand All @@ -49,7 +49,6 @@ class ENV:
TIMELIMIT: int = int(getenv("TIMELIMIT", 10))

REMOVE_CACHE: bool = bool(getenv("REMOVE_CACHE", False))

PROCESS_JUVIX: bool = bool(getenv("PROCESS_JUVIX", False))
JUVIX_FULL_VERSION: str
JUVIX_BIN_NAME: str = getenv("JUVIX_BIN", "juvix")
Expand Down Expand Up @@ -118,6 +117,10 @@ def __init__(self, config: Optional[MkDocsConfig] = None):
self.ROOT_PATH = Path(".").resolve()

self.ROOT_ABSPATH = self.ROOT_PATH.absolute()
if self.PROCESS_JUVIX:
self.CACHE_DIRNAME = getenv("CACHE_DIRNAME", ".cache-mkdocs-with-juvix-processing")
else:
self.CACHE_DIRNAME = getenv("CACHE_DIRNAME", ".cache-mkdocs-without-juvix-processing")
self.CACHE_ABSPATH = self.ROOT_ABSPATH / self.CACHE_DIRNAME

self.DOCS_PATH = self.ROOT_PATH / self.DOCS_DIRNAME
Expand Down Expand Up @@ -366,12 +369,18 @@ def compute_processed_filepath(
return processed_path

def unqualified_module_name(self, filepath: Path) -> Optional[str]:
log.debug(f"Computing unqualified module name for {filepath}")
if not self.juvix_enabled:
log.debug("Juvix is not enabled, returning None")
return None
fposix: str = filepath.as_posix()
if not fposix.endswith(".juvix.md"):
return None
return os.path.basename(fposix).replace(".juvix.md", "")

def qualified_module_name(self, filepath: Path) -> Optional[str]:
if not self.juvix_enabled:
return None
absolute_path = filepath.absolute()
cmd = [self.JUVIX_BIN, "dev", "root", absolute_path.as_posix()]
pp = subprocess.run(cmd, cwd=self.DOCS_ABSPATH, capture_output=True)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mkdocs-juvix-plugin"
version = "0.4.7"
version = "0.4.8"
description = "MkDocs documentation with support for Juvix Markdown files"
authors = ["Jonathan Prieto-Cubides, and GitHub contributors"]
license = "MIT"
Expand Down

0 comments on commit 441ea2e

Please sign in to comment.