Skip to content

Commit 893f0cf

Browse files
committed
fixup! feat: add docstring prompt
1 parent 8d4d22c commit 893f0cf

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/git_draft/prompt.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ class TemplatedPrompt:
1616

1717
@classmethod
1818
def parse(cls, name: str, *args: str) -> Self:
19+
"""Parse arguments into a TemplatedPrompt.
20+
21+
Args:
22+
name: The name of the template.
23+
*args: Additional arguments for context, expected in 'key=value' format.
24+
"""
1925
return cls(name, dict(e.split("=", 1) for e in args))
2026

2127

2228
class PromptRenderer:
29+
"""Renderer for prompt templates using Jinja2"""
30+
2331
def __init__(self, env: jinja2.Environment) -> None:
2432
self._environment = env
2533

2634
@classmethod
27-
def for_repo(cls, repo: git.Repo):
35+
def for_repo(cls, repo: git.Repo) -> Self:
2836
env = jinja2.Environment(
2937
auto_reload=False,
3038
autoescape=False,
@@ -35,7 +43,7 @@ def for_repo(cls, repo: git.Repo):
3543
undefined=jinja2.StrictUndefined,
3644
)
3745
env.globals["repo"] = {
38-
"file_paths": repo.git.ls_files(),
46+
"file_paths": repo.git.ls_files().splitlines(),
3947
}
4048
return cls(env)
4149

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
For reference, here is the list of all currently available files in the
22
repository:
33

4-
{% for path in repo.file_paths %}
4+
{% for path in repo.file_paths -%}
55
* {{ path }}
66
{% endfor %}

0 commit comments

Comments
 (0)