Skip to content

Commit

Permalink
Bump up version to 0.4.7 (#15) Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaprieto authored Dec 5, 2024
1 parent 4bea8e6 commit 61308c1
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 101 deletions.
6 changes: 3 additions & 3 deletions mkdocs_juvix/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ENV:

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

JUVIX_ENABLED: bool = bool(getenv("JUVIX_ENABLED", True))
PROCESS_JUVIX: bool = bool(getenv("PROCESS_JUVIX", False))
JUVIX_FULL_VERSION: str
JUVIX_BIN_NAME: str = getenv("JUVIX_BIN", "juvix")
JUVIX_BIN_PATH: str = getenv("JUVIX_PATH", "")
Expand Down Expand Up @@ -243,7 +243,7 @@ def __init__(self, config: Optional[MkDocsConfig] = None):
log.debug(
"Juvix version not found. Make sure Juvix is installed, for now support for Juvix Markdown is disabled."
)
self.JUVIX_ENABLED = False
self.PROCESS_JUVIX = False
self.JUVIX_AVAILABLE = False

return
Expand All @@ -264,7 +264,7 @@ def __init__(self, config: Optional[MkDocsConfig] = None):

@property
def juvix_enabled(self) -> bool:
return self.JUVIX_ENABLED and self.JUVIX_AVAILABLE
return self.PROCESS_JUVIX and self.JUVIX_AVAILABLE

@staticmethod
def when_juvix_enabled(func):
Expand Down
7 changes: 2 additions & 5 deletions mkdocs_juvix/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from mkdocs_juvix.common.preprocesors.links import WLPreprocessor
from mkdocs_juvix.common.utils import fix_site_url, get_page_title
from mkdocs_juvix.env import ENV
from mkdocs_juvix.logger import clear_line, clear_screen, log
from mkdocs_juvix.logger import log

files_relation: List[ResultEntry] = []
EXCLUDED_DIRS = [
Expand Down Expand Up @@ -117,7 +117,6 @@ def on_pre_build(self, config: MkDocsConfig) -> None:
config["nodes"][url]["page"]["names"].append(page)
node_index += 1
pbar.update(1)
clear_line()

if self.NODES_JSON.exists():
self.NODES_JSON.unlink()
Expand Down Expand Up @@ -168,14 +167,12 @@ def process_file(file: File) -> None:
url = urljoin(config.get("site_url", ""), file.url)
config["url_for"][_title] = [url]
config["aliases_for"][url] = [_title]
clear_screen()

with sync_tqdm(total=len(files), desc="> processing files") as pbar:
for file in files:
if file.is_documentation_page():
process_file(file)
pbar.update(1)
clear_line()

if self.LINKS_JSON.exists():
self.LINKS_JSON.unlink()

Expand Down
31 changes: 3 additions & 28 deletions mkdocs_juvix/logger.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
import os
import logging
from typing import Any, MutableMapping
from colorama import Fore, Style # type: ignore

DEBUG = os.getenv("DEBUG", "false").lower() == "true"
print(f"{Fore.GREEN}DEBUG: {DEBUG}")

class Logger(logging.Logger):
def __init__(self, logger: logging.Logger):
self.logger = logger
super().__init__(logger.name, logger.level)

def info(self, msg, *args, **kwargs):
if DEBUG:
self.debug(msg, *args, **kwargs)
else:
super().info(msg, *args, **kwargs)

def debug(self, msg, *args, **kwargs):
if DEBUG:
print("-"*100)
print(msg, *args, **kwargs)
clear_line(2)
else:
super().debug(msg, *args, **kwargs)
log = logging.getLogger("mkdocs.plugins.juvix")

def get_plugin_logger(name: str) -> Logger:
logger = logging.getLogger(f"mkdocs.plugins.{name}")
setattr(logger, "info", lambda msg: getattr(logger, "info")(msg))
return Logger(logger)

log = get_plugin_logger(f"{Fore.BLUE}juvix_mkdocs{Style.RESET_ALL}")
DEBUG = bool(os.getenv("DEBUG", "false").lower()) == "true"
print(f"{Fore.GREEN}DEBUG: {DEBUG}")

def clear_screen():
if os.getenv("DEBUG", "false").lower() != "true":
Expand Down
Loading

0 comments on commit 61308c1

Please sign in to comment.