-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
feat: add dynamic file structures in loop using yield-tag #1855
base: master
Are you sure you want to change the base?
Conversation
… extention for yield tag, allow _render_path to generate mulitple paths and contexts when yield tag is used
… test file to test dynamic file structure feature
hopefully closes #1271 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
I only reviewed tests in depth so far, and it seems the interface is almost exactly what I meant! Awesome! Quoting from #1271 (comment):
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 😊 |
…d YieldTagInFileError and raise it if yield tag used when rendering file content. also add the test case
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! |
… is unnecessary if there's a docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, the first code review is here!
Apart from what's mentioned, I also miss the documentation.
Thank you!
…ntext with yield_name and yield_iterable attributes in YieldEnvironment and YieldExtension
…or check to _render_file method to enforce yield tag restrictions during file rendering
…r of parameters in _yield_support method for consistency and clarity
…ng over lists to generate files and directories
@yajo I have added a few commits:
And in the last commit, I added documentation. Specifically, three points:
This is my first time adding documentation, so I'm not sure if it meets your expectations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks very good, thanks!
Please review a couple of suggestions for the docs, so we can merge.
@copier-org/maintainers this is an important feature, would you like to add your reviews?
I'll try to give feedback later today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions, nothing critical, looking good 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…r for handling multiple yield tags, with some test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mostly LGTM, just a couple of minor comments. Thanks!
|
||
!!! example | ||
|
||
```pycon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
```pycon | |
```python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yajo
see @pawamoy 's comment #1855 (comment)
in my dev env, syntax highlighting on console results are bit different based on pycon
or python
I'm not sure which is suitable here.
copier/jinja_ext.py
Outdated
environment: YieldEnvironment | ||
|
||
def __init__(self, environment: YieldEnvironment): | ||
super().__init__(environment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought: It seems to me like this method override is doing nothing, right? Could you remove these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ctor in YieldExtension class
What I did:
copier/jinja_ext.py
to handleyield
tagsyield
tags and sets up the necessary context throughjinja_env
_render_path
to return multiple destination paths and their corresponding contexts whenyield
tags are presentyield
tags to the_render_parts
functionextra_context
parameter to_render_file
to enable injection of contexts generated fromyield
tags