Skip to content

Commit

Permalink
feat: add sample
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobslisboa committed Dec 9, 2024
1 parent e76368c commit 29a6cc4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
project_name = astexplorer-refmt

DUNE = opam exec -- dune
opam_file = $(project_name).opam

.PHONY: help
help:
@echo "";
@echo "List of available make commands";
@echo "";
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}';
@echo "";

.PHONY: build-dev
dev:
$(DUNE) build -w @all

.PHONY: clean
clean: ## Clean artifacts
$(DUNE) clean

.PHONY: exec
exec: ## Run the project
$(DUNE) exec $(demo)

.PHONY: format
format:
DUNE_CONFIG__GLOBAL_LOCK=disabled $(DUNE) build @fmt --auto-promote

.PHONY: format-check
format-check:
$(DUNE) build @fmt

.PHONY: create-switch
create-switch: ## Create opam switch
opam switch create . 5.1.1 --deps-only --with-dev-setup -y

.PHONY: install
install:
$(DUNE) build @install
opam install . --deps-only --with-test

.PHONY: init
init: create-switch install
4 changes: 4 additions & 0 deletions src/example/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let code = "let x = 1";

let ast = window.parseReason(code);
window.document.querySelector("#app").innerHTML = ast;
8 changes: 6 additions & 2 deletions src/index.html → src/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script
type="text/javascript"
src="../_esy/default/build/default/src/AstExplorerRefmt.bc.js"
src="../dist/ast_explorer_refmt.bc.js"
></script>
</head>
<body>
<div id="app"></div>
<pre id="app"></pre>
</body>
<script
type="text/javascript"
src="./example.js"
></script>
</html>

0 comments on commit 29a6cc4

Please sign in to comment.