Skip to content

docs: include full _copier_conf attributes list #2127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

wgordon17
Copy link
Contributor

No description provided.

@wgordon17
Copy link
Contributor Author

Here's the funny thing, I hadn't even noticed the introduction sentence with

_copier_conf includes a representation of the current Copier [Worker](https://copier.readthedocs.io/en/stable/reference/main/#copier._main.Worker) object

until I went back and looked after I had found the Attributes table. Now that I know it's there, this PR is really just intended to give some additional clarity (feel free to close as well if you feel that the extra Note shouldn't be necessary ¯\_(ツ)_/¯ )

@sisp
Copy link
Member

sisp commented May 8, 2025

Thanks for aspiring to improve the docs! 🙇 I agree that the render context isn't documented as well as it could be. There's only one concern I have with this addition: copier.main will become an internal-only module and copier.main.Worker will become an internal-only class. So the API reference will become unavailable. IMO, we should model public interfaces (like the copier.yml content specification and the render context) with Pydantic to have declarative and explicit representations as single source of truth of information, static typing, runtime validation, and (exportable) JSON schema. I've resumed work on this long-standing idea of mine, but it's a quite massive change. In the meantime, how about documenting the render context explicitly and manually? We'll need to keep it synchronous with the actual implementation, but changes are quite infrequent.

@wgordon17
Copy link
Contributor Author

Hey @sisp, thanks for the review. If y'all are good with ensuring that the docs are just always in-sync, I'm absolutely happy to help copy over the data. Let me do a quick fix, and I'll let you give it another review 😊

@wgordon17 wgordon17 changed the title docs: clarifying _copier_conf attributes reference docs: include full _copier_conf attributes list May 8, 2025
@wgordon17
Copy link
Contributor Author

@sisp I think this should be ready for a review now. Direct link to docs preview: https://copier--2127.org.readthedocs.build/en/2127/creating/#_copier_conf

A few things that I adjusted (if you're OK with that)

  • Alphabetized the attributes to ideally make it easier to skim, versus the previous order matching _main.py
  • Included Defaults on the rows where I could easily see what the defaults were in _main.py
  • Added a NOTE in _main.py to hopefully provide a reminder to folks that any changes there need to also be reflected on the, now static, Attributes table in docs

Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.03%. Comparing base (b4b40ad) to head (adca79d).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2127   +/-   ##
=======================================
  Coverage   98.03%   98.03%           
=======================================
  Files          55       55           
  Lines        6005     6005           
=======================================
  Hits         5887     5887           
  Misses        118      118           
Flag Coverage Δ
unittests 98.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wgordon17
Copy link
Contributor Author

@sisp Just checking if you're good with the changes?

Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for compiling the render context attributes table so meticulously! 🙇 I have a couple of suggestions regarding clarity, consistency, and style.

Seeing this table makes it much clearer (IMO) that the render context and Worker class attributes are not the same and not even as similar as it seemed with the previous documentation. Clarifying the render context is crucial for providing template authors with the necessary information to create good templates. Thanks for taking on this important task! 🙇

@wgordon17
Copy link
Contributor Author

@sisp awesome review, and definitely makes things clearer! I wonder...would it make sense to group setting attributes that are just sets of booleans, and then separate some of the more "in depth" attributes into their own group?

@sisp
Copy link
Member

sisp commented May 16, 2025

I think it's fine to keep all attributes in one table. There, they are sorted alphabetically and references to related settings are provided where applicable. Having a complete overview of all _copier_conf attributes in one table feels more useful than splitting them according to some rule that some may find intuitive and others may not.

I've noticed that the skip_answered setting isn't documented yet, and hence the Markdown reference isn't resolved. I've just created #2152 to add it.

I stumbled over one more thing: The settings attribute is still missing. Could you please add it?

@wgordon17 wgordon17 force-pushed the patch-2 branch 3 times, most recently from 0d51bf8 to 3b1f596 Compare May 31, 2025 14:05
@wgordon17 wgordon17 force-pushed the patch-2 branch 2 times, most recently from 49c34ec to ef463ce Compare June 7, 2025 23:03
Co-authored-by: Sigurd Spieckermann <2206639+sisp@users.noreply.github.com>
Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. 😉

wgordon17 and others added 3 commits June 9, 2025 11:01
Co-authored-by: Sigurd Spieckermann <2206639+sisp@users.noreply.github.com>
Co-authored-by: Sigurd Spieckermann <2206639+sisp@users.noreply.github.com>
@wgordon17
Copy link
Contributor Author

@sisp 2 questions/thoughts, looking at

image

  1. Why is Linux capitalized while the others are lowercase? Could/should that be normalized? 🤔 Likely a breaking change 😞
  2. Do you want to use &nbsp; to keep everything on one-line? Would definitely make the column wider 😞 Not sure if you have a preference ¯\_(ツ)_/¯

| `src_path` | `Path` | The absolute path to the (cloned/downloaded) template on disk. |
| `unsafe` | `bool` | When `True`, allow usage of unsafe templates.<br>See the [`unsafe`][] setting for related information. |
| `use_prereleases` | `bool` | When `True`, `vcs_ref`/`vcs_ref_hash` may refer to a prerelease version of the template.<br>See the [`use_prereleases`][] setting for related information. |
| `user_defaults` | `dict[str, Any]` | Specified user defaults that may override a template's defaults during question prompts. |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we point to https://copier--2127.org.readthedocs.build/en/2127/settings/#user-defaults? What would that be, See the [User defaults][settings.user-defaults] setting for related information.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_defaults in the render context is a Worker class attribute that can be passed via API only, but it's not the same as Settings.defaults. It may make sense to document user_defaults in docs/configuring.md in a separate PR.

| `exclude` | `Sequence[str]` | Specified additional [file exclusion patterns][patterns-syntax].<br>See the [`exclude`][] setting for related information. |
| `os` | <code>Literal["Linux", "macos", "windows"] &vert; None</code> | The detected operating system, `None` if it could not be detected. |
| `overwrite` | `bool` | When `True`, overwrite files that already exist, without asking.<br>See the [`overwrite`][] setting for related information. |
| `pretend` | `bool` | When `True`, produce no real rendering.<br>See the [`pretend`][] setting for related information. |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `pretend` | `bool` | When `True`, produce no real rendering.<br>See the [`pretend`][] setting for related information. |
| `pretend` | `bool` | When `True`, perform no real rendering.<br>See the [`pretend`][] setting for related information. |

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we should synchronize the descriptions and the Worker class attributes in a separate PR – wherever it makes sense.

| `dst_path` | `Path` | Destination path where to render the subproject.<br>⚠️ When [updating a project][updating-a-project], it may be a temporary directory, as Copier's update algorithm generates fresh copies using the old and new template versions in temporary locations. |
| `exclude` | `Sequence[str]` | Specified additional [file exclusion patterns][patterns-syntax].<br>See the [`exclude`][] setting for related information. |
| `os` | <code>Literal["Linux", "macos", "windows"] &vert; None</code> | The detected operating system, `None` if it could not be detected. |
| `overwrite` | `bool` | When `True`, overwrite files that already exist, without asking.<br>See the [`overwrite`][] setting for related information. |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `overwrite` | `bool` | When `True`, overwrite files that already exist, without asking.<br>See the [`overwrite`][] setting for related information. |
| `overwrite` | `bool` | When `True`, overwrite files that already exist without asking.<br>See the [`overwrite`][] setting for related information. |

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we should synchronize the descriptions and the Worker class attributes in a separate PR – wherever it makes sense.

| `context_lines` | `PositiveInt` | Lines of context to consider when solving conflicts in updates.<br>See the [`context_lines`][] setting for related information. |
| `data` | `dict[str, Any]` | Answers to the questionnaire, defined in the template, provided via CLI (`-d,--data`) or API (`data`).<br>See the [`data`][] setting for related information.<br>⚠️ May contain secret answers. |
| `defaults` | `bool` | When `True`, use default answers to questions.<br>See the [`defaults`][] setting for related information. |
| `dst_path` | `Path` | Destination path where to render the subproject.<br>⚠️ When [updating a project][updating-a-project], it may be a temporary directory, as Copier's update algorithm generates fresh copies using the old and new template versions in temporary locations. |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| `dst_path` | `Path` | Destination path where to render the subproject.<br>⚠️ When [updating a project][updating-a-project], it may be a temporary directory, as Copier's update algorithm generates fresh copies using the old and new template versions in temporary locations. |
| `dst_path` | `Path` | Destination path where to render the subproject.<br>⚠️ When [updating a project][updating-a-project], this may be a temporary directory, as Copier's update algorithm generates fresh copies using the old and new template versions in temporary locations. |

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we should synchronize the descriptions and the Worker class attributes in a separate PR – wherever it makes sense.

@wgordon17
Copy link
Contributor Author

Ok, threw a few more "consistency" suggestions in here as well, WDYT?

Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why is Linux capitalized while the others are lowercase? Could/should that be normalized? 🤔 Likely a breaking change 😞

OMG, that's totally my error. I was typing on mobile and it seems typing correction capitalized it without me noticing. It should be lowercase of course. Thanks for catching this! 🥇

  1. Do you want to use &nbsp; to keep everything on one-line? Would definitely make the column wider 😞 Not sure if you have a preference ¯\_(ツ)_/¯

It does look better without the line wrap, but then the description column might get squeezed too much. I'd say, your call. We can always change it later. Thanks for paying attention to such details though! 🙇

| `src_path` | `Path` | The absolute path to the (cloned/downloaded) template on disk. |
| `unsafe` | `bool` | When `True`, allow usage of unsafe templates.<br>See the [`unsafe`][] setting for related information. |
| `use_prereleases` | `bool` | When `True`, `vcs_ref`/`vcs_ref_hash` may refer to a prerelease version of the template.<br>See the [`use_prereleases`][] setting for related information. |
| `user_defaults` | `dict[str, Any]` | Specified user defaults that may override a template's defaults during question prompts. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_defaults in the render context is a Worker class attribute that can be passed via API only, but it's not the same as Settings.defaults. It may make sense to document user_defaults in docs/configuring.md in a separate PR.

| `exclude` | `Sequence[str]` | Specified additional [file exclusion patterns][patterns-syntax].<br>See the [`exclude`][] setting for related information. |
| `os` | <code>Literal["Linux", "macos", "windows"] &vert; None</code> | The detected operating system, `None` if it could not be detected. |
| `overwrite` | `bool` | When `True`, overwrite files that already exist, without asking.<br>See the [`overwrite`][] setting for related information. |
| `pretend` | `bool` | When `True`, produce no real rendering.<br>See the [`pretend`][] setting for related information. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we should synchronize the descriptions and the Worker class attributes in a separate PR – wherever it makes sense.

| `dst_path` | `Path` | Destination path where to render the subproject.<br>⚠️ When [updating a project][updating-a-project], it may be a temporary directory, as Copier's update algorithm generates fresh copies using the old and new template versions in temporary locations. |
| `exclude` | `Sequence[str]` | Specified additional [file exclusion patterns][patterns-syntax].<br>See the [`exclude`][] setting for related information. |
| `os` | <code>Literal["Linux", "macos", "windows"] &vert; None</code> | The detected operating system, `None` if it could not be detected. |
| `overwrite` | `bool` | When `True`, overwrite files that already exist, without asking.<br>See the [`overwrite`][] setting for related information. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we should synchronize the descriptions and the Worker class attributes in a separate PR – wherever it makes sense.

| `context_lines` | `PositiveInt` | Lines of context to consider when solving conflicts in updates.<br>See the [`context_lines`][] setting for related information. |
| `data` | `dict[str, Any]` | Answers to the questionnaire, defined in the template, provided via CLI (`-d,--data`) or API (`data`).<br>See the [`data`][] setting for related information.<br>⚠️ May contain secret answers. |
| `defaults` | `bool` | When `True`, use default answers to questions.<br>See the [`defaults`][] setting for related information. |
| `dst_path` | `Path` | Destination path where to render the subproject.<br>⚠️ When [updating a project][updating-a-project], it may be a temporary directory, as Copier's update algorithm generates fresh copies using the old and new template versions in temporary locations. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we should synchronize the descriptions and the Worker class attributes in a separate PR – wherever it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants