Skip to content

Commit 6663b8c

Browse files
authored
Merge pull request #529 from NLeSC/440_default_values
440-Organize copier questions
2 parents 7899466 + dd18d64 commit 6663b8c

11 files changed

Lines changed: 239 additions & 159 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66

7+
* New YAML files for copier questions [#529](https://github.com/NLeSC/python-template/pull/529)
78
* Make zenodo next step instructions optional [#520](https://github.com/NLeSC/python-template/pull/520)
89
* Make SonarCloud optional [#515](https://github.com/NLeSC/python-template/pull/515)
910
* Make citation optional [#471](https://github.com/NLeSC/python-template/pull/471)
@@ -33,6 +34,9 @@ Released on August 15, 2024
3334

3435
### Changed
3536

37+
* Made copier configuration more modular [#529](https://github.com/NLeSC/python-template/pull/529)
38+
* pre-commit script is optional ([#457](https://github.com/NLeSC/python-template/issues/457))
39+
* CHANGELOG.md is now optional ([#462](https://github.com/NLeSC/python-template/issues/462))
3640
* Moved to src/ based layout for generated packages
3741
* Moved from setup.cfg/.py to pyproject.toml [#351](https://github.com/NLeSC/python-template/issues/351)
3842
* Moved from prospector to ruff [#336](https://github.com/NLeSC/python-template/issues/336)

copier.yml

Lines changed: 18 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,23 @@
1-
# Essential questions
1+
---
2+
# General settings for copier
3+
!include copier/settings.yml
24

3-
package_name:
4-
type: str
5-
default: my_python_package
6-
help: Enter the name of the Python package.
7-
validator: >-
8-
{% if not (package_name | regex_search('^[a-z][a-z0-9\_]+$')) %}
9-
package_name must start with a letter, followed one or more letters, digits or underscores all lowercase.
10-
{% endif %}
11-
package_short_description:
12-
type: str
13-
default: Short description of package
14-
keyword1:
15-
type: str
16-
default: keyword1
17-
keyword2:
18-
type: str
19-
default: keyword2
20-
version:
21-
type: str
22-
default: 0.1.0
23-
github_organization:
24-
type: str
25-
default: "<my-github-organization>"
26-
help: Enter the name of your GitHub username or organization
27-
full_name:
28-
type: str
29-
default: Jane Smith
30-
help: Enter your full name.
31-
email:
32-
type: str
33-
default: yourname@esciencecenter.nl
34-
copyright_holder:
35-
type: str
36-
default: Netherlands eScience Center
37-
code_of_conduct_email:
38-
type: str
39-
default: "{{ email }}"
5+
---
6+
# profiles
7+
!include copier/profiles.yml
408

41-
# calculated fields
42-
repository:
43-
default: git@github.com:{{ github_organization }}/{{ package_name }}
44-
when: false
9+
---
10+
# essential questions about the package details
11+
!include copier/questions/essential.yml
4512

46-
repository_url:
47-
default: https://github.com/{{ github_organization }}/{{ package_name }}
48-
when: false
13+
---
14+
# additional questions about the package details
15+
!include copier/questions/package_details.yml
4916

17+
---
18+
# Features
19+
!include copier/questions/features.yml
5020

51-
# profile selection
52-
template_profile:
53-
type: str
54-
default: recommended
55-
help: Optional questions (You can use our defaults, or the bare minimum, or decide everything)
56-
choices:
57-
Recommended (our defaults for research software): "recommended"
58-
Minimum (no extra features): "minimum"
59-
Let me choose (decide each feature yourself): "ask"
60-
61-
62-
# extra questions
63-
license:
64-
type: str
65-
choices:
66-
- "Apache Software License 2.0"
67-
- "MIT license"
68-
- "BSD license"
69-
- "ISC license"
70-
- "GNU General Public License v3 or later"
71-
- "GNU Lesser General Public License v3 or later"
72-
- "Not open source"
73-
default: "MIT license"
74-
75-
AddLinkCheck:
76-
when: "{{ template_profile == 'ask' }}"
77-
type: bool
78-
default: "{{ template_profile != 'minimum' }}"
79-
help: Do you want to add a GitHub action to check broken links?
80-
81-
AddGitHubActions:
82-
when: "{{ template_profile == 'ask' }}"
83-
type: bool
84-
default: "{{ template_profile != 'minimum' }}"
85-
help: GitHub actions to test the package and the documentation
86-
87-
AddCitation:
88-
when: "{{ template_profile == 'ask' }}"
89-
type: bool
90-
default: "{{ template_profile != 'minimum' }}"
91-
help: Citation file and cffconvert workflow which validates the citation file
92-
93-
AddChangeLog:
94-
when: "{{ template_profile == 'ask' }}"
95-
type: bool
96-
default: "{{ template_profile != 'minimum' }}"
97-
help: Add a change log to keep track of changes in the package
98-
99-
AddOnlineDocumentation:
100-
when: "{{ template_profile == 'ask' }}"
101-
type: bool
102-
default: "{{ template_profile != 'minimum' }}"
103-
help: Online documentation using Read the Docs
104-
105-
AddPreCommit:
106-
when: "{{ template_profile == 'ask' }}"
107-
type: bool
108-
default: "{{ template_profile != 'minimum' }}"
109-
help: Add pre-commit hook to check code style and format on every commit?
110-
111-
AddZenodo:
112-
when: "{{ template_profile == 'ask' }}"
113-
type: bool
114-
default: "{{ template_profile != 'minimum' }}"
115-
help: Create a GitHub issue on how to enable Zenodo integration?
116-
117-
AddSonarCloud:
118-
when: "{{ template_profile == 'ask' }}"
119-
type: bool
120-
default: "{{ template_profile != 'minimum' }}"
121-
help: Add SonarCloud (code analysis service) integration?
122-
123-
# internal fields
124-
_subdirectory: template
125-
126-
# user messages
127-
_message_before_copy: |
128-
Thanks for generating a project using our template.
129-
130-
You'll be asked a series of questions whose answers will be used to
131-
generate a tailored project for you.
132-
133-
_message_after_copy: |
134-
Your project "{{ package_name }}" has been created successfully!
135-
136-
Next steps:
137-
138-
1. Change directory to the project root:
139-
140-
$ cd {{ _copier_conf.dst_path }}
141-
142-
2. Read next_steps.md which contains information on next steps.
143-
144-
_message_before_update: |
145-
Thanks for updating your project using our template.
146-
147-
You'll be asked a series of questions whose answers are pre-populated
148-
with previously entered values. Feel free to change them as needed.
149-
150-
_message_after_update: |
151-
Your project "{{ package_name }}" has been updated successfully!
152-
In case there are any conflicts, please resolve them. Then,
153-
you're done.
21+
---
22+
# User messages
23+
!include copier/messages.yml

copier/messages.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# user messages
2+
_message_before_copy: |
3+
Thanks for generating a project using our template.
4+
5+
You'll be asked a series of questions whose answers will be used to
6+
generate a tailored project for you.
7+
8+
For each question there is a placeholder. Make sure you provide an
9+
input to each of them.
10+
11+
_message_after_copy: |
12+
Your project "{{ package_name }}" has been created successfully!
13+
14+
Next steps:
15+
16+
1. Change directory to the project root:
17+
18+
$ cd {{ _copier_conf.dst_path }}
19+
20+
2. Read next_steps.md which contains information on next steps.
21+
22+
_message_before_update: |
23+
Thanks for updating your project using our template.
24+
25+
You'll be asked a series of questions whose answers are pre-populated
26+
with previously entered values. Feel free to change them as needed.
27+
28+
_message_after_update: |
29+
Your project "{{ package_name }}" has been updated successfully!
30+
In case there are any conflicts, please resolve them. Then,
31+
you're done.

copier/profiles.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# profile selection
3+
template_profile:
4+
type: str
5+
default: ask
6+
help: Select a profile
7+
choices:
8+
Recommended (our defaults for research software): "recommended"
9+
Minimum (bare minimum, no extra features): "minimum"
10+
Let me choose (decide each feature yourself): "ask"

copier/questions/essential.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# Essential questions
3+
package_name:
4+
type: str
5+
placeholder: my_python_package
6+
help: Enter the name of the Python package.
7+
validator: >-
8+
{% if not (package_name | regex_search('^[a-z][a-z0-9\_]+$')) %}
9+
Package name must start with a letter, followed one or more letters, digits or underscores all lowercase
10+
{% endif %}
11+
version:
12+
type: str
13+
placeholder: 0.1.0
14+
help: Enter the version of the Python package
15+
license:
16+
type: str
17+
choices:
18+
- "Apache Software License 2.0"
19+
- "MIT license"
20+
- "BSD license"
21+
- "ISC license"
22+
- "GNU General Public License v3 or later"
23+
- "GNU Lesser General Public License v3 or later"
24+
- "Not open source"
25+
default: "Apache Software License 2.0"

copier/questions/features.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
# Questions for features
3+
addExtraFeatures:
4+
type: bool
5+
default: yes
6+
help: Do you want to add extra features?
7+
when: "{{ template_profile == 'ask' }}"
8+
AddLinkCheck:
9+
when: "{{ template_profile == 'ask' }}"
10+
type: bool
11+
default: "{{ template_profile != 'minimum' }}"
12+
help: Do you want to add a GitHub action to check broken links?
13+
AddGitHubActions:
14+
when: "{{ template_profile == 'ask' }}"
15+
type: bool
16+
default: "{{ template_profile != 'minimum' }}"
17+
help: Do you want to add GitHub actions to test the package and the documentation?
18+
AddCitation:
19+
when: "{{ template_profile == 'ask' }}"
20+
type: bool
21+
default: "{{ template_profile != 'minimum' }}"
22+
help: Citation file and cffconvert workflow which validates the citation file
23+
AddChangeLog:
24+
when: "{{ template_profile == 'ask' }}"
25+
type: bool
26+
default: "{{ template_profile != 'minimum' }}"
27+
help: Add a change log to keep track of changes in the package
28+
AddOnlineDocumentation:
29+
when: "{{ template_profile == 'ask' }}"
30+
type: bool
31+
default: "{{ template_profile != 'minimum' }}"
32+
help: Online documentation using Read the Docs
33+
AddPreCommit:
34+
when: "{{ template_profile == 'ask' }}"
35+
type: bool
36+
default: "{{ template_profile != 'minimum' }}"
37+
help: Add pre-commit hook to check code style and format on every commit?
38+
AddZenodo:
39+
when: "{{ template_profile == 'ask' }}"
40+
type: bool
41+
default: "{{ template_profile != 'minimum' }}"
42+
help: Create a GitHub issue on how to enable Zenodo integration?
43+
AddSonarCloud:
44+
when: "{{ template_profile == 'ask' }}"
45+
type: bool
46+
default: "{{ template_profile != 'minimum' }}"
47+
help: Add SonarCloud (code analysis service) integration?
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
# package details
3+
AddPackageDetails:
4+
type: bool
5+
default: yes
6+
help: Do you want to add extra details for the package?
7+
when: "{{ template_profile != 'minimum'}}"
8+
package_short_description:
9+
type: str
10+
placeholder: Short description
11+
help: Provide a short description of package.
12+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
13+
keyword1:
14+
type: str
15+
placeholder: keyword1
16+
help: Add keyword1
17+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
18+
keyword2:
19+
type: str
20+
placeholder: keyword2
21+
help: Add keyword2
22+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
23+
github_organization:
24+
type: str
25+
placeholder: "<my-github-organization>"
26+
help: Enter the name of your GitHub username or organization
27+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
28+
full_name:
29+
type: str
30+
placeholder: Jane Smith
31+
help: Enter your full name
32+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
33+
email:
34+
type: str
35+
placeholder: yourname@esciencecenter.nl
36+
help: What is your email address?
37+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
38+
code_of_conduct_email:
39+
type: str
40+
placeholder: yourname@esciencecenter.nl
41+
help: What is the email address of code of conduct?
42+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
43+
copyright_holder:
44+
type: str
45+
placeholder: Netherlands eScience Center
46+
help: Who is the copyright holder?
47+
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
48+
49+
# calculated fields for GitHub
50+
repository:
51+
default: git@github.com:{{ github_organization }}/{{ package_name }}
52+
when: false
53+
54+
repository_url:
55+
default: https://github.com/{{ github_organization }}/{{ package_name }}
56+
when: false

copier/settings.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# internal fields
2+
_subdirectory: template
3+
4+
# Settings like `_skip_if_exists` are merged
5+
_skip_if_exists:
6+
- "pyproject.toml"
7+
- CITATION.cff
8+
- LICENSE

template/docs/conf.py.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
project = u"{{ package_name }}"
2121
copyright = u"{{ '%Y-%m-%d %H:%M:%S' | strftime }}, {{ copyright_holder }}"
22-
author = u"{{ full_name.replace('\"', '\\\"') }}"
22+
author = u"{{ full_name|replace('\"', '\\\"') }}"
2323

2424
# The version info for the project you're documenting, acts as replacement for
2525
# |version| and |release|, also used in various other places throughout the

0 commit comments

Comments
 (0)