Skip to content

Commit 76018a7

Browse files
committed
1 parent d027494 commit 76018a7

File tree

4 files changed

+127
-15
lines changed

4 files changed

+127
-15
lines changed

copier/template.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ class Template:
112112

113113
@cached_property
114114
def _raw_config(self) -> AnyByStrDict:
115-
"""Get template configuration, raw."""
115+
"""Get template configuration, raw.
116+
117+
It reads [the `copier.yml` file][the-copieryml-file].
118+
"""
116119
result = load_config_data(self.local_abspath)
117120
with suppress(KeyError):
118121
verify_minimum_version(result["_min_copier_version"])
@@ -123,6 +126,8 @@ def answers_relpath(self) -> Path:
123126
"""Get the answers file relative path, as specified in the template.
124127
125128
If not specified, returns the default `.copier-answers.yml`.
129+
130+
See [answers_file][].
126131
"""
127132
result = Path(self.config_data.get("answers_file", ".copier-answers.yml"))
128133
assert not result.is_absolute()
@@ -137,7 +142,11 @@ def commit(self) -> OptStr:
137142

138143
@cached_property
139144
def config_data(self) -> AnyByStrDict:
140-
"""Get config from the template."""
145+
"""Get config from the template.
146+
147+
It reads [the `copier.yml` file][the-copieryml-file] to get its
148+
[settings][available-settings].
149+
"""
141150
return filter_config(self._raw_config)[0]
142151

143152
@cached_property
@@ -147,7 +156,10 @@ def default_answers(self) -> AnyByStrDict:
147156

148157
@cached_property
149158
def envops(self) -> Mapping:
150-
"""Get the Jinja configuration specified in the template, or default values."""
159+
"""Get the Jinja configuration specified in the template, or default values.
160+
161+
See [envops][].
162+
"""
151163
# TODO Use Jinja defaults
152164
result = {
153165
"autoescape": False,
@@ -164,7 +176,10 @@ def envops(self) -> Mapping:
164176

165177
@cached_property
166178
def exclude(self) -> Tuple[str, ...]:
167-
"""Get exclusions specified in the template, or default ones."""
179+
"""Get exclusions specified in the template, or default ones.
180+
181+
See [exclude][].
182+
"""
168183
return tuple(self.config_data.get("exclude", DEFAULT_EXCLUDE))
169184

170185
@cached_property
@@ -183,6 +198,8 @@ def migration_tasks(self, stage: str, from_: str, to: str) -> Sequence[Mapping]:
183198
"""Get migration objects that match current version spec.
184199
185200
Versions are compared using PEP 440.
201+
202+
See [migrations][].
186203
"""
187204
result: List[dict] = []
188205
if not from_ or not to:
@@ -206,7 +223,10 @@ def migration_tasks(self, stage: str, from_: str, to: str) -> Sequence[Mapping]:
206223

207224
@cached_property
208225
def questions_data(self) -> AnyByStrDict:
209-
"""Get questions from the template."""
226+
"""Get questions from the template.
227+
228+
See [questions][].
229+
"""
210230
return filter_config(self._raw_config)[1]
211231

212232
@cached_property
@@ -226,6 +246,8 @@ def skip_if_exists(self) -> StrSeq:
226246
"""Get skip patterns from the template.
227247
228248
These files will never be rewritten when rendering the template.
249+
250+
See [skip_if_exists][].
229251
"""
230252
return self.config_data.get("skip_if_exists", ())
231253

@@ -236,19 +258,26 @@ def subdirectory(self) -> str:
236258
The subdirectory points to the real template code, allowing the
237259
templater to separate it from other template assets, such as docs,
238260
tests, etc.
261+
262+
See [subdirectory][].
239263
"""
240264
return self.config_data.get("subdirectory", "")
241265

242266
@cached_property
243267
def tasks(self) -> Sequence:
244-
"""Get tasks defined in the template."""
268+
"""Get tasks defined in the template.
269+
270+
See [tasks][].
271+
"""
245272
return self.config_data.get("tasks", [])
246273

247274
@cached_property
248275
def templates_suffix(self) -> str:
249276
"""Get the suffix defined for templates.
250277
251278
By default: `.tmpl`.
279+
280+
See [templates_suffix][].
252281
"""
253282
return self.config_data.get("templates_suffix", DEFAULT_TEMPLATES_SUFFIX)
254283

docs/configuring.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,32 @@ is overriden, and don't ask user anything else:
290290
copier -fd 'user_name=Manuel Calavera' copy template destination
291291
```
292292

293+
### `envops`
294+
295+
- Format: `dict`
296+
- CLI flags: N/A
297+
- Default value:
298+
299+
```yaml
300+
{
301+
"autoescape": False,
302+
"block_end_string": "%]",
303+
"block_start_string": "[%",
304+
"comment_end_string": "#]",
305+
"comment_start_string": "[#",
306+
"keep_trailing_newline": True,
307+
"variable_end_string": "]]",
308+
"variable_start_string": "[[",
309+
}
310+
```
311+
312+
Configurations for the Jinja environment.
313+
314+
These defaults are different from upstream Jinja's.
315+
316+
See [upstream docs](https://jinja.palletsprojects.com/en/2.11.x/api/#jinja2.Environment)
317+
to know available options.
318+
293319
### `exclude`
294320

295321
- Format: `List[str]`

poetry.lock

Lines changed: 65 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pyyaml = "^5.3.1"
4444
pyyaml-include = "^1.2"
4545
questionary = "^1.8.1"
4646
typing-extensions = {version = "^3.7.4", python = "<3.8"}
47+
# HACK https://github.com/pawamoy/pytkdocs/issues/86
4748
# HACK https://github.com/pawamoy/mkdocstrings/issues/225#issuecomment-774669999
4849
pytkdocs = {git = "https://github.com/pawamoy/pytkdocs.git", rev = "master", optional = true}
4950

0 commit comments

Comments
 (0)