Skip to content

Commit

Permalink
Merge pull request #38 from avsm/dune-port
Browse files Browse the repository at this point in the history
Dune port + opam metadata 2 + mustache-unix package
  • Loading branch information
rgrinberg committed Mar 7, 2019
2 parents 0333e46 + adefef4 commit ef23578
Show file tree
Hide file tree
Showing 20 changed files with 113 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_build/
TAGS
*.install
.merlin
.merlin
.*.swp
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ script: bash -ex ./.travis-docker.sh
env:
global:
- PACKAGE="mustache"
- PINS="mustache:."
- PINS="mustache-unix:. mustache:."
matrix:
- DISTRO="debian-stable" OCAML_VERSION="4.02.3"
- DISTRO="debian-testing" OCAML_VERSION="4.03.0"
- DISTRO="debian-unstable" OCAML_VERSION="4.04.0"
- DISTRO="ubuntu-16.04" OCAML_VERSION="4.05.0"
- DISTRO="alpine-3.5" OCAML_VERSION="4.04.0"
- DISTRO="fedora-25" OCAML_VERSION="4.03.0"
- DISTRO="debian-stable" OCAML_VERSION="4.03"
- DISTRO="debian-testing" OCAML_VERSION="4.04"
- DISTRO="fedora" OCAML_VERSION="4.05"
- DISTRO="ubuntu-lts" OCAML_VERSION="4.06"
- DISTRO="alpine" OCAML_VERSION="4.07"
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 3.1.0

* Add a `mustache-unix` package under which `mustache-cli` is installed. (@avsm)
* Update opam metadata to 2.0 format (@avsm)
* Port build to Dune (@avsm)
* Fix ocamldoc syntax to be compatible with odoc (@avsm)
* Test OCaml 4.06 and 4.07 as well (@avsm)

### 3.0.2 (08-05-2017)

* Add .descr file to repository
Expand Down
25 changes: 6 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
JBUILDER ?= jbuilder

all:
@$(JBUILDER) build @install @DEFAULT
dune build

test:
@$(JBUILDER) runtest
dune runtest

check: test

clean:
@$(JBUILDER) clean

.PHONY: check test all clean

REPO=../opam-repository
PACKAGES=$(REPO)/packages
@dune clean

pkg-%:
topkg opam pkg -n $*
mkdir -p $(PACKAGES)/$*
cp -r _build/$*.* $(PACKAGES)/$*/
rm -f $(PACKAGES)/$*/$*.opam
cd $(PACKAGES) && git add $*
doc:
dune build @doc

PKGS=$(basename $(wildcard *.opam))
opam-pkg:
$(MAKE) $(PKGS:%=pkg-%)
.PHONY: check test all clean doc
7 changes: 7 additions & 0 deletions bin/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(executable
(name mustache_cli)
(public_name mustache-cli)
(modules mustache_cli)
(package mustache-unix)
(libraries mustache ezjsonm))

2 changes: 1 addition & 1 deletion examples/mustache_cli.ml → bin/mustache_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let run json_filename template_filename =
apply_mustache j t

let usage () =
print_endline "Usage: $0 json_filename template_filename"
print_endline "Usage: mustache-cli json_filename template_filename"

let () =
match Sys.argv with
Expand Down
3 changes: 3 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 1.0)
(name mustache)
(using menhir 2.0)
5 changes: 5 additions & 0 deletions examples/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(executable
(name mustache_example)
(modules mustache_example)
(libraries mustache ezjsonm))

9 changes: 0 additions & 9 deletions examples/jbuild

This file was deleted.

11 changes: 11 additions & 0 deletions lib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(ocamllex mustache_lexer)

(menhir
(modules mustache_parser))

(library
(name mustache)
(public_name mustache)
(synopsis "Mustache.js templates in OCaml")
(libraries menhirLib)
(wrapped false))
12 changes: 0 additions & 12 deletions lib/jbuild

This file was deleted.

7 changes: 4 additions & 3 deletions lib/mustache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE. }}}*)
open MoreLabels

[@@@warning "-6"]
include Mustache_types

module List = ListLabels
Expand Down Expand Up @@ -272,7 +273,7 @@ module Without_locations = struct
in
let print_indent indent =
for i = 0 to indent - 1 do
for _ = 0 to indent - 1 do
Format.pp_print_char fmt ' '
done
in
Expand Down Expand Up @@ -331,7 +332,7 @@ module Without_locations = struct
| None, true -> raise (Missing_partial name)
end
| Comment c -> ()
| Comment _c -> ()
| Concat templates ->
List.iter (fun x -> render' indent x js) templates
Expand Down
8 changes: 4 additions & 4 deletions lib/mustache.mli
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ val to_string : t -> string
For each partial [p], if [partials p] is [Some t] then the partial is
substituted by [t]. Otherwise, the partial is substituted by the empty
string is [strict] is [false]. If [strict] is [true], the [Missing_partial
p] exception is raised. *)
string is [strict] is [false]. If [strict] is [true], the
{!Missing_partial} exception is raised. *)
val render_fmt :
?strict:bool ->
?partials:(name -> t option) ->
Expand Down Expand Up @@ -186,8 +186,8 @@ module With_locations : sig
For each partial [p], if [partials p] is [Some t] then the partial is
substituted by [t]. Otherwise, the partial is substituted by the empty
string is [strict] is [false]. If [strict] is [true], the [Missing_partial
p] exception is raised. *)
string is [strict] is [false]. If [strict] is [true], the {!Missing_partial}
exception is raised. *)
val render_fmt :
?strict:bool ->
?partials:(name -> t option) ->
Expand Down
5 changes: 2 additions & 3 deletions lib/mustache_lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
{
open Lexing
open Mustache_parser
open Mustache_types

let tok_arg f lexbuf =
let start_p = lexbuf.Lexing.lex_start_p in
Expand Down Expand Up @@ -106,7 +105,7 @@ and mustache = parse
let loc_end = get_loc () in
(tok, loc_start, loc_end)
in
let rec slurp_line () =
let slurp_line () =
let rec loop acc =
let tok = get_tok () in
match tok with
Expand All @@ -124,7 +123,7 @@ and mustache = parse
done;
!ret
in
let rec skip_blanks l =
let skip_blanks l =
let rec loop skipped = function
| (RAW s, _, _) :: toks when is_blank s ->
loop (skipped + String.length s) toks
Expand Down
14 changes: 14 additions & 0 deletions lib_test/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(executables
(names test_mustache spec_mustache)
(libraries mustache oUnit ezjsonm))

(alias
(name runtest)
(deps test_mustache.exe ../specs/comments.json ../specs/interpolation.json
../specs/partials.json ../specs/sections.json ../specs/inverted.json)
(action (run ./test_mustache.exe)))

(alias
(name runtest)
(deps spec_mustache.exe)
(action (run %{deps})))
21 changes: 0 additions & 21 deletions lib_test/jbuild

This file was deleted.

1 change: 1 addition & 0 deletions lib_test/test_mustache.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@@@warning "-6"]
open OUnit2
open Mustache

Expand Down
23 changes: 23 additions & 0 deletions mustache-unix.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
opam-version: "2.0"
maintainer: "rudi.grinberg@gmail.com"
authors: ["Rudi Grinberg" "Armaël Guéneau"]
license: "MIT"
homepage: "https://github.com/rgrinberg/ocaml-mustache"
doc: "http://rgrinberg.github.io/mustache/"
bug-reports: "https://github.com/rgrinberg/ocaml-mustache/issues"
depends: [
"ocaml" {>= "4.03"}
"dune" {build}
"base-unix"
"mustache"
]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
dev-repo: "git+https://github.com/rgrinberg/ocaml-mustache.git"
synopsis: "Unix utilitie for Mustache logic-less templates in OCaml"
description: """
Contains the `mustache-cli` command line utility for driving
Mustache logic-less templates.
"""
3 changes: 0 additions & 3 deletions mustache.descr

This file was deleted.

33 changes: 16 additions & 17 deletions mustache.opam
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
opam-version: "1.2"
opam-version: "2.0"
maintainer: "rudi.grinberg@gmail.com"
authors: ["Rudi Grinberg" "Armaël Guéneau"]
license: "MIT"

homepage: "https://github.com/rgrinberg/ocaml-mustache"
doc: "http://rgrinberg.github.io/mustache/"
bug-reports: "https://github.com/rgrinberg/ocaml-mustache/issues"
dev-repo: "https://github.com/rgrinberg/ocaml-mustache.git"
doc: "http://mustache.github.io/mustache.5.html"

build: [
["jbuilder" "subst" "-n" name] {pinned}
["jbuilder" "build" "-p" name "-j" jobs]
]

build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]

depends: [
"jbuilder" {build}
"ocaml" {>= "4.03"}
"dune" {build}
"menhir"
"ounit" {test}
"ezjsonm" {test}
"ounit" {with-test}
"ezjsonm" {with-test}
]
build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
]

available: [ocaml-version >= "4.02.3"]
dev-repo: "git+https://github.com/rgrinberg/ocaml-mustache.git"
synopsis: "Mustache logic-less templates in OCaml"
description: """
Read and write mustache templates, and render them by providing a json object.
"""

0 comments on commit ef23578

Please sign in to comment.