From cd255696f0fcfa74a85ba532e0a8356703ce011d Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Wed, 2 Jul 2025 08:30:56 +0200 Subject: [PATCH] rework documentation launch --- src/utils/documentation.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/utils/documentation.py b/src/utils/documentation.py index 2e41721..fa70640 100644 --- a/src/utils/documentation.py +++ b/src/utils/documentation.py @@ -1,5 +1,28 @@ import os import sys +from pyramid.config import Configurator +from wsgiref.simple_server import make_server + +docport = 8000 + + +def website(): + config = Configurator() + + # Set up static file serving from the 'site/' directory + config.add_static_view( + name="/", path=os.path.join(os.getcwd(), "site"), cache_max_age=3600 + ) + + app = config.make_wsgi_app() + return app + + +def launch_documentation(): + app = website() + server = make_server("localhost", docport, app) + print("Serving MkDocs documentation on http://0.0.0.0:{}".format(docport)) + server.serve_forever() def run_mkdocs(): @@ -9,7 +32,9 @@ def run_mkdocs(): sys.stdout = devnull sys.stderr = devnull try: - os.system("mkdocs serve -q") + launch_documentation() + except Exception as e: + print("Error occurred while launching documentation:", e) finally: sys.stdout = old_stdout sys.stderr = old_stderr