Skip to content

Commit

Permalink
Add ocaml-mdx verification of the tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
craigfe committed Aug 8, 2019
1 parent f66b0be commit 8ebf4fb
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ _build/
.cache/
public/
node_modules/
*.install
*.merlin
.#*
package-lock.json
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
language: node_js
node_js:
- "11"
script: npm run lint
matrix:
include:
- language: node_js
node_js:
- "11"
script: npm run lint

- language: c
install: wget https://raw.githubusercontent.com/ocaml/ocaml-travisci-skeleton/master/.travis-opam.sh
script: bash ./.travis-opam.sh
env:
- OCAML_VERSION=4.08
- PACKAGE="irmin-website"
- PINS="irmin-website:."

2 changes: 1 addition & 1 deletion data/tutorial/contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ A convenience function for adding a timestamp to a `C.t` value:
The merge operation for `Lww_register` is slightly different than the ones covered so far. It will not attempt to merge any values, instead it will pick the newest value based on the attached timestamp.

```ocaml
let merge ~old (a, timestamp_a) (b, timestamp_b) =
let merge ~old:_ (a, timestamp_a) (b, timestamp_b) =
match Int64.compare timestamp_a timestamp_b with
| 0 ->
if Irmin.Type.equal C.t a b then
Expand Down
11 changes: 11 additions & 0 deletions data/tutorial/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(rule
(targets mdx.ml)
(deps (:markdown (glob_files *.md)))
(action (with-stdout-to %{targets}
(bash "echo %{markdown} | xargs --max-args=1 ocaml-mdx pp")))
)

(test
(name mdx)
(libraries irmin irmin-unix lwt hiredis)
)
16 changes: 0 additions & 16 deletions data/tutorial/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,6 @@ Each of these also has an `_exn` variant which may raise an exception instead of

For example, you can pull a repo and list the files in the root of the project:

```ocaml
open Irmin_unix
module Git_mem_store = Git.Mem.KV(Irmin.Contents.String)
module Sync = Irmin.Sync(Git_mem_store)
let remote = Git_mem_store.remote "git://github.com/mirage/irmin.git"
let main =
Git_mem_store.Repo.v config >>= Git_mem_store.master >>= fun t ->
Sync.pull_exn t remote `Set >>= fun _ ->
Git_mem_store.list t [] >|= List.iter (fun (step, kind) ->
match kind with
| `Contents -> Printf.printf "FILE %s\n" step
| `Node -> Printf.printf "DIR %s\n" step
)
let () = Lwt_main.run main
```

## JSON Contents

Most examples in this tutorial use string contents, so I will provide some further information about using JSON values.
Expand Down
2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.11)
(name irmin-website)
34 changes: 34 additions & 0 deletions irmin-website.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
opam-version: "2.0"
name: "irmin-website"
synopsis: "Public homepage of Irmin"
maintainer: "Craig Ferguson <[email protected]>"
authors: ["Craig Ferguson <[email protected]>"]
homepage: "https://github.com/tarides/irmin.io"
bug-reports: "https://github.com/tarides/irmin.io/issues"
dev-repo: "git+https://github.com/tarides/irmin.io.git"

build: [
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name] {with-test}
]

depends: [
"ocaml" {>= "4.06.0"}
"dune" {build & >= "1.7.0"}
"irmin"
"irmin-unix"
"mdx"
"lwt"
"hiredis"
]

pin-depends: [
["irmin.dev" "git+https://github.com/mirage/irmin.git"]
["irmin-unix.dev" "git+https://github.com/mirage/irmin.git"]
["irmin-mem.dev" "git+https://github.com/mirage/irmin.git"]
["irmin-git.dev" "git+https://github.com/mirage/irmin.git"]
["irmin-http.dev" "git+https://github.com/mirage/irmin.git"]
["irmin-fs.dev" "git+https://github.com/mirage/irmin.git"]
["irmin-graphql.dev" "git+https://github.com/mirage/irmin.git"]
]

0 comments on commit 8ebf4fb

Please sign in to comment.