Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

refactor: move render_config to config.py

author: pi66
date: 2026-06-27 10:51
hash: e8182fb5dc5f7e5046295449084c7515c87f1dbb

Diffstat:

M

src/config.py
21 +++++++++++++++++++++++++++++-

M

src/init_project.py
21 +++---------------------------
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
diff --git a/src/config.py b/src/config.py
index a1b2933..8ca60a4 100644
--- a/src/config.py
+++ b/src/config.py
@@ -4,8 +4,27 @@ from tomllib import loads

 from .fileops import read_file
 from .log import GRAY
-from .modules import Tree, Webview
+from .modules import Config, Tree, Webview

+def render_config(config:Config) -> str:
+    return f"""[project]
+name        = "{config.project.name}"
+version     = "{config.project.version}"
+description = "{config.project.description}"
+
+[tree]
+markdown  = "{config.tree.markdown}"
+static    = "{config.tree.static}"
+templates = "{config.tree.templates}"
+dest      = "{config.tree.dest}"
+plugins   = "{config.tree.plugins}"
+
+[webview]
+host  = "{config.webview.host}"
+port  = {config.webview.port}
+html_path   = "{config.webview.html_path}"
+static_path = "{config.webview.static_path}"
+"""

 def find_project_from_path(project_path: str):
     if not path.exists(project_path):
diff --git a/src/init_project.py b/src/init_project.py
index aa1523d..06007f6 100644
--- a/src/init_project.py
+++ b/src/init_project.py
@@ -1,29 +1,12 @@
 from os import path, getcwd, makedirs
+
 from .modules import Config, Project, Tree, Webview
 from .log import *
 from .errors import fatal
 from .templates import *
 from .fileops import *
+from .config import render_config

-def render_config(config:Config) -> str:
-    return f"""[project]
-name        = "{config.project.name}"
-version     = "{config.project.version}"
-description = "{config.project.description}"
-
-[tree]
-markdown  = "{config.tree.markdown}"
-static    = "{config.tree.static}"
-templates = "{config.tree.templates}"
-dest      = "{config.tree.dest}"
-plugins   = "{config.tree.plugins}"
-
-[webview]
-host  = "{config.webview.host}"
-port  = {config.webview.port}
-html_path   = "{config.webview.html_path}"
-static_path = "{config.webview.static_path}"
-"""

 def init_config_struct(project_name:str) -> Config:
     """Build a Config with default values for a newly initialized project."""