-
Notifications
You must be signed in to change notification settings - Fork 15
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
Improve PPX template #124
Open
pkel
wants to merge
3
commits into
tmattio:main
Choose a base branch
from
pkel:ppx_template
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Improve PPX template #124
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Contributing | ||
|
||
## Setup your development environment | ||
|
||
You need Opam, you can install it by following [Opam's documentation](https://opam.ocaml.org/doc/Install.html). | ||
|
||
With Opam installed, you can install the dependencies in a new local switch with: | ||
|
||
```bash | ||
make switch | ||
``` | ||
|
||
Or globally, with: | ||
|
||
```bash | ||
make deps | ||
``` | ||
|
||
Then, build the project with: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
### Running the PPX | ||
|
||
After building the project, you can run the main binary on an OCaml source file to see what the PPX is doing. | ||
|
||
```bash | ||
opam exec -- dune exec bin/main.exe test/{{ project_snake }}_test.ml | ||
``` | ||
|
||
### Running Tests | ||
|
||
You can run the test compiled executable: | ||
|
||
```bash | ||
make test | ||
``` | ||
|
||
### Building documentation | ||
|
||
Documentation for the libraries in the project can be generated with: | ||
|
||
```bash | ||
make doc | ||
make servedoc | ||
``` | ||
|
||
### Repository Structure | ||
|
||
The following snippet describes {{ project_name }}'s repository structure. | ||
|
||
```text | ||
. | ||
├── bin/ | ||
| Source for {{ project_slug }}'s binaries. This links to the rewriter defined in `lib/`. | ||
│ | ||
├── lib/ | ||
| Source for {{ project_name }}'s library. Contains {{ project_name }}'s rewriting functionalities. | ||
│ | ||
├── test/ | ||
| Unit tests and integration tests for {{ project_name }}. | ||
│ | ||
├── dune-project | ||
| Dune file used to mark the root of the project and define project-wide parameters. | ||
| For the documentation of the syntax, see https://dune.readthedocs.io/en/stable/dune-files.html#dune-project | ||
│ | ||
├── LICENSE | ||
│ | ||
├── Makefile | ||
| Make file containing common development command. | ||
│ | ||
├── README.md | ||
│ | ||
└── {{ project_slug }}.opam | ||
Opam package definition. | ||
To know more about creating and publishing opam packages, see https://opam.ocaml.org/doc/Packaging.html. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(executable | ||
(name main) | ||
(public_name {{ project_slug }}) | ||
(libraries {{ project_snake }} cmdliner fmt fmt.tty logs.fmt logs.cli)) | ||
(libraries {{ project_snake }})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
open Ppxlib | ||
|
||
let _ = Driver.run_as_ppx_rewriter () | ||
let _ = Driver.standalone () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
open Ppxlib | ||
|
||
let _ = Driver.standalone () |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this file be
.ml
and not.mli
? Also should we add a dune file with a test stanza for it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right.
There is a story to this. The original template had no
test/{{ project_snake }}_test.mli
andmake test
was complaining that themli
file is missing. I was confused and tried to copy the emptybin/main.mli
totest/{{ project_snake }}_test.mli
. Missed ani
obviously. But how can it first ask for anmli
and then accept an invalidmli
?I'll try again.