From db1c59bd1eaa686225dfce11b0d119d777e0b58b Mon Sep 17 00:00:00 2001 From: zihang Date: Fri, 13 Dec 2024 16:29:02 +0800 Subject: [PATCH] fix: allow failure when moonc is missing --- next/_ext/check.py | 17 ++++++++++++----- next/_ext/indent.py | 4 +++- next/conf.py | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/next/_ext/check.py b/next/_ext/check.py index f826f736..eeb89fcb 100644 --- a/next/_ext/check.py +++ b/next/_ext/check.py @@ -8,12 +8,19 @@ logger = logging.getLogger(__name__) def setup(app: Sphinx) -> ExtensionMetadata: - result = subprocess.run(["moonc", '-v'], capture_output=True) - if result.returncode != 0: + metadata = { + "version": "0.1.0", + "parallel_read_safe": True, + "parallel_write_safe": True, + } + try: + result = subprocess.run(["moonc", '-v'], capture_output=True, check=True) + except (FileNotFoundError, subprocess.CalledProcessError): logger.warning("moonbit compiler is missing! No code check performed") - else: - logger.info(f"moonc version: {result.stdout.decode().strip()}") - app.connect("doctree-read", source_read_handler) + return metadata + logger.info(f"moonc version: {result.stdout.decode().strip()}") + app.connect("doctree-read", source_read_handler) + return metadata class Visitor(NodeVisitor): def visit_literal_block(self, node : Node): diff --git a/next/_ext/indent.py b/next/_ext/indent.py index 9b775022..d1780673 100644 --- a/next/_ext/indent.py +++ b/next/_ext/indent.py @@ -9,4 +9,6 @@ def __init__(self, s, _): def __radd__(self, _): return f"```\n{self.s}\n```" -i18n.indent = ModifiedIndent \ No newline at end of file +i18n.indent = ModifiedIndent + +def setup(_app): pass \ No newline at end of file diff --git a/next/conf.py b/next/conf.py index 58336500..7737fd9f 100644 --- a/next/conf.py +++ b/next/conf.py @@ -27,7 +27,7 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output html_theme = 'sphinx_book_theme' -html_static_path = ['_static'] +# html_static_path = ['_static'] html_theme_options = { "repository_url": "https://github.com/moonbitlang/moonbit-docs/", "path_to_docs": "next",