Pi66

Home | Repos | About | Blog | Gaza

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

About | Files | Commits | Refs | License


refactor: move `init_config_struct()` to config.py

Author: pi66
Date: 2026-06-27 11:06
commit: 31826b65

Stat

M src/config.py 29 +28 -1
M src/init_project.py 26 +1 -25

Diff

diff --git a/src/config.py b/src/config.py
index 8ca60a4..7d5ccf3 100644
--- a/src/config.py
+++ b/src/config.py
@@ -4,7 +4,34 @@ from tomllib import loads

from .fileops import read_file from .log import GRAY -from .modules import Config, Tree, Webview +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( ...

Show all

diff --git a/src/config.py b/src/config.py
index 8ca60a4..7d5ccf3 100644
--- a/src/config.py
+++ b/src/config.py
@@ -4,7 +4,34 @@ from tomllib import loads

from .fileops import read_file from .log import GRAY -from .modules import Config, Tree, Webview +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, + html_path = "/", + static_path = "/static" + ), + extras= Extras( + highlight = "monokai" + ) + ) +

def render_config(config:Config) -> str: return f"""[project] diff --git a/src/init_project.py b/src/init_project.py index 06007f6..ca90465 100644 --- a/src/init_project.py +++ b/src/init_project.py @@ -5,31 +5,7 @@ from .log import * from .errors import fatal from .templates import * from .fileops import * -from .config import 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, - html_path = "/", - static_path = "/static" - ) - ) +from .config import init_config_struct, render_config

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

// Created by Pi66

// Copyright ©Pi66 2026