From a263ad0e01a4eccf9addf3eb40c1a52e24101250 Mon Sep 17 00:00:00 2001 From: Italo Maia Date: Mon, 6 Jun 2022 23:17:35 +0200 Subject: [PATCH 1/7] Update boolean_variables.rst Adding explanation on what is considered valid input for boolean configuration. --- docs/advanced/boolean_variables.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/advanced/boolean_variables.rst b/docs/advanced/boolean_variables.rst index 58c5e48a7..964049152 100644 --- a/docs/advanced/boolean_variables.rst +++ b/docs/advanced/boolean_variables.rst @@ -20,7 +20,10 @@ you'd get the following user input when running Cookiecutter:: run_as_docker [True]: -Depending on the user's input, a different condition will be selected. +The following values are considered valid input: + + true, 1, yes, y **or** + false, 0, no, n The above ``run_as_docker`` boolean variable creates ``cookiecutter.run_as_docker``, which can be used like this:: From c6dff1b9bd0f4b29eeb4cd65bd559a3202d622fd Mon Sep 17 00:00:00 2001 From: Italo Maia Date: Tue, 7 Jun 2022 00:15:20 +0200 Subject: [PATCH 2/7] Update boolean_variables.rst Removing trailing whitespace --- docs/advanced/boolean_variables.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced/boolean_variables.rst b/docs/advanced/boolean_variables.rst index 964049152..85d4bc461 100644 --- a/docs/advanced/boolean_variables.rst +++ b/docs/advanced/boolean_variables.rst @@ -23,7 +23,7 @@ you'd get the following user input when running Cookiecutter:: The following values are considered valid input: true, 1, yes, y **or** - false, 0, no, n + false, 0, no, n The above ``run_as_docker`` boolean variable creates ``cookiecutter.run_as_docker``, which can be used like this:: From 1ad2375fc4582572f25c5e668fb541d72e33bab6 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Tue, 7 Jun 2022 13:47:04 +0300 Subject: [PATCH 3/7] Fix CI/CD for first time contributors --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f4963bda3..a84a59992 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -72,6 +72,7 @@ jobs: - name: Project security test run: "nox -p ${{ matrix.python }} -s safety_tests" - name: Send coverage report to codeclimate + continue-on-error: true uses: paambaati/codeclimate-action@v3.0.0 with: coverageCommand: echo "Ignore rerun" From 6008c7123b0a7dbaf8495b4ceaae840bb478d6fc Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Tue, 7 Jun 2022 15:10:27 +0300 Subject: [PATCH 4/7] Update documentation intersphinx_mapping to external sources --- docs/conf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index d608b0308..332153029 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -353,7 +353,11 @@ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/3': None} +intersphinx_mapping = { + "python": ("https://docs.python.org/3", None), + "requests": ("https://requests.readthedocs.io/en/latest/", None), + "click": ("https://click.palletsprojects.com/en/latest", None), +} myst_enable_extensions = [ "tasklist", "strikethrough", From 4d40ed5ea3e0ff79264861d1ffbedbc5c01e3de5 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Tue, 7 Jun 2022 15:11:08 +0300 Subject: [PATCH 5/7] Update list of directories for looking for files changes in interactive documentation build --- noxfile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index aa5de2e2b..25189967e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -55,7 +55,7 @@ def docs(session, batch_run: bool = False): """Build the documentation or serve documentation interactively.""" shutil.rmtree(Path("docs").joinpath("_build"), ignore_errors=True) session.install("-r", "docs/requirements.txt") - session.install(".") + session.install("-e", ".") session.cd("docs") sphinx_args = ["-b", "html", "-W", ".", "_build/html"] @@ -69,7 +69,13 @@ def docs(session, batch_run: bool = False): "--port", "9812", "--watch", - "../", + "../*.md", + "--watch", + "../*.rst", + "--watch", + "../*.py", + "--watch", + "../cookiecutter", ] ) From fbc68f7456a4e152dc8c6443c1d688fd0d56c955 Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Tue, 7 Jun 2022 15:12:06 +0300 Subject: [PATCH 6/7] Extend read_user_yes_no docstrings --- cookiecutter/prompt.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cookiecutter/prompt.py b/cookiecutter/prompt.py index 003ace67d..d27481f7b 100644 --- a/cookiecutter/prompt.py +++ b/cookiecutter/prompt.py @@ -16,20 +16,23 @@ def read_user_variable(var_name, default_value): :param str var_name: Variable of the context to query the user :param default_value: Value that will be returned if no input happens """ - # Please see https://click.palletsprojects.com/en/7.x/api/#click.prompt return click.prompt(var_name, default=default_value) def read_user_yes_no(question, default_value): """Prompt the user to reply with 'yes' or 'no' (or equivalent values). - Note: - Possible choices are 'true', '1', 'yes', 'y' or 'false', '0', 'no', 'n' + - These input values will be converted to ``True``: + "1", "true", "t", "yes", "y", "on" + - These input values will be converted to ``False``: + "0", "false", "f", "no", "n", "off" + + Actual parsing done by :func:`click.prompt`; Check this function codebase change in + case of unexpected behaviour. :param str question: Question to the user :param default_value: Value that will be returned if no input happens """ - # Please see https://click.palletsprojects.com/en/7.x/api/#click.prompt return click.prompt(question, default=default_value, type=click.BOOL) @@ -38,7 +41,6 @@ def read_repo_password(question): :param str question: Question to the user """ - # Please see https://click.palletsprojects.com/en/7.x/api/#click.prompt return click.prompt(question, hide_input=True) @@ -51,7 +53,6 @@ def read_user_choice(var_name, options): :param list options: Sequence of options that are available to select from :return: Exactly one item of ``options`` that has been chosen by the user """ - # Please see https://click.palletsprojects.com/en/7.x/api/#click.prompt if not isinstance(options, list): raise TypeError @@ -109,7 +110,6 @@ def read_user_dict(var_name, default_value): :param default_value: Value that will be returned if no input is provided :return: A Python dictionary to use in the context. """ - # Please see https://click.palletsprojects.com/en/7.x/api/#click.prompt if not isinstance(default_value, dict): raise TypeError From 621739292da406b549f44a09aca76b5b4c46671f Mon Sep 17 00:00:00 2001 From: Andrey Shpak Date: Tue, 7 Jun 2022 16:14:53 +0300 Subject: [PATCH 7/7] Finalize Boolean Variables documentation update (rst) --- docs/advanced/boolean_variables.rst | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/advanced/boolean_variables.rst b/docs/advanced/boolean_variables.rst index 85d4bc461..8d9cf6997 100644 --- a/docs/advanced/boolean_variables.rst +++ b/docs/advanced/boolean_variables.rst @@ -1,32 +1,35 @@ -.. _boolean-variables: +Boolean Variables +----------------- -Boolean Variables (2.2+) ------------------------- +.. versionadded:: 2.2.0 Boolean variables are used for answering True/False questions. Basic Usage ~~~~~~~~~~~ -Boolean variables are regular key / value pairs, but with the value being True/False. +Boolean variables are regular key / value pairs, but with the value being +``True``/``False``. -For example, if you provide the following boolean variable in your ``cookiecutter.json``:: +For example, if you provide the following boolean variable in your +``cookiecutter.json``:: { "run_as_docker": true } -you'd get the following user input when running Cookiecutter:: +you will get the following user input when running Cookiecutter:: run_as_docker [True]: -The following values are considered valid input: +User input will be parsed by :func:`~cookiecutter.prompt.read_user_yes_no`. The +following values are considered as valid user input: - true, 1, yes, y **or** - false, 0, no, n + - ``True`` values: "1", "true", "t", "yes", "y", "on" + - ``False`` values: "0", "false", "f", "no", "n", "off" -The above ``run_as_docker`` boolean variable creates ``cookiecutter.run_as_docker``, which -can be used like this:: +The above ``run_as_docker`` boolean variable creates ``cookiecutter.run_as_docker``, +which can be used like this:: {%- if cookiecutter.run_as_docker -%} # In case of True add your content here @@ -36,7 +39,8 @@ can be used like this:: {% endif %} -Cookiecutter is using `Jinja2's if conditional expression `_ to determine the correct ``run_as_docker``. +Cookiecutter is using `Jinja2's if conditional expression `_ to determine the correct ``run_as_docker``. Input Validation ~~~~~~~~~~~~~~~~