Skip to content

Commit

Permalink
Move content into files and use nicer blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Kubica <marek@tarides.com>
  • Loading branch information
Leonidas-from-XIV committed Sep 17, 2024
1 parent 71e465f commit be930f2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
34 changes: 16 additions & 18 deletions doc/tutorials/dune-package-management/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,34 @@ management for the very first time.
The best way to work with the package management is to declare your
dependencies in the `dune-project` file, like so:

```dune
(lang dune 3.17)
(name test)
::::{dropdown} `dune-project`
:icon: file-code

(package
(name test)
(depends
(ocaml (>= 4.14))))
```
:::{literalinclude} setup/dune-project
:language: dune
:::

This setup will be very familiar to people who use Dune to generate their OPAM
files as this is also exactly the information that is used to generate the
files using the `generate_opam_files` stanza.

The code we want to execute goes into our `test.ml`:

```ocaml
let langs = ["OCaml"; "Rust"]
::::{dropdown} `test.ml`
:icon: file-code

let () =
let s = String.concat ", " langs in
Format.printf "Hello, %s!\n" s
```
:::{literalinclude} setup/test.ml
:language: ocaml
:::

And finally we need to declare this module an executable using a `dune` file:

```dune
(executable
(public_name test))
```
::::{dropdown} `dune`
:icon: file-code

:::{literalinclude} setup/dune
:language: dune
:::

## Locking dependencies

Expand Down
2 changes: 2 additions & 0 deletions doc/tutorials/dune-package-management/setup/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(executable
(public_name test))
7 changes: 7 additions & 0 deletions doc/tutorials/dune-package-management/setup/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(lang dune 3.17)
(name test)

(package
(name test)
(depends
(ocaml (>= 4.14))))
5 changes: 5 additions & 0 deletions doc/tutorials/dune-package-management/setup/test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let langs = ["OCaml"; "Rust"]

let () =
let s = String.concat ", " langs in
Format.printf "Hello, %s!\n" s
1 change: 1 addition & 0 deletions doc/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ These tutorials are hands-on lessons to learn about Dune.
:maxdepth: 1

developing-with-dune/index
dune-package-management/index
:::

0 comments on commit be930f2

Please sign in to comment.