Skip to content

Latest commit

 

History

History
63 lines (37 loc) · 2.63 KB

CONTRIBUTING.md

File metadata and controls

63 lines (37 loc) · 2.63 KB

Contributing to this repository

When contributing to this repository, please first discuss the change you wish to make via issue or any other method with the owners of this repository before making a change.

Before you get started

PPXs

PPXs are not the easiest to work with, especially if it's your first time writing one. Don't be afraid to ask for help by commenting on a related GitHub issue or in the Discord: https://discord.gg/SmsJyCdH2h.

Developing

Scripts

In order to see what are the scripts available on the repository, run yarn run. It will render a list of available commands in order to build the project, build the ppx, etc.

Editor support with ocaml-lsp

Note: Wasn't able to install ocaml-lsp-server with esy, instead can use opam.

ocaml-lsp-server is only needed for development.

You would need to have opam installed.

  • cd ppx_src;
  • opam switch create . 4.12.1 --deps-only # If it's the first time you create a switch it can take a while.
  • eval $(opam env)
  • opam install -y . --deps-only
  • Profit, this should make your editor a little more smart

Testing

Unit testing is done in ReScript and rescript-jest, lives under test/__tests__.

Iterating

Working on PPXs can be a real pain because you don't get to easily see the product of your work. There are some tools to help though.

Preview PPX

See the output of your PPX as ReScript code by running yarn run preview-ppx <file name>

Gotcha: This PPX'd output isn't ReScript syntax generated by the PPX. The PPX runs on the AST, which is OCaml. What you see here is the result of the transformed AST rendered back into ReScript by the compiler's formatting tool

If you want to see what's really going on under the hood, read more:

Inspect the Parsetree (AST)

See a text representation of the tree you're really operating on, and the real results of your PPX by running yarn run print-parse-tree-with-ppx <file name>

You'll probably get compiler errors, because that's calling a private API of bsc that isn't including dependencies. But your goal here is really just to inspect the tree.

Figure out what to write

I suggest that when you're trying to get something written, you write the ReScript syntax for what you're trying to achieve, inspect its AST using the command above, and then use the same command on your PPX to see what you're actually getting.