Skip to content

Commit eba6b4a

Browse files
committed
Add a new title template variable
This will be useful when generating the documentation, as we need a pretty name for the project for the website title for example, but this could be used in other places where a pretty, human readable, name is needed. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 80e52f7 commit eba6b4a

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

cookiecutter/cookiecutter.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
],
99
"name": null,
1010
"description": null,
11+
"title": "{{cookiecutter | title}}",
1112
"keywords": "(comma separated: 'frequenz', <type> and <name> are included automatically)",
1213
"github_org": "frequenz-floss",
1314
"license": [
@@ -26,6 +27,7 @@
2627
"local_extensions.github_repo_name",
2728
"local_extensions.keywords",
2829
"local_extensions.pypi_package_name",
29-
"local_extensions.python_package"
30+
"local_extensions.python_package",
31+
"local_extensions.title"
3032
]
3133
}

cookiecutter/local_extensions.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,31 @@ def github_repo_name(cookiecutter: dict[str, str]) -> str:
8282
return f"{pypi}{end}"
8383

8484

85+
@_simple_filter # type: ignore[misc]
86+
def title(cookiecutter: dict[str, str]) -> str:
87+
"""Build a default mkdocs site name for the project.
88+
89+
Args:
90+
cookiecutter: The cookiecutter context.
91+
92+
Returns:
93+
The default site name.
94+
"""
95+
match cookiecutter["type"]:
96+
case "actor":
97+
return f"Frequenz {cookiecutter['name']} actor"
98+
case "api":
99+
return f"Frequenz {cookiecutter['name']} API"
100+
case "lib":
101+
return f"Freqenz {cookiecutter['name']} library"
102+
case "app":
103+
return f"Frequenz {cookiecutter['name']} app"
104+
case "model":
105+
return f"Frequenz {cookiecutter['name']} AI model"
106+
case _ as repo_type:
107+
assert False, f"Unhandled repository type {repo_type!r}"
108+
109+
85110
@_simple_filter # type: ignore[misc]
86111
def keywords(cookiecutter: dict[str, str]) -> str:
87112
"""Extend cookiecutter["keywords"] with predefined ones by repository type.

0 commit comments

Comments
 (0)