Skip to content

configuration management via toml #2

@kjaymiller

Description

@kjaymiller

Issue: Basic Configuration Reading API

Summary

Create a simple API to read site_module and editor settings from [tool.render-engine] in pyproject.toml for use by CLI and TUI tools.

Current State

CLI Implementation (render_engine_cli.utils.CliConfig)

@dataclass
class CliConfig:
    """Handles loading and storing the config from disk"""
    _module_site: str = None
    _collection: str = None
    _editor: str = None

    def load_config(self, config_file: str = "pyproject.toml"):
        """Load config from [tool.render-engine.cli]"""

TUI Implementation

Currently reads inline from pyproject.toml in SiteLoader

Proposed API

Create render_engine_api.config with:

class RenderEngineConfig:
    """Simple configuration reader for render-engine tools."""

    def __init__(self, project_root: Optional[Path] = None):
        """Initialize from project root or cwd."""

    def get_site_module(self) -> str:
        """Get site_module from [tool.render-engine].

        Returns:
            Site module path (e.g., "app.site")

        Raises:
            ConfigError: If site_module not found
        """

    def get_editor(self) -> Optional[str]:
        """Get configured editor or fallback to $EDITOR env var."""

Configuration Schema

[tool.render-engine]
site_module = "app.site"  # Required: module path to Site instance
editor = "vim"  # Optional: falls back to $EDITOR env var

Benefits

  1. Simplicity: Single source of truth for basic config
  2. Consistency: All tools read config the same way
  3. Type Safety: Proper typing and validation

Migration Path

  1. Create render_engine_api.config.RenderEngineConfig
  2. Update CLI to use RenderEngineConfig
  3. Update TUI SiteLoader to use RenderEngineConfig

Dependencies

  • tomllib (Python 3.11+) or tomli (Python 3.10)
  • Must not depend on CLI or TUI packages (pure API)

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions