Pi66

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

← back to log

refactor: move init_config_struct/render_config into init_project

author: pi66
date: 2026-07-04 22:58
hash: 80ff18e47907eb998aef1fc40e273b892c0e3829

Diffstat:

M

src/config.py
50 ----------------------------

M

src/init_project.py
54 +++++++++++++++++++++++++++++-
  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
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
diff --git a/src/config.py b/src/config.py
index f69845d..6bcfc80 100644
--- a/src/config.py
+++ b/src/config.py
@@ -5,56 +5,6 @@ from .fileops import read_file
 from .log import GRAY
 from .modules import Config, Extras, Project, Tree, Webview

-def init_config_struct(project_name:str) -> Config:
-    """Build a Config with default values for a newly initialized project."""
-    return Config(
-        project=Project(
-            name        = project_name,
-            version     = "0.1.0",
-            description = "Add your description here",
-        ),
-        tree = Tree(
-            markdown  = "src/md",
-            static    = "src/static",
-            templates = "src/templates",
-            dest      = "src/dest",
-            plugins   = "src/plugins.py",
-        ),
-        webview = Webview(
-            host        = "localhost",
-            port        = 8866,
-            dev_tools   = False,
-            html_path   = "/",
-            static_path = "/static"
-        ),
-        extras = Extras(
-            highlight = "monokai"
-        )
-    )
-
-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}
-dev_tools   = {str(config.webview.dev_tools).lower()}
-html_path   = "{config.webview.html_path}"
-static_path = "{config.webview.static_path}"
-
-[extras]
-highlight = "{config.extras.highlight}"
-"""

 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 d4698bb..c4c379c 100644
--- a/src/init_project.py
+++ b/src/init_project.py
@@ -1,11 +1,61 @@
 from os import path, getcwd, makedirs

-from .modules import Config, Project, Tree, Webview
+from .modules import Config, Project, Tree, Webview, Extras
 from .log import *
 from .errors import fatal
 from .templates import *
 from .fileops import *
-from .config import init_config_struct, render_config
+
+def init_config_struct(project_name:str) -> Config:
+    """Build a Config with default values for a newly initialized project."""
+    return Config(
+        project=Project(
+            name        = project_name,
+            version     = "0.1.0",
+            description = "Add your description here",
+        ),
+        tree = Tree(
+            markdown  = "src/md",
+            static    = "src/static",
+            templates = "src/templates",
+            dest      = "src/dest",
+            plugins   = "src/plugins.py",
+        ),
+        webview = Webview(
+            host        = "localhost",
+            port        = 8866,
+            dev_tools   = False,
+            html_path   = "/",
+            static_path = "/static"
+        ),
+        extras = Extras(
+            highlight = "monokai"
+        )
+    )
+
+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}
+dev_tools   = {str(config.webview.dev_tools).lower()}
+html_path   = "{config.webview.html_path}"
+static_path = "{config.webview.static_path}"
+
+[extras]
+highlight = "{config.extras.highlight}"
+"""

 def check_not_already_initialized(file_path:str) -> None:
     """raise FileExistsError when config file exists"""