1010
1111
1212def get_package_dir () -> Path :
13- """Get the package directory."""
13+ """Get the package directory.
14+
15+ Returns:
16+ The path to the package directory.
17+
18+ """
1419 return Path (__file__ ).parent
1520
1621
1722def get_template_env (template_dir : Path ) -> Environment :
18- """Create a Jinja2 environment for the given template directory."""
23+ """Create a Jinja2 environment for the given template directory.
24+
25+ Args:
26+ template_dir: The directory containing the templates.
27+
28+ Returns:
29+ A configured Jinja2 environment.
30+
31+ """
1932 return Environment (
2033 loader = FileSystemLoader (str (template_dir )),
2134 autoescape = select_autoescape (default = False ),
@@ -26,7 +39,15 @@ def get_template_env(template_dir: Path) -> Environment:
2639
2740
2841def slugify (text : str ) -> str :
29- """Convert text to a valid Python package name."""
42+ """Convert text to a valid Python package name.
43+
44+ Args:
45+ text: The text to slugify.
46+
47+ Returns:
48+ The slugified text.
49+
50+ """
3051 # Convert to lowercase
3152 text = text .lower ()
3253 # Replace spaces and hyphens with underscores
@@ -40,7 +61,15 @@ def slugify(text: str) -> str:
4061
4162
4263def validate_project_name (name : str ) -> str | None :
43- """Validate project name. Returns error message or None if valid."""
64+ """Validate project name. Returns error message or None if valid.
65+
66+ Args:
67+ name: The project name to validate.
68+
69+ Returns:
70+ An error message if the name is invalid, otherwise None.
71+
72+ """
4473 if not name :
4574 return "Project name cannot be empty"
4675 if len (name ) < MIN_PROJECT_NAME_LENGTH :
@@ -66,6 +95,16 @@ def write_file(path: Path, content: str) -> None:
6695
6796
6897def render_template (env : Environment , template_name : str , context : dict ) -> str :
69- """Render a Jinja2 template with the given context."""
98+ """Render a Jinja2 template with the given context.
99+
100+ Args:
101+ env: The Jinja2 environment.
102+ template_name: The name of the template to render.
103+ context: The context dictionary to render the template with.
104+
105+ Returns:
106+ The rendered template string.
107+
108+ """
70109 template = env .get_template (template_name )
71110 return template .render (** context )
0 commit comments