From 9ab7da31f5506250ab51254877c01489df576e8c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se>
Date: Mon, 26 Jun 2023 19:33:57 +0200
Subject: [PATCH] Upstream markdown files now rendered within template.

---
 muppet/output.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/muppet/output.py b/muppet/output.py
index 676bbb4..242b3b5 100644
--- a/muppet/output.py
+++ b/muppet/output.py
@@ -352,14 +352,22 @@ def setup_module(base: str, module: ModuleEntry, *, path_base: str) -> None:
         name, _ = os.path.splitext(filename)
         with open(filepath) as f:
             raw_content = f.read()
-        content = commonmark(raw_content)
 
-        out_path = os.path.join(path, f'{name}.html')
+        pathlib.Path(os.path.join(path, name)).mkdir(exist_ok=True)
+        out_path = os.path.join(path, name, 'index.html')
+
+        content = commonmark(raw_content)
+        template = jinja.get_template('content.html')
+        crumbs = breadcrumbs(('Environment', ''),
+                             module.name,
+                             name)
 
         with open(out_path, 'w') as f:
-            f.write(content)
+            f.write(template.render(content=content,
+                                    path_base=path_base,
+                                    breadcrumbs=crumbs))
 
-        doc_files[name] = os.path.join(module.name, f'{name}.html')
+        doc_files[name] = os.path.join(module.name, name, 'index.html')
 
     setup_module_index(base=path,
                        module=module,
-- 
GitLab