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

Improve PPX template #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
79 changes: 79 additions & 0 deletions template/ppx/template/CONTRIBUTING.md
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.
```
3 changes: 1 addition & 2 deletions template/ppx/template/bin/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(executable
(name main)
(public_name {{ project_slug }})
(libraries {{ project_snake }} cmdliner fmt fmt.tty logs.fmt logs.cli))
(libraries {{ project_snake }}))
2 changes: 1 addition & 1 deletion template/ppx/template/bin/main.ml
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 ()