Skip to content
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

Fix docs to conform to new API #52

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# elm-review-codeinstaller

**NOTE:** *This version is a breaking change from version 12.05. The visible part is an improved set of rule names. Please see the documentation,
both below and for the
A package designed to make it easy to add pieces of code to an existing codebase using `elm-review` rules. This package provides a set of tools to help you automatically insert clauses in case expressions, fields in type aliases, fields in initializer functions, and variants in custom types.*
**NOTE:** _This version is a breaking change from version 12.05. The visible part is an improved set of rule names. Please see the documentation,
both below and for the [codeinstaller-rulesets](https://github.com/jxxcarlson/codeinstaller-rulesets) package designed to make it easy to add pieces of code to an existing codebase using `elm-review` rules. This package provides a set of tools to help you automatically insert clauses in case expressions, fields in type aliases, fields in initializer functions, and variants in custom types._

*The project is still in development, so expect it to change a lot over the next weeks and likely months. For now, consider it to be an experiment.*
_The project is still in development, so expect it to change a lot over the next weeks and likely months. For now, consider it to be an experiment._

## Installation

Expand Down Expand Up @@ -59,12 +58,12 @@ addResetCounter =

addResetCounterVariant : Rule
addResetCounterVariant =
Install.TypeVariant.makeRule "Counter" "Msg" "ResetCounter"
Install.typeVariant "Counter" "Msg" "ResetCounter"

addResetCounterClause : Rule
addResetCounterClause =
Install.ClauseInCase.config "Counter" "update" "ResetCounter" "( { model | counter = 0 }, Cmd.none )"
|> Install.ClauseInCase.makeRule
|> Install.clauseInCase
```

After running `elm-review --fix`, your `Counter` module will be updated as follows:
Expand Down Expand Up @@ -115,14 +114,13 @@ For this to succeed, your Lamdera project must have a notion of "page," as in th
that you will find in the folder `counter-original` of the
repo for this project. Try copying that folder.


## Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.

## Contributors

James Carlson and Mateus Leite. We also thank Jeroen Engels for his
[James Carlson](https://github.com/jxxcarlson) and [Mateus Leite](https://github.com/mateusfpleite). We also thank [Jeroen Engels](https://github.com/jfmengels) for his
contributions to making our API much better.

## License
Expand Down
10 changes: 5 additions & 5 deletions src/Install/ClauseInCase.elm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ in a specified module. For example, if you put the code below in your
"updateFromFrontend"
"ResetCounter"
"( { model | counter = 0 }, broadcast (CounterNewValue 0 clientId) )"
|> Install.ClauseInCase.makeRule
|> Install.clauseInCase

Thus we will have

Expand Down Expand Up @@ -56,7 +56,7 @@ type alias Config =
"updateFromFrontend"
"ResetCounter"
"( { model | counter = 0 }, broadcast (CounterNewValue 0 clientId) )"
|> Install.ClauseInCase.makeRule
|> Install.clauseInCase

If you need additional configuration, check the `withInsertAfter` and `withCustomErrorMessage` functions.

Expand Down Expand Up @@ -110,7 +110,7 @@ To add the clause `Aspasia` after the clause `Aristotle`, you can use the follow
"Aspasia"
"Just Aspasia"
|> Install.ClauseInCase.withInsertAfter "Aristotle"
|> Install.ClauseInCase.makeRule
|> Install.clauseInCase

This will add the clause `Aspasia` after the clause `Aristotle` in the `stringToPhilosopher` function, resulting in:

Expand Down Expand Up @@ -151,7 +151,7 @@ You also can add the clause after another clause of choice with the `withInsertA
"ResetCounter"
"( { model | counter = 0 }, broadcast (CounterNewValue 0 clientId) )"
|> Install.ClauseInCase.withInsertAtBeginning
|> Install.ClauseInCase.makeRule
|> Install.clauseInCase

In this case we will have

Expand Down Expand Up @@ -184,7 +184,7 @@ withInsertAtBeginning (Internal.Config config_) =
"ResetCounter"
"( { model | counter = 0 }, broadcast (CounterNewValue 0 clientId) )"
|> Install.ClauseInCase.withCustomErrorMessage "Add handler for ResetCounter" []
|> Install.ClauseInCase.makeRule
|> Install.clauseInCase

-}
withCustomErrorMessage : String -> List String -> Config -> Config
Expand Down
6 changes: 4 additions & 2 deletions src/Install/FieldInTypeAlias.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ in a specified module. For example, if you put the code below in your
`quot: String` to the type alias `FrontendModel` in the `Types` module.

-- code for ReviewConfig.elm:
Install.FieldInTypeAlias.makeRule "Types" "FrontendModel" [ "clientName: String", "quot: String" ]
Install.FieldInTypeAlias.config "Types" "FrontendModel" [ "clientName: String", "quot: String" ]
|> Install.fieldInTypeAlias

Thus we will have

Expand Down Expand Up @@ -42,7 +43,8 @@ type alias Config =

After running the rule with the following code:

Install.FieldInTypeAlias.makeRule "Types" "FrontendModel" [ "clientName: String", "quot: String" ]
Install.FieldInTypeAlias.config "Types" "FrontendModel" [ "clientName: String", "quot: String" ]
|> Install.fieldInTypeAlias

we will have

Expand Down
4 changes: 2 additions & 2 deletions src/Install/Function/ReplaceFunction.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Install.Function.ReplaceFunction exposing (Config, config)
"view"
"""view model =
Html.text "This is a test\""""
|> Install.Function.ReplaceFunction.makeRule
|> Install.replaceFunction

Running this rule will replace the function `view` in the module `Frontend` with the provided implementation.

Expand All @@ -20,7 +20,7 @@ The form of the rule is the same for nested modules:
"Foo.Bar"
"earnInterest"
"hoho model = { model | interest = 1.03 * model.interest }"
|> Install.Function.ReplaceFunction.makeRule
|> Install.replaceFunction

@docs Config, config

Expand Down
6 changes: 4 additions & 2 deletions src/Install/Initializer.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ the `ReviewConfig` item below, you specify the module name, the function
name, as well as a list of item `{field = <fieldName>, value = <value>}`
to be added to the function.

Install.Initializer.makeRule "Main"
Install.Initializer.config "Main"
"init"
[ { field = "message", value = "\"hohoho!\"" }, { field = "counter", value = "0" } ]
|> Install.initializer

Thus we will have

Expand Down Expand Up @@ -40,9 +41,10 @@ As in the `ReviewConfig` item below, you specify
the module name, the function name, as well as the
field name and value to be added to the function:

Install.Initializer.makeRule "Main"
Install.Initializer.config "Main"
"init"
[ { field = "message", value = "\"hohoho!\"" }, { field = "counter", value = "0" } ]
|> Install.initializer

-}
config : String -> String -> List { field : String, value : String } -> Config
Expand Down
Loading