Skip to content

Commit

Permalink
- d added howto for inline parsing
Browse files Browse the repository at this point in the history
Co-Authored-By: Kody Fintak <15849743+kodyfintak@users.noreply.github.com>
Co-Authored-By: 4dsherwood <4dsherwood@users.noreply.github.com>
Co-Authored-By: Nazee Hajebi <2491283+NazeeHajebi@users.noreply.github.com>
  • Loading branch information
4 people committed Apr 7, 2024
1 parent 09426a2 commit a18c372
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/how_to/inline_approvals_with_parse_input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# How to have tight feedback loops with inline approvals and parse_input

## Problem
You are doing TDD on a pure function that takes some parameters and returns a result.
You want to just program and see the results of running it with as little in the way of that as possible.

## Handling 1 Parameter

### Scenario - Counting Vowels
You are writing a function that counts the number of vowels in a string.

### Step 1: Write the Test
Start by writing an empty implementation with 1 input.
snippet: parse_input_step_1

### Step 2: Run the Test
When you run the test it will fail, but it will automatically update the docstring with the result from your function
snippet: parse_input_step_2

### Step 3: Implement the Function
Everytime you run the tests, you automatically see the result at the top in the docstring.
When you finally get the answer you want, remove the `auto_approve=True` and commit the code.


## Handling 1 Parameter that is not a string
All input will be treated as strings.
But it is easy to transform it to the type you care about.
Here's an example:

snippet: parse_input_transformation

## Handling 2 Parameters
If you need multiple parameters, there are transform calls for each parameter.
Here's an example with two parameters:

snippet: parse_input_two_parameters

0 comments on commit a18c372

Please sign in to comment.