From 131712a6f17ee8088400b0457bc44b37d79c6086 Mon Sep 17 00:00:00 2001
From: Matthias Bussonnier <bussonniermatthias@gmail.com>
Date: Thu, 2 Nov 2023 16:18:41 +0100
Subject: [PATCH] Move templates to a subfolder.

This make the structure a tiny bit cleaner.
---
 papyri/render.py                       | 15 +++++++--------
 papyri/{ => templates}/404.tpl.j2      |  0
 papyri/{ => templates}/ascii.tpl.j2    |  0
 papyri/{ => templates}/examples.tpl.j2 |  0
 papyri/{ => templates}/gallery.tpl.j2  |  0
 papyri/{ => templates}/graph.tpl.j2    |  0
 papyri/{ => templates}/head.tpl.j2     |  0
 papyri/{ => templates}/html.tpl.j2     |  0
 papyri/{ => templates}/index.tpl.j2    |  0
 papyri/{ => templates}/macros.tpl.j2   |  0
 papyri/{ => templates}/root.tpl.j2     |  0
 papyri/{ => templates}/skeleton.tpl.j2 |  0
 papyri/{ => templates}/toctree.tpl.j2  |  0
 papyri/{ => templates}/virtual.j2      |  0
 14 files changed, 7 insertions(+), 8 deletions(-)
 rename papyri/{ => templates}/404.tpl.j2 (100%)
 rename papyri/{ => templates}/ascii.tpl.j2 (100%)
 rename papyri/{ => templates}/examples.tpl.j2 (100%)
 rename papyri/{ => templates}/gallery.tpl.j2 (100%)
 rename papyri/{ => templates}/graph.tpl.j2 (100%)
 rename papyri/{ => templates}/head.tpl.j2 (100%)
 rename papyri/{ => templates}/html.tpl.j2 (100%)
 rename papyri/{ => templates}/index.tpl.j2 (100%)
 rename papyri/{ => templates}/macros.tpl.j2 (100%)
 rename papyri/{ => templates}/root.tpl.j2 (100%)
 rename papyri/{ => templates}/skeleton.tpl.j2 (100%)
 rename papyri/{ => templates}/toctree.tpl.j2 (100%)
 rename papyri/{ => templates}/virtual.j2 (100%)

diff --git a/papyri/render.py b/papyri/render.py
index 66955c59..015e7cf0 100644
--- a/papyri/render.py
+++ b/papyri/render.py
@@ -1,7 +1,7 @@
 import builtins
-import math
 import json
 import logging
+import math
 import operator
 import os
 import random
@@ -11,12 +11,12 @@
 from dataclasses import dataclass
 from functools import lru_cache
 from pathlib import Path
-from typing import Optional, Set, Any, Dict, List, Callable, Tuple, Iterable
+from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple
 
 from flatlatex import converter
 from jinja2 import Environment, FileSystemLoader, StrictUndefined, select_autoescape
 from pygments.formatters import HtmlFormatter
-from quart import send_from_directory, Response, redirect
+from quart import Response, redirect, send_from_directory
 from quart_trio import QuartTrio
 from rich.logging import RichHandler
 
@@ -31,10 +31,9 @@
 from .crosslink import IngestedBlobs, find_all_refs
 from .graphstore import GraphStore, Key
 from .myst_ast import MLink, MText
-from .take2 import RefInfo, encoder, Section
+from .take2 import RefInfo, Section, encoder
 from .tree import TreeReplacer, TreeVisitor
-from .utils import progress, dummy_progress
-
+from .utils import dummy_progress, progress
 
 FORMAT = "%(message)s"
 logging.basicConfig(
@@ -212,7 +211,7 @@ def __init__(self, store: GraphStore, *, sidebar, prefix, trailing_html):
         self.progress = progress
         self.store = store
         self.env = Environment(
-            loader=FileSystemLoader(os.path.dirname(__file__)),
+            loader=FileSystemLoader(Path(os.path.dirname(__file__)) / "templates"),
             autoescape=select_autoescape(["html", "tpl.j2"]),
             undefined=StrictUndefined,
         )
@@ -1217,7 +1216,7 @@ def old_render_one(
 @lru_cache
 def _ascii_env():
     env = Environment(
-        loader=CleanLoader(os.path.dirname(__file__)),
+        loader=CleanLoader(Path(os.path.dirname(__file__)) / "templates"),
         lstrip_blocks=True,
         trim_blocks=True,
         undefined=StrictUndefined,
diff --git a/papyri/404.tpl.j2 b/papyri/templates/404.tpl.j2
similarity index 100%
rename from papyri/404.tpl.j2
rename to papyri/templates/404.tpl.j2
diff --git a/papyri/ascii.tpl.j2 b/papyri/templates/ascii.tpl.j2
similarity index 100%
rename from papyri/ascii.tpl.j2
rename to papyri/templates/ascii.tpl.j2
diff --git a/papyri/examples.tpl.j2 b/papyri/templates/examples.tpl.j2
similarity index 100%
rename from papyri/examples.tpl.j2
rename to papyri/templates/examples.tpl.j2
diff --git a/papyri/gallery.tpl.j2 b/papyri/templates/gallery.tpl.j2
similarity index 100%
rename from papyri/gallery.tpl.j2
rename to papyri/templates/gallery.tpl.j2
diff --git a/papyri/graph.tpl.j2 b/papyri/templates/graph.tpl.j2
similarity index 100%
rename from papyri/graph.tpl.j2
rename to papyri/templates/graph.tpl.j2
diff --git a/papyri/head.tpl.j2 b/papyri/templates/head.tpl.j2
similarity index 100%
rename from papyri/head.tpl.j2
rename to papyri/templates/head.tpl.j2
diff --git a/papyri/html.tpl.j2 b/papyri/templates/html.tpl.j2
similarity index 100%
rename from papyri/html.tpl.j2
rename to papyri/templates/html.tpl.j2
diff --git a/papyri/index.tpl.j2 b/papyri/templates/index.tpl.j2
similarity index 100%
rename from papyri/index.tpl.j2
rename to papyri/templates/index.tpl.j2
diff --git a/papyri/macros.tpl.j2 b/papyri/templates/macros.tpl.j2
similarity index 100%
rename from papyri/macros.tpl.j2
rename to papyri/templates/macros.tpl.j2
diff --git a/papyri/root.tpl.j2 b/papyri/templates/root.tpl.j2
similarity index 100%
rename from papyri/root.tpl.j2
rename to papyri/templates/root.tpl.j2
diff --git a/papyri/skeleton.tpl.j2 b/papyri/templates/skeleton.tpl.j2
similarity index 100%
rename from papyri/skeleton.tpl.j2
rename to papyri/templates/skeleton.tpl.j2
diff --git a/papyri/toctree.tpl.j2 b/papyri/templates/toctree.tpl.j2
similarity index 100%
rename from papyri/toctree.tpl.j2
rename to papyri/templates/toctree.tpl.j2
diff --git a/papyri/virtual.j2 b/papyri/templates/virtual.j2
similarity index 100%
rename from papyri/virtual.j2
rename to papyri/templates/virtual.j2