package spin

  1. Overview
  2. Docs

Source file ppx.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(* Generated by: ocaml-crunch
   Creation date: Sat, 17 May 2025 12:17:10 GMT *)

module Internal = struct
  let d_154dd21082460ed627fc1ccd4bb486c0 = "(lang dune 2.0)\n\n(name {{ project_slug }})\n\n{% if github_username %}(documentation \"https://{{ github_username }}.github.io/{{ project_slug }}/\"){% endif %}\n\n{% if github_username %}(source\n (github {{ github_username }}/{{ project_slug }})){% endif %}\n\n(license ISC)\n\n(authors\n \"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\")\n\n(maintainers\n \"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\")\n\n(generate_opam_files true)\n\n(allow_approximate_merlin)\n\n(package\n (name {{ project_slug }})\n (synopsis \"{{ project_description }}\")\n (description \"{{ project_description }}\")\n (depends\n  (ocaml\n   (>= 4.08.0))\n  dune\n  {%- if test_framework == 'Alcotest' %}\n  (alcotest :with-test)\n  {%- endif %}\n  (odoc :with-doc)\n  (ppxlib :build)))\n"

  let d_1c85d519cd01472be225b0493a92e13c = "# {{ project_name }}\n\n{%- if ci_cd == 'Github' and github_username %}\n\n[![Actions Status](https://github.com/{{ github_username }}/{{ project_slug }}/workflows/CI/badge.svg)](https://github.com/{{ github_username }}/{{ project_slug }}/actions)\n{%- endif %}\n\n{%- if project_description %}\n\n{{ project_description }}\n{%- endif %}\n\n## Installation\n\n### With `opam` on native projects\n\n```bash\nopam install {{ project_slug }}\n```\n\n### With `esy` on native projects\n\n```bash\nesy add @opam/{{ project_slug }}\n```\n\n## Usage\n\n`{{ project_snake }}` implements a ppx that transforms the `[%{{ project_snake }}]` extension into an expression that adds 5 to the integer passed in parameter.\n\nThe code:\n\n```ocaml\n[%{{ project_snake }} 5]\n```\n\nWill transform to something like:\n\n```ocaml\n5 + 5\n```\n\n## Contributing\n\nTake a look at our [Contributing Guide](CONTRIBUTING.md).\n"

  let d_3a7b24ddee4af75e50875d771ad5161f = "(executable\n (name main)\n (public_name {{ project_slug }})\n (libraries {{ project_snake }} cmdliner fmt fmt.tty logs.fmt logs.cli))\n"

  let d_3d62b7f3b28f90f8b1847b2f8d90bd0c = "open Alcotest\n\nlet test_simple_addition () =\n    let result = [%{{ project_snake }} 5] in\n    check int \"same value\" 10 result\n\nlet suite = [ \"5 + 5 should equal 10\", `Quick, test_simple_addition ]\n\nlet () =\n  Alcotest.run \"{{ project_slug }}\" [ \"{{ project_snake | capitalize }}\", suite ]\n"

  let d_5791af8d227385d694ab392e1309fa21 = "open Ppxlib\n\nlet expand ~loc ~path:_ (num : int) =\n  let (module Builder) = Ast_builder.make loc in\n  [%expr [%e Builder.eint num] + 5]\n\nlet name = \"{{ project_snake }}\"\n\nlet extension =\n  Extension.declare\n    name\n    Extension.Context.expression\n    (let open Ast_pattern in\n    single_expr_payload (eint __))\n    expand\n\nlet rule = Context_free.Rule.extension extension\n\nlet () = Driver.register_transformation name ~rules:[ rule ]\n"

  let d_75608a2495961c048bb914e395df8d2a = "(** Main module *)\n"

  let d_7e279157f3da7f4f84c9dcb062e18620 = "(library\n (name {{ project_snake }})\n (public_name {{ project_slug }})\n (libraries ppxlib)\n (kind ppx_rewriter)\n (preprocess\n  (pps ppxlib.metaquot ppxlib.runner)))\n"

  let d_90a0a50ee43d40e9a676bd5de3454a00 = "(inherit (official bin))\n\n(name ppx)\n(description \"PPX library\")\n"

  let d_9e2d10df8673be92596ec81a8ee5e55e = "(** {{ project_description }} *)\n\nval name : string\n\nval extension : Ppxlib.Extension.t\n\nval rule : Ppxlib.Context_free.Rule.t\n"

  let d_a128dfde613083a655bac2201af36450 = "open Ppxlib\n\nlet _ = Driver.run_as_ppx_rewriter ()\n"

  let d_c08eb21d7d9264b648b44e31d8009983 = "# PPX\n\nPPX library\n\n```bash\nspin new ppx\n```\n\n## Acknowledgments\n\nThis template is inspired by these awesome projects:\n\n- [ppx-examples](https://github.com/ttinythings/ppx-examples/) - PPX Examples written with ReasonML and Ppxlib\n"

  let d_c4b11419ee9578cbbd8a1d7c9cb26181 = "(tests\n (names {{ project_snake }}_test)\n (package {{ project_slug }})\n (libraries alcotest {{ project_snake }})\n (preprocess\n  (pps {{ project_slug }})))\n"

  let d_faae66d72ddafe77b5cbf2d3c2c310ac = "# This file is generated by dune, edit dune-project instead\nopam-version: \"2.0\"\nsynopsis: \"{{ project_description }}\"\ndescription: \"\"\"\n{{ project_description }}\n\"\"\"\nmaintainer: [\"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\"]\nauthors: [\"{{ author_name }}{% if author_email %} <{{ author_email }}>{% endif %}\"]\nlicense: \"ISC\"\n{%- if github_username %}\nhomepage: \"https://github.com/{{ github_username }}/{{ project_slug }}\"\ndoc: \"https://{{ github_username }}.github.io/{{ project_slug }}\"\nbug-reports: \"https://github.com/{{ github_username }}/{{ project_slug }}/issues\"{% endif %}\ndepends: [\n  \"ocaml\" {>= \"4.08.0\"}\n  \"dune\" {>= \"2.0\"}\n  {% if test_framework == 'Alcotest' -%}\n  \"alcotest\" {with-test}\n  {% endif -%}\n  \"odoc\" {with-doc}\n  \"ppxlib\" {build}\n]\nbuild: [\n  [\"dune\" \"subst\"] {dev}\n  [\n    \"dune\"\n    \"build\"\n    \"-p\"\n    name\n    \"-j\"\n    jobs\n    \"@install\"\n    \"@runtest\" {with-test}\n    \"@doc\" {with-doc}\n  ]\n]\n{%- if github_username %}\ndev-repo: \"git+https://github.com/{{ github_username }}/{{ project_slug }}.git\"{% endif %}\n"

  let file_chunks = function
    | "README.md" | "/README.md" -> Some [ d_c08eb21d7d9264b648b44e31d8009983; ]
    | "spin" | "/spin" -> Some [ d_90a0a50ee43d40e9a676bd5de3454a00; ]
    | "template/README.md" | "/template/README.md" -> Some [ d_1c85d519cd01472be225b0493a92e13c; ]
    | "template/bin/dune" | "/template/bin/dune" -> Some [ d_3a7b24ddee4af75e50875d771ad5161f; ]
    | "template/bin/main.ml" | "/template/bin/main.ml" -> Some [ d_a128dfde613083a655bac2201af36450; ]
    | "template/bin/main.mli" | "/template/bin/main.mli" -> Some [ d_75608a2495961c048bb914e395df8d2a; ]
    | "template/dune-project" | "/template/dune-project" -> Some [ d_154dd21082460ed627fc1ccd4bb486c0; ]
    | "template/lib/dune" | "/template/lib/dune" -> Some [ d_7e279157f3da7f4f84c9dcb062e18620; ]
    | "template/lib/{{ project_snake }}.ml" | "/template/lib/{{ project_snake }}.ml" -> Some [ d_5791af8d227385d694ab392e1309fa21; ]
    | "template/lib/{{ project_snake }}.mli" | "/template/lib/{{ project_snake }}.mli" -> Some [ d_9e2d10df8673be92596ec81a8ee5e55e; ]
    | "template/test/dune" | "/template/test/dune" -> Some [ d_c4b11419ee9578cbbd8a1d7c9cb26181; ]
    | "template/test/{{ project_snake }}_test.ml" | "/template/test/{{ project_snake }}_test.ml" -> Some [ d_3d62b7f3b28f90f8b1847b2f8d90bd0c; ]
    | "template/{{ project_slug }}.opam" | "/template/{{ project_slug }}.opam" -> Some [ d_faae66d72ddafe77b5cbf2d3c2c310ac; ]
    | _ -> None

  let file_list = [ "README.md"; "spin"; "template/README.md"; "template/bin/dune"; "template/bin/main.ml"; "template/bin/main.mli"; "template/dune-project"; "template/lib/dune"; "template/lib/{{ project_snake }}.ml"; "template/lib/{{ project_snake }}.mli"; "template/test/dune"; "template/test/{{ project_snake }}_test.ml"; "template/{{ project_slug }}.opam"; ]
end

let file_list = Internal.file_list

let read name =
  match Internal.file_chunks name with
  | None -> None
  | Some c -> Some (String.concat "" c)

let hash = function
  | "README.md" | "/README.md" -> Some "c08eb21d7d9264b648b44e31d8009983"
  | "spin" | "/spin" -> Some "90a0a50ee43d40e9a676bd5de3454a00"
  | "template/README.md" | "/template/README.md" -> Some "1c85d519cd01472be225b0493a92e13c"
  | "template/bin/dune" | "/template/bin/dune" -> Some "3a7b24ddee4af75e50875d771ad5161f"
  | "template/bin/main.ml" | "/template/bin/main.ml" -> Some "a128dfde613083a655bac2201af36450"
  | "template/bin/main.mli" | "/template/bin/main.mli" -> Some "75608a2495961c048bb914e395df8d2a"
  | "template/dune-project" | "/template/dune-project" -> Some "154dd21082460ed627fc1ccd4bb486c0"
  | "template/lib/dune" | "/template/lib/dune" -> Some "7e279157f3da7f4f84c9dcb062e18620"
  | "template/lib/{{ project_snake }}.ml" | "/template/lib/{{ project_snake }}.ml" -> Some "5791af8d227385d694ab392e1309fa21"
  | "template/lib/{{ project_snake }}.mli" | "/template/lib/{{ project_snake }}.mli" -> Some "9e2d10df8673be92596ec81a8ee5e55e"
  | "template/test/dune" | "/template/test/dune" -> Some "c4b11419ee9578cbbd8a1d7c9cb26181"
  | "template/test/{{ project_snake }}_test.ml" | "/template/test/{{ project_snake }}_test.ml" -> Some "3d62b7f3b28f90f8b1847b2f8d90bd0c"
  | "template/{{ project_slug }}.opam" | "/template/{{ project_slug }}.opam" -> Some "faae66d72ddafe77b5cbf2d3c2c310ac"
  | _ -> None

let size = function
  | "README.md" | "/README.md" -> Some 231
  | "spin" | "/spin" -> Some 65
  | "template/README.md" | "/template/README.md" -> Some 860
  | "template/bin/dune" | "/template/bin/dune" -> Some 132
  | "template/bin/main.ml" | "/template/bin/main.ml" -> Some 51
  | "template/bin/main.mli" | "/template/bin/main.mli" -> Some 19
  | "template/dune-project" | "/template/dune-project" -> Some 779
  | "template/lib/dune" | "/template/lib/dune" -> Some 165
  | "template/lib/{{ project_snake }}.ml" | "/template/lib/{{ project_snake }}.ml" -> Some 436
  | "template/lib/{{ project_snake }}.mli" | "/template/lib/{{ project_snake }}.mli" -> Some 127
  | "template/test/dune" | "/template/test/dune" -> Some 155
  | "template/test/{{ project_snake }}_test.ml" | "/template/test/{{ project_snake }}_test.ml" -> Some 290
  | "template/{{ project_slug }}.opam" | "/template/{{ project_slug }}.opam" -> Some 1069
  | _ -> None
OCaml

Innovation. Community. Security.