Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noredink/elm-review-extract-api
A rule to extract the API of Elm applications using elm-review's data extraction facilities
https://github.com/noredink/elm-review-extract-api
Last synced: about 2 months ago
JSON representation
A rule to extract the API of Elm applications using elm-review's data extraction facilities
- Host: GitHub
- URL: https://github.com/noredink/elm-review-extract-api
- Owner: NoRedInk
- License: bsd-3-clause
- Created: 2024-02-01T15:56:57.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-04T16:40:11.000Z (11 months ago)
- Last Synced: 2024-05-08T23:24:57.259Z (8 months ago)
- Language: Elm
- Size: 38.1 KB
- Stars: 3
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `elm-review-extract-api`
An elm-review rule with extractor to extract the public interface (that is ports, their types, and flags) of all entrypoints in an Elm application.
## Say what now?
Imagine you have this beautiful application:
``` elm
port module Main exposing (main)port send : { data : String, finished : Bool } -> Cmd msg
port recv : (List String -> msg) -> Sub msg
type alias Flags =
{ more : String
, stuff : Int
}main : Program Flags () ()
main =
Platform.worker
{ init = \_ -> ( (), Cmd.none )
, update = \_ _ -> ( (), send { data = "hi", finished = False } )
, subscriptions = \_ -> recv (\_ -> ())
}
```Now, with this rule configured, running `elm-review --report=json --extract` can yield us this extract:
``` json
{
"ports": {
"send": {
"type": "record",
"fields": {
"data": "string",
"finished": "bool"
}
},
"recv": {
"type": "list",
"content": "string"
}
},
"entryPoints": {
"Main": {
"cmds": ["send"],
"subs": ["recv"],
"flags": {
"type": "record",
"fields": {
"more": "string",
"stuff": "int"
}
}
}
}
}
```Having this information isn't particularily valuable on its own, but it can be used for further processing, such as generating typescript definition files to ensure you use your app correctly!