copier-org / copier

Library and command-line utility for rendering projects templates.
https://readthedocs.org/projects/copier/
MIT License
2.06k stars 182 forks source link

feat: add dynamic file structures in loop using yield-tag #1855

Open kj-9 opened 2 weeks ago

kj-9 commented 2 weeks ago

What I did:

kj-9 commented 2 weeks ago

hopefully closes #1271

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.74%. Comparing base (8391966) to head (6f4acec). Report is 10 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1855 +/- ## ========================================== + Coverage 97.67% 97.74% +0.07% ========================================== Files 49 51 +2 Lines 5238 5358 +120 ========================================== + Hits 5116 5237 +121 + Misses 122 121 -1 ``` | [Flag](https://app.codecov.io/gh/copier-org/copier/pull/1855/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/copier-org/copier/pull/1855/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org) | `97.74% <100.00%> (+0.07%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=copier-org#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

yajo commented 5 days ago

I only reviewed tests in depth so far, and it seems the interface is almost exactly what I meant! Awesome!

Quoting from https://github.com/copier-org/copier/issues/1271#issue-1821616806:

are you rendering a filename? No: just let the exception raise and print a nice message "Using yield outside of file names isn't supported".

That seems to be the only missing part. At least I saw no test for that. Could you add this please?

When done I'll review the implementation. This PR is big!

Thank you very much 😊

kj-9 commented 3 days ago

@yajo

Thank you for your review!

I've added a new commit that implements the behavior you mentioned - throwing an exception when yield is used for rendering file contents. I've also added the corresponding test case.

Looking forward to your implementation review!