diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 80a0dff..34876be 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -6,23 +6,35 @@ on: - main jobs: - build_doc: + build: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup OCaml - uses: avsm/setup-ocaml@v2 + uses: ocaml/setup-ocaml@v2 with: - ocaml-compiler: 4.14.0 + ocaml-compiler: 5.00 - name: Pin locally run: opam pin -y add -n . - name: Install locally run: opam install -y odoc metadata - name: Build doc run: opam exec dune build @doc - - name: Deploy doc - uses: JamesIves/github-pages-deploy-action@4.1.6 + - name: Upload website artifact + uses: actions/upload-pages-artifact@v2 with: - branch: gh-pages - folder: _build/default/_doc/_html + path: _build/default/_doc/_html + deploy: + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy website + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8828deb..2cd11e8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,10 +4,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: ocaml/setup-ocaml@v2 + - name: Checkout + uses: actions/checkout@v4 + - name: Setup OCaml + uses: ocaml/setup-ocaml@v2 with: - ocaml-compiler: 4.14.0 + ocaml-compiler: 5.00 - name: Install required packages run: sudo apt install ffmpeg - name: Pin package diff --git a/CHANGES.md b/CHANGES.md index 6cbf0dd..0749171 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ 0.3.0 (unreleased) ===== +- Add basic example. - Add support for bigarray values - Use `Unix.map_file` to represent large metadata values. diff --git a/README.md b/README.md index 4920398..2d7b777 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,29 @@ supported: - image formats: jpeg and png - video formats: mp4 and avi +Usage +----- + +Basic usage is + +```ocaml +let () = + let filename = "test.mp3" in + let metadata = Metadata.Any.parse_file filename in + List.iter (fun (k,v) -> Printf.printf "- %s: %s\n" k v) metadata +``` + +In the above example, the function `Metadata.Any.parse_file`{.ocaml} takes a +file name as argument and returns an association list describing its +metadata. It consists of pairs of strings being the name of the metadata and its +value. + Installing ---------- The preferred way is via opam: -``` +```bash opam pin add . opam install metadata ``` diff --git a/examples/basic.ml b/examples/basic.ml new file mode 100644 index 0000000..3e7d06e --- /dev/null +++ b/examples/basic.ml @@ -0,0 +1,6 @@ +(** Basic usage of the library. *) + +let () = + let filename = "test.mp3" in + let metadata = Metadata.Any.parse_file filename in + List.iter (fun (k,v) -> Printf.printf "- %s: %s\n" k v) metadata diff --git a/examples/dune b/examples/dune index 99f6f48..ebcc0c0 100644 --- a/examples/dune +++ b/examples/dune @@ -3,6 +3,11 @@ (modules meta) (libraries str metadata)) +(executable + (name basic) + (modules basic) + (libraries metadata)) + (executable (name dump) (modules dump) @@ -28,6 +33,7 @@ (glob_files id3v2/*.mp3)) (action (progn + (run ./basic.exe) (run ./test.exe) (run ./meta.exe %{deps}))))