Skip to content

Commit edf8aa9

Browse files
authored
refactor: use trim_blocks and lstrip_blocks to avoid unnecessary whitespace control (#814)
1 parent b6bce7d commit edf8aa9

File tree

25 files changed

+308
-312
lines changed

25 files changed

+308
-312
lines changed

copier.yaml

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
_envops:
2-
block_end_string: '%]'
3-
block_start_string: '[%'
2+
block_end_string: "%]"
3+
block_start_string: "[%"
4+
lstrip_blocks: true
5+
trim_blocks: true
46
_subdirectory: template
57
_message_before_copy: |
68
Thanks for generating a project using our template.
@@ -20,7 +22,7 @@ _message_after_update: |
2022
you're done.
2123
project_name:
2224
default: My Project
23-
help: 'Enter the name of the project in CamelCase format:'
25+
help: "Enter the name of the project in CamelCase format:"
2426
type: str
2527
project_description:
2628
default: Project brief description.
@@ -32,7 +34,7 @@ development_status:
3234
- Alpha
3335
- Beta
3436
- Production/Stable
35-
help: 'Choose the development status:'
37+
help: "Choose the development status:"
3638
type: str
3739
copyright_license:
3840
default: MIT License
@@ -53,65 +55,65 @@ copyright_year:
5355
type: str
5456
author_name:
5557
default: Your Name
56-
help: 'Specify the name of the author:'
58+
help: "Specify the name of the author:"
5759
type: str
5860
organization_name:
5961
default: Your Organization Name
60-
help: 'Provide the name of the organization associated with the project:'
62+
help: "Provide the name of the organization associated with the project:"
6163
type: str
6264
copyright_holder:
63-
default: '{{ organization_name }}'
65+
default: "{{ organization_name }}"
6466
help: Name(s) or organization(s) holding the copyright.
6567
type: str
6668
author_email:
6769
default: '{{ author_name|lower|replace(" ", ".") }}@{{ organization_name|lower|replace(" ", "-") }}.com'
68-
help: 'Specify the email address of the author:'
70+
help: "Specify the email address of the author:"
6971
type: str
7072
repo_platform:
7173
default: github
7274
choices:
7375
GitHub: github
7476
GitLab: gitlab
7577
GitLab (self-managed): gitlab-self-managed
76-
help: 'Choose the platform for the repository:'
78+
help: "Choose the platform for the repository:"
7779
type: str
7880
repo_host:
7981
default: |-
80-
[% if repo_platform == 'github' -%]
81-
github.com
82-
[%- elif repo_platform == 'gitlab' -%]
83-
gitlab.com
82+
[% if repo_platform == 'github' %]
83+
github.com
84+
[%- elif repo_platform == 'gitlab' %]
85+
gitlab.com
8486
[%- endif %]
85-
help: 'Specify the host of the self-managed GitLab:'
87+
help: "Specify the host of the self-managed GitLab:"
8688
type: str
8789
when: '{{ repo_platform == "gitlab-self-managed" }}'
8890
page_host:
8991
default: |-
90-
[% if repo_platform == 'github' -%]
91-
github.io
92-
[%- elif repo_platform == 'gitlab' -%]
93-
gitlab.io
92+
[% if repo_platform == 'github' %]
93+
github.io
94+
[%- elif repo_platform == 'gitlab' %]
95+
gitlab.io
9496
[%- endif %]
95-
help: 'Specify the host of the self-managed GitLab Pages:'
97+
help: "Specify the host of the self-managed GitLab Pages:"
9698
type: str
9799
when: '{{ repo_platform == "gitlab-self-managed" }}'
98100
container_registry_host:
99101
default: |-
100-
[% if repo_platform == 'github' -%]
101-
ghcr.io
102-
[%- elif repo_platform == 'gitlab' -%]
103-
registry.gitlab.com
102+
[% if repo_platform == 'github' %]
103+
ghcr.io
104+
[%- elif repo_platform == 'gitlab' %]
105+
registry.gitlab.com
104106
[%- endif %]
105-
help: 'Specify the host of the self-managed GitLab Container Registry:'
107+
help: "Specify the host of the self-managed GitLab Container Registry:"
106108
type: str
107109
when: '{{ repo_platform == "gitlab-self-managed" }}'
108110
repo_namespace:
109111
default: '{{ organization_name|lower|replace(" ", "-") }}'
110-
help: 'Indicate the GitHub Repository Owner or GitLab Namespace. This is typically the account name of the author or the organization:'
112+
help: "Indicate the GitHub Repository Owner or GitLab Namespace. This is typically the account name of the author or the organization:"
111113
type: str
112114
repo_name:
113115
default: '{{ project_name|lower|replace(" ", "-") }}'
114-
help: 'Provide a name for the repository:'
116+
help: "Provide a name for the repository:"
115117
type: str
116118
package_name:
117119
default: '{{ repo_name|regex_replace("-python$", "") }}'
@@ -123,7 +125,7 @@ module_name:
123125
type: str
124126
coverage_threshold:
125127
default: 100
126-
help: 'Set the threshold for test coverage, ranging from 0 to 100:'
128+
help: "Set the threshold for test coverage, ranging from 0 to 100:"
127129
type: int
128130
validator: "[% if not 0 <= coverage_threshold <= 100 %]Test Coverage threshold should be between 0 and 100[% endif %]"
129131
platforms:
@@ -136,59 +138,59 @@ platforms:
136138
multiselect: true
137139
type: str
138140
min_py:
139-
default: '3.12'
141+
default: "3.12"
140142
choices:
141-
- '3.9'
142-
- '3.10'
143-
- '3.11'
144-
- '3.12'
145-
- '3.13'
146-
help: 'Choose the minimal Python version the project should support:'
143+
- "3.9"
144+
- "3.10"
145+
- "3.11"
146+
- "3.12"
147+
- "3.13"
148+
help: "Choose the minimal Python version the project should support:"
147149
type: str
148150
max_py:
149-
default: '3.12'
151+
default: "3.12"
150152
choices:
151-
'3.9':
153+
"3.9":
152154
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_higher_than_validator %]{{ version_higher_than_validator("3.9", min_py) }}'
153-
value: '3.9'
154-
'3.10':
155+
value: "3.9"
156+
"3.10":
155157
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_higher_than_validator %]{{ version_higher_than_validator("3.10", min_py) }}'
156-
value: '3.10'
157-
'3.11':
158+
value: "3.10"
159+
"3.11":
158160
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_higher_than_validator %]{{ version_higher_than_validator("3.11", min_py) }}'
159-
value: '3.11'
160-
'3.12':
161+
value: "3.11"
162+
"3.12":
161163
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_higher_than_validator %]{{ version_higher_than_validator("3.12", min_py) }}'
162-
value: '3.12'
163-
'3.13':
164-
value: '3.13'
165-
help: 'Choose the maximal Python version the project should support:'
164+
value: "3.12"
165+
"3.13":
166+
value: "3.13"
167+
help: "Choose the maximal Python version the project should support:"
166168
type: str
167169
default_py:
168-
default: '{{ max_py }}'
170+
default: "{{ max_py }}"
169171
choices:
170-
'3.9':
172+
"3.9":
171173
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_between_validator %]{{ version_between_validator("3.9", min_py, max_py) }}'
172-
value: '3.9'
173-
'3.10':
174+
value: "3.9"
175+
"3.10":
174176
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_between_validator %]{{ version_between_validator("3.10", min_py, max_py) }}'
175-
value: '3.10'
176-
'3.11':
177+
value: "3.10"
178+
"3.11":
177179
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_between_validator %]{{ version_between_validator("3.11", min_py, max_py) }}'
178-
value: '3.11'
179-
'3.12':
180+
value: "3.11"
181+
"3.12":
180182
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_between_validator %]{{ version_between_validator("3.12", min_py, max_py) }}'
181-
value: '3.12'
182-
'3.13':
183+
value: "3.12"
184+
"3.13":
183185
validator: '[% from pathjoin("includes", "version_compare.jinja") import version_between_validator %]{{ version_between_validator("3.13", min_py, max_py) }}'
184-
value: '3.13'
185-
help: 'Choose the default Python version for development, documentation generation, and package build:'
186+
value: "3.13"
187+
help: "Choose the default Python version for development, documentation generation, and package build:"
186188
type: str
187189
readme_content:
188190
default: |-
189-
[% if project_name == 'Serious Scaffold Python' -%]
190-
[% from pathjoin("includes", "sample.jinja") import readme_content with context %]{{ readme_content() }}
191-
[%- else -%]
191+
[% if project_name == 'Serious Scaffold Python' %]
192+
[% from pathjoin("includes", "sample.jinja") import readme_content with context %]{{ readme_content() }}
193+
[%- else %]
192194
## A multiline README content here
193195
[%- endif %]
194196
help: "Provide a multiline content to be used in the README and documentation's index page:"

includes/sample.jinja

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
[% macro readme_content() -%]
2-
[% from pathjoin("includes", "variable.jinja") import page_url with context -%]
3-
[% from pathjoin("includes", "variable.jinja") import repo_url with context -%]
1+
[% macro readme_content() %]
2+
[% from pathjoin("includes", "variable.jinja") import page_url with context %]
3+
[% from pathjoin("includes", "variable.jinja") import repo_url with context %]
44
[![{{ project_name }}](https://{{ page_url() }}/_static/images/logo.svg)](https://{{ repo_url() }})
55

66
Serious Scaffold Python is crafted for long-term, maintainable Python projects. It includes GitHub Actions and GitLab CI/CD, automated dependency updates via Renovate, and comprehensive linting, testing, and documentation. Key integrations like pdm for environment and dependency management, click for CLI development, and pydantic for configuration enhance project robustness. With copier’s easy project setup and continuous updating, your project stays aligned with best practices for sustainable development. Pre-configured dev containers and cross-platform CI support ensure maintainability from the start.
77

8-
[% if repo_platform == 'github' -%]
8+
[% if repo_platform == 'github' %]
99
If you find this helpful, please consider [sponsorship](https://github.com/sponsors/{{ author_name }}).
10-
11-
[% endif -%]
10+
[% endif %]
1211

1312
## 🛠️ Features
1413

@@ -76,5 +75,4 @@ pipx install copier==9.4.1
7675
```
7776

7877
1. That's it! Feel free to focus on the coding within `src` folder.
79-
80-
[%- endmacro %]
78+
[% endmacro %]

includes/variable.jinja

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
[% macro coverage_badge() -%]
2-
[% if repo_platform == 'github' -%]
1+
[% macro coverage_badge() %]
2+
[% if repo_platform == 'github' %]
33
[![Coverage](https://img.shields.io/endpoint?url=https://{{ page_url() }}/_static/badges/coverage.json)](https://{{ page_url() }}/reports/coverage)
4-
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
4+
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
55
[![coverage report](https://{{ repo_url() }}/badges/main/coverage.svg)](https://{{ repo_url() }}/-/commits/main)
66
[%- endif %]
7-
[%- endmacro %]
7+
[% endmacro %]
88

9-
[% macro license_badge() -%]
10-
[% if repo_platform == 'github' -%]
9+
[% macro license_badge() %]
10+
[% if repo_platform == 'github' %]
1111
[![GitHub](https://img.shields.io/github/license/{{ repo_namespace }}/{{ repo_name }})]({{ license_url() }})
12-
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
12+
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
1313
[![GitLab](https://img.shields.io/gitlab/license/{{ repo_namespace }}/{{ repo_name }}?gitlab_url=https%3A%2F%2F{{ repo_host }})]({{ license_url() }})
14-
[%- endif -%]
15-
[%- endmacro %]
14+
[%- endif %]
15+
[% endmacro %]
1616

17-
[% macro license_url() -%]
18-
[% if repo_platform == 'github' -%]
19-
https://{{ repo_url() }}/blob/main/LICENSE
20-
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
21-
https://{{ repo_url() }}/-/blob/main/LICENSE
22-
[%- endif -%]
23-
[%- endmacro %]
17+
[% macro license_url() %]
18+
[% if repo_platform == 'github' %]
19+
https://{{ repo_url() }}/blob/main/LICENSE
20+
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
21+
https://{{ repo_url() }}/-/blob/main/LICENSE
22+
[%- endif %]
23+
[% endmacro %]
2424

25-
[% macro logo_badge() -%]
26-
[![Serious Scaffold Python]({{ logo_badge_url() }})](https://serious-scaffold.github.io/ss-python)
25+
[% macro logo_badge() %]
26+
[![Serious Scaffold Python]({{ logo_badge_url() }})](https://serious-scaffold.github.io/ss-python)
2727
[%- endmacro %]
2828

29-
[% macro logo_badge_url() -%]
30-
https://img.shields.io/endpoint?url=https://serious-scaffold.github.io/ss-python/_static/badges/logo.json
29+
[% macro logo_badge_url() %]
30+
https://img.shields.io/endpoint?url=https://serious-scaffold.github.io/ss-python/_static/badges/logo.json
3131
[%- endmacro %]
3232

33-
[% macro page_url() -%]
34-
[% if repo_platform == 'github' -%]
35-
{{ repo_namespace }}.github.io/{{ repo_name }}
36-
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
37-
[%- set repo_namespace_root = repo_namespace.split("/")[0] -%]
38-
{{ repo_namespace_root }}.{{ page_host }}{{ repo_namespace | replace(repo_namespace_root, "", 1) }}/{{ repo_name }}
33+
[% macro page_url() %]
34+
[% if repo_platform == 'github' %]
35+
{{ repo_namespace }}.github.io/{{ repo_name }}
36+
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
37+
[% set repo_namespace_root = repo_namespace.split("/")[0] %]
38+
{{ repo_namespace_root }}.{{ page_host }}{{ repo_namespace | replace(repo_namespace_root, "", 1) }}/{{ repo_name }}
3939
[%- endif %]
40-
[%- endmacro %]
40+
[% endmacro %]
4141

42-
[% macro pipeline_badge() -%]
43-
[% if repo_platform == 'github' -%]
42+
[% macro pipeline_badge() %]
43+
[% if repo_platform == 'github' %]
4444
[![CI](https://{{ repo_url() }}/actions/workflows/ci.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/ci.yml)
4545
[![CommitLint](https://{{ repo_url() }}/actions/workflows/commitlint.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/commitlint.yml)
4646
[![DevContainer](https://{{ repo_url() }}/actions/workflows/devcontainer.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/devcontainer.yml)
4747
[![Release](https://{{ repo_url() }}/actions/workflows/release.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/release.yml)
4848
[![Renovate](https://{{ repo_url() }}/actions/workflows/renovate.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/renovate.yml)
4949
[![Semantic Release](https://{{ repo_url() }}/actions/workflows/semantic-release.yml/badge.svg)](https://{{ repo_url() }}/actions/workflows/semantic-release.yml)
50-
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
50+
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
5151
[![pipeline status](https://{{ repo_url() }}/badges/main/pipeline.svg)](https://{{ repo_url() }}/-/commits/main)
5252
[%- endif %]
53-
[%- endmacro %]
53+
[% endmacro %]
5454

55-
[% macro releases_url() -%]
56-
[% if repo_platform == 'github' -%]
57-
https://{{ repo_url() }}/releases
58-
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
59-
https://{{ repo_url() }}/-/releases
60-
[%- endif -%]
61-
[%- endmacro %]
55+
[% macro releases_url() %]
56+
[% if repo_platform == 'github' %]
57+
https://{{ repo_url() }}/releases
58+
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
59+
https://{{ repo_url() }}/-/releases
60+
[%- endif %]
61+
[% endmacro %]
6262

63-
[% macro release_badge() -%]
64-
[% if repo_platform == 'github' -%]
63+
[% macro release_badge() %]
64+
[% if repo_platform == 'github' %]
6565
[![Release](https://img.shields.io/github/v/release/{{ repo_namespace }}/{{ repo_name }})]
66-
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' -%]
66+
[%- elif repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %]
6767
[![Latest Release](https://{{ repo_url() }}/-/badges/release.svg)]
68-
[%- endif -%]
68+
[%- endif %]
6969
({{ releases_url()}})
7070
[![PyPI](https://img.shields.io/pypi/v/{{ package_name }})](https://pypi.org/project/{{ package_name }}/)
7171
[%- endmacro %]
7272

73-
[% macro repo_url() -%]
74-
{{ repo_host }}/{{ repo_namespace }}/{{ repo_name }}
73+
[% macro repo_url() %]
74+
{{ repo_host }}/{{ repo_namespace }}/{{ repo_name }}
7575
[%- endmacro %]

0 commit comments

Comments
 (0)