Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
christokur committed Feb 3, 2023
1 parent 3908278 commit 4bb0ef8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
25 changes: 11 additions & 14 deletions cookiecutter/generate.py
Expand Up @@ -140,8 +140,10 @@ def resolve_changed_variable_names(context, variables_to_resolve):


def apply_overwrites_to_context_v2(context, extra_context):
"""
Modify the given version 2 context in place based on extra_context.
"""Modify the given version 2 context in place based on extra_context.
:parameter context: cookiecutter context.
:parameter extra_context: optional dictionary of key/value pairs to
The extra_context parameter may be a dictionary or a list of dictionaries.
Expand All @@ -168,20 +170,17 @@ def apply_overwrites_to_context_v2(context, extra_context):
Changing the 'name' field requires a special syntax. Because the algorithm
chosen to find a variable’s dictionary entry in the variables list of
OrderDicts uses the variable’s ‘name’ field; it could not be used to
simultaneously hold a new ‘name’ field value. Therefore the following
extra context dictionary entry snytax was introduced to allow the ‘name’
simultaneously hold a new ‘name’ field value. Therefor the following
extra context dictionary entry sytax was introduced to allow the ‘name’
field of a variable to be changed:
{
'name': 'CURRENT_VARIABLE_NAME::NEW_VARIABLE_NAME',
}
{ 'name': 'CURRENT_VARIABLE_NAME::NEW_VARIABLE_NAME',}
So, for example, to change a variable’s ‘name’ field from
‘director_credit’ to ‘producer_credit’, would require:
{
'name': 'director_credit::producer_credit',
}
{ 'name': 'director_credit::producer_credit', }
Removing a Field from a Variable
--------------------------------
Expand All @@ -191,10 +190,8 @@ def apply_overwrites_to_context_v2(context, extra_context):
In order to accomplish this a remove field token is used in the extra
context as follows:
{
'name': 'director_cut',
'skip_if': '<<REMOVE::FIELD>>',
}
{ 'name': 'director_cut',
'skip_if': '<<REMOVE::FIELD>>', }
In the example above, the extra context overwrite results in the variable
named ‘director_cut’ having it’s ‘skip_if’ field removed.
Expand Down
6 changes: 3 additions & 3 deletions docs/cookiecutter.rst
Expand Up @@ -25,9 +25,9 @@ cookiecutter.context module
---------------------------

.. automodule:: cookiecutter.context
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

cookiecutter.environment module
-------------------------------
Expand Down

0 comments on commit 4bb0ef8

Please sign in to comment.