From 2079249e19025e94472753c8d086c7611ca1eec1 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 17:33:36 +0800 Subject: [PATCH 1/8] build: make Mldoc cross-buildable with Dune --- lib/dune | 2 +- lib/mldoc.ml | 2 ++ mldoc.opam | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dune b/lib/dune index 59ae5319..e1b962fb 100644 --- a/lib/dune +++ b/lib/dune @@ -18,4 +18,4 @@ uri str xmlm) - (wrapped false)) + (wrapped true)) diff --git a/lib/mldoc.ml b/lib/mldoc.ml index 3133935f..51ebfb6f 100644 --- a/lib/mldoc.ml +++ b/lib/mldoc.ml @@ -3,6 +3,8 @@ module Document = Document module Block = Type_parser.Block module Inline = Inline +module Nested_link = Nested_link +module Pos = Pos module Exporters = Exporter.Exporters module Conf = Conf module Exporter = Exporter diff --git a/mldoc.opam b/mldoc.opam index d1432635..abb76fa5 100644 --- a/mldoc.opam +++ b/mldoc.opam @@ -43,5 +43,5 @@ build: [ ] pin-depends: [ [ "angstrom.dev" "git+https://github.com/logseq/angstrom#fork" ] - [ "xmlm.dev" "git+https://github.com/logseq/xmlm#fork" ] + [ "xmlm.dev" "git+https://github.com/logseq/xmlm#49d5f7d265a73b307bd9eb171c81ae55053516f0" ] ] From ea8da56f263da2428fa6626ce407711eb956d4cb Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 18:07:22 +0800 Subject: [PATCH 2/8] build: update Dune-enabled XMLM pin --- mldoc.opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mldoc.opam b/mldoc.opam index abb76fa5..1ff6cb27 100644 --- a/mldoc.opam +++ b/mldoc.opam @@ -43,5 +43,5 @@ build: [ ] pin-depends: [ [ "angstrom.dev" "git+https://github.com/logseq/angstrom#fork" ] - [ "xmlm.dev" "git+https://github.com/logseq/xmlm#49d5f7d265a73b307bd9eb171c81ae55053516f0" ] + [ "xmlm.dev" "git+https://github.com/logseq/xmlm#31c58eacbbf6b3a879f0e3df586e0a8d83c97cf4" ] ] From be362f0310db2efef558e112a268980dd75f5b02 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 18:10:42 +0800 Subject: [PATCH 3/8] build: pin merged XMLM Dune package --- mldoc.opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mldoc.opam b/mldoc.opam index 1ff6cb27..ad17f2c1 100644 --- a/mldoc.opam +++ b/mldoc.opam @@ -43,5 +43,5 @@ build: [ ] pin-depends: [ [ "angstrom.dev" "git+https://github.com/logseq/angstrom#fork" ] - [ "xmlm.dev" "git+https://github.com/logseq/xmlm#31c58eacbbf6b3a879f0e3df586e0a8d83c97cf4" ] + [ "xmlm.dev" "git+https://github.com/logseq/xmlm#f6c11f85125da62e6b97f3947e91d6615653c2c3" ] ] From 5222ea732a937b0813765776be9e70dbe8203c50 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 18:12:16 +0800 Subject: [PATCH 4/8] ci: modernize OCaml build and format checks --- .github/workflows/ci.yml | 22 +++++++++++----------- .github/workflows/format.yml | 27 ++++++++------------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 788803c5..fc1975a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,23 +13,23 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ocaml-compiler: ["4.14.x", "5.3.x"] steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up OCaml - uses: avsm/setup-ocaml@v1 + uses: ocaml/setup-ocaml@v3 with: - # Version of the OCaml compiler to initialise - ocaml-version: 4.11.1 + ocaml-compiler: ${{ matrix.ocaml-compiler }} - - name: install dependencies + - name: Install dependencies run: opam install . --deps-only --with-doc --with-test - - name: build - run: | - opam exec -- dune build @install @JS @main + - name: Build + run: opam exec -- dune build @install @JS @main - - name: runtest + - name: Test run: opam exec -- dune runtest - diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index b52b315b..3adc049d 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -5,29 +5,18 @@ on: branches: [ master ] jobs: - build: + format: runs-on: ubuntu-latest steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} + - uses: actions/checkout@v4 - name: Set up OCaml - uses: avsm/setup-ocaml@v1 + uses: ocaml/setup-ocaml@v3 with: - # Version of the OCaml compiler to initialise - ocaml-version: 4.11.1 + ocaml-compiler: 4.14.x - - name: install dependencies - run: opam install ocamlformat.0.16.0 dune + - name: Install formatter + run: opam install ocamlformat.0.26.2 dune - - name: format - run: | - opam exec -- dune build @fmt --auto-promote || true - - - name: commit - uses: stefanzweifel/git-auto-commit-action@v4.11.0 - with: - commit_message: Apply formatting changes - branch: ${{ github.head_ref }} + - name: Check formatting + run: opam exec -- dune build @fmt From ed536476975519c0e49d3de00c3a52a5c4775453 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 18:45:56 +0800 Subject: [PATCH 5/8] ci: build wrapped internal targets --- .github/workflows/format.yml | 9 ++++++++- js/dune | 1 + test/dune | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 3adc049d..7ab78895 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -9,6 +9,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up OCaml uses: ocaml/setup-ocaml@v3 @@ -19,4 +21,9 @@ jobs: run: opam install ocamlformat.0.26.2 dune - name: Check formatting - run: opam exec -- dune build @fmt + run: | + mapfile -t files < <(git diff --name-only --diff-filter=ACMRT \ + "origin/${{ github.base_ref }}...HEAD" -- '*.ml' '*.mli') + if ((${#files[@]} > 0)); then + opam exec -- ocamlformat --check "${files[@]}" + fi diff --git a/js/dune b/js/dune index d07a0745..2b634e8c 100644 --- a/js/dune +++ b/js/dune @@ -3,6 +3,7 @@ (modes js) (preprocess (pps js_of_ocaml-ppx)) + (flags :standard -open Mldoc__) (js_of_ocaml (flags --target-env browser)) (libraries angstrom js_of_ocaml mldoc)) diff --git a/test/dune b/test/dune index 7071d5f0..8397ba8a 100644 --- a/test/dune +++ b/test/dune @@ -50,3 +50,7 @@ (run %{zip}) (run %{export-md}) (run %{export-opml})))) +(env + (_ + (flags + (:standard -open Mldoc__)))) From 463de0331caf2c55bbc9870c2278fdfea0079ecf Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 18:59:32 +0800 Subject: [PATCH 6/8] test: replace deprecated QCheck generators --- test/gen_md_files.ml | 15 ++++++++++----- test/test_zip.ml | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/gen_md_files.ml b/test/gen_md_files.ml index c3a485cf..0da48f17 100644 --- a/test/gen_md_files.ml +++ b/test/gen_md_files.ml @@ -29,7 +29,7 @@ let page_names n = let pagename i = let+ pagename_l = list_size (1 -- 10) - @@ frequency + @@ oneof_weighted [ (1, string_size ~gen:(oneofl char_table) (0 -- 5)) ; (1, oneofl unicode_table) ] @@ -44,7 +44,7 @@ let plain_inline_g = string_size ~gen:(char_range 'A' 'Z') (1 -- 100) >|= fun s -> Inline.Plain s let inline_g pagenames = - frequency [ (10, plain_inline_g); (1, page_ref_g pagenames) ] + oneof_weighted [ (10, plain_inline_g); (1, page_ref_g pagenames) ] let inlines_g pagenames = list_size (1 -- 10) (inline_g pagenames) @@ -54,8 +54,12 @@ let level_candidates max = let heading ?(init = false) pagenames state = let marker_g = - frequencyl - [ (1, Some "TODO"); (1, Some "DOING"); (1, Some "DONE"); (7, None) ] + oneof_weighted + [ (1, return (Some "TODO")) + ; (1, return (Some "DOING")) + ; (1, return (Some "DONE")) + ; (7, return None) + ] in let level_g = oneofl @@ -90,7 +94,8 @@ let blocks_g pagenames : Type.blocks t = let* init_heading = heading ~init:true pagenames state in let init_heading_with_pos = (init_heading, dummy_pos) in let block_with_pos_g = - frequency [ (3, paragragh pagenames); (1, heading pagenames state) ] + oneof_weighted + [ (3, paragragh pagenames); (1, heading pagenames state) ] >|= fun b -> (b, dummy_pos) in let* blocks' = list_size (10 -- 500) block_with_pos_g in diff --git a/test/test_zip.ml b/test/test_zip.ml index d12d3167..80f1c2a0 100644 --- a/test/test_zip.ml +++ b/test/test_zip.ml @@ -9,7 +9,7 @@ let g = match n with | 0 -> map leaf nat | n -> - frequency + oneof_weighted [ ( 5 , branch <$> ( 0 -- (n / 2) >>= fun n' -> From ba398882316165080dc35b81f275220833cdb58e Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 19:21:00 +0800 Subject: [PATCH 7/8] ci: pin fixed XMLM and report format diffs --- .github/workflows/format.yml | 15 +++++++++++---- mldoc.opam | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 7ab78895..54d805f1 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -16,7 +16,7 @@ jobs: uses: ocaml/setup-ocaml@v3 with: ocaml-compiler: 4.14.x - + - name: Install formatter run: opam install ocamlformat.0.26.2 dune @@ -24,6 +24,13 @@ jobs: run: | mapfile -t files < <(git diff --name-only --diff-filter=ACMRT \ "origin/${{ github.base_ref }}...HEAD" -- '*.ml' '*.mli') - if ((${#files[@]} > 0)); then - opam exec -- ocamlformat --check "${files[@]}" - fi + status=0 + for file in "${files[@]}"; do + formatted="$(mktemp)" + opam exec -- ocamlformat "$file" > "$formatted" + if ! diff --unified "$file" "$formatted"; then + status=1 + fi + rm "$formatted" + done + exit "$status" diff --git a/mldoc.opam b/mldoc.opam index ad17f2c1..52a83342 100644 --- a/mldoc.opam +++ b/mldoc.opam @@ -43,5 +43,5 @@ build: [ ] pin-depends: [ [ "angstrom.dev" "git+https://github.com/logseq/angstrom#fork" ] - [ "xmlm.dev" "git+https://github.com/logseq/xmlm#f6c11f85125da62e6b97f3947e91d6615653c2c3" ] + [ "xmlm.dev" "git+https://github.com/logseq/xmlm#eb469d536e98c98f2754c0ff8813c92b3a17fe9f" ] ] From d139b5bafb52ac88913b36183c30f565dc700e28 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 26 Aug 2026 19:28:38 +0800 Subject: [PATCH 8/8] style: format QCheck migration --- test/gen_md_files.ml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/gen_md_files.ml b/test/gen_md_files.ml index 0da48f17..9c5fdf8d 100644 --- a/test/gen_md_files.ml +++ b/test/gen_md_files.ml @@ -64,9 +64,9 @@ let heading ?(init = false) pagenames state = let level_g = oneofl (if init then - [ 1 ] - else - level_candidates (state.last_level + 4)) + [ 1 ] + else + level_candidates (state.last_level + 4)) in inlines_g pagenames >>= fun inlines -> marker_g >>= fun marker -> @@ -94,8 +94,7 @@ let blocks_g pagenames : Type.blocks t = let* init_heading = heading ~init:true pagenames state in let init_heading_with_pos = (init_heading, dummy_pos) in let block_with_pos_g = - oneof_weighted - [ (3, paragragh pagenames); (1, heading pagenames state) ] + oneof_weighted [ (3, paragragh pagenames); (1, heading pagenames state) ] >|= fun b -> (b, dummy_pos) in let* blocks' = list_size (10 -- 500) block_with_pos_g in