diff --git a/data/changelog/dune/2024-06-17-dune.3.16.0.md b/data/changelog/dune/2024-06-17-dune.3.16.0.md index e42e229329..ee538819ae 100644 --- a/data/changelog/dune/2024-06-17-dune.3.16.0.md +++ b/data/changelog/dune/2024-06-17-dune.3.16.0.md @@ -1,6 +1,7 @@ --- title: Dune 3.16.0 tags: [dune, platform] +versions: [3.16.0, "3.16.0~alpha2", "3.16.0~alpha1"] changelog: | ### Added diff --git a/data/changelog/dune/2024-11-27-dune.3.17.0.md b/data/changelog/dune/2024-11-27-dune.3.17.0.md index 9be1e8c069..67767cb9bb 100644 --- a/data/changelog/dune/2024-11-27-dune.3.17.0.md +++ b/data/changelog/dune/2024-11-27-dune.3.17.0.md @@ -1,6 +1,7 @@ --- title: Dune 3.17.0 tags: [dune, platform] +versions: [3.17.0, "3.17.0~alpha0"] changelog: | ### Fixed diff --git a/data/changelog/ocaml-lsp/2024-12-23-ocaml-lsp-1.20.1.md b/data/changelog/ocaml-lsp/2024-12-23-ocaml-lsp-1.20.1.md index 92c6efb71f..f398a1cd0d 100644 --- a/data/changelog/ocaml-lsp/2024-12-23-ocaml-lsp-1.20.1.md +++ b/data/changelog/ocaml-lsp/2024-12-23-ocaml-lsp-1.20.1.md @@ -1,6 +1,7 @@ --- title: OCaml-LSP 1.20.1 tags: [ocaml-lsp, platform] +versions: ["1.20.1", "1.20.1-4.14", "1.20.0-4.14"] changelog: | ## Features - Add custom `ocamllsp/typeSearch` request ([#1369](https://github.com/ocaml/ocaml-lsp/pull/1369)) diff --git a/data/changelog/ocaml/2024-05-02-ocaml-5.2.0.rc1.md b/data/changelog/ocaml/2024-05-02-ocaml-5.2.0.rc1.md index 3ee212f2b2..7257efb47a 100644 --- a/data/changelog/ocaml/2024-05-02-ocaml-5.2.0.rc1.md +++ b/data/changelog/ocaml/2024-05-02-ocaml-5.2.0.rc1.md @@ -2,6 +2,7 @@ title: OCaml 5.2.0 - First Release Candidate description: First Release Candidate of OCaml 5.2.0 tags: [ocaml] +versions: ["5.2.0-rc1"] changelog: | ## Changes since the second beta diff --git a/data/changelog/ocaml/2024-05-13-ocaml-5.2.0.md b/data/changelog/ocaml/2024-05-13-ocaml-5.2.0.md index 627512680a..05ab91e06a 100644 --- a/data/changelog/ocaml/2024-05-13-ocaml-5.2.0.md +++ b/data/changelog/ocaml/2024-05-13-ocaml-5.2.0.md @@ -2,6 +2,7 @@ title: Release of OCaml 5.2.0 description: Release of OCaml 5.2.0 tags: [ocaml] +versions: ["OCaml 5.2.0"] changelog: | (Changes that can break existing programs are marked with a "*") diff --git a/data/changelog/ocaml/2024-09-20-ocaml-5.3.0.alpha1.md b/data/changelog/ocaml/2024-09-20-ocaml-5.3.0.alpha1.md index e4680d5648..eed26910e3 100644 --- a/data/changelog/ocaml/2024-09-20-ocaml-5.3.0.alpha1.md +++ b/data/changelog/ocaml/2024-09-20-ocaml-5.3.0.alpha1.md @@ -2,6 +2,7 @@ title: OCaml 5.3.0 - First Alpha description: First Alpha Release of OCaml 5.3.0 tags: [ocaml] +versions: ["5.3.0-alpha1"] --- Four months after the release of OCaml 5.2.0, the set of new features for the diff --git a/data/changelog/ocaml/2024-10-31-ocaml-5.3.0.beta1.md b/data/changelog/ocaml/2024-10-31-ocaml-5.3.0.beta1.md index 048e922ea3..2af02f776e 100644 --- a/data/changelog/ocaml/2024-10-31-ocaml-5.3.0.beta1.md +++ b/data/changelog/ocaml/2024-10-31-ocaml-5.3.0.beta1.md @@ -2,6 +2,7 @@ title: OCaml 5.3.0 - First Beta description: First Beta Release of OCaml 5.3.0 tags: [ocaml] +versions: ["5.3.0-beta1"] changelog: | ### Runtime fixes diff --git a/data/changelog/ocaml/2024-11-07-5.2.1-rc1.md b/data/changelog/ocaml/2024-11-07-5.2.1-rc1.md index fdbe2bc203..7eff8e3c34 100644 --- a/data/changelog/ocaml/2024-11-07-5.2.1-rc1.md +++ b/data/changelog/ocaml/2024-11-07-5.2.1-rc1.md @@ -2,6 +2,7 @@ title: OCaml 5.2.1 - Release Candidate description: Release Candidate for OCaml 5.2.1 tags: [ocaml] +versions: ["5.2.1-rc1"] changelog: | ## Changes Since OCaml 5.2.0 ### Runtime System: diff --git a/data/changelog/ocaml/2024-11-18-ocaml-5.2.1.md b/data/changelog/ocaml/2024-11-18-ocaml-5.2.1.md index 7ee76cff84..5527d8bef2 100644 --- a/data/changelog/ocaml/2024-11-18-ocaml-5.2.1.md +++ b/data/changelog/ocaml/2024-11-18-ocaml-5.2.1.md @@ -2,6 +2,7 @@ title: Release of OCaml 5.2.1 description: Release of OCaml 5.2.1 tags: [ocaml] +versions: ["OCaml 5.2.1"] changelog: | ## Changes Since OCaml 5.2.0 diff --git a/data/changelog/ocaml/2025-01-08-ocaml-5.3.0.md b/data/changelog/ocaml/2025-01-08-ocaml-5.3.0.md index 57b2ce110e..fb22fb4993 100644 --- a/data/changelog/ocaml/2025-01-08-ocaml-5.3.0.md +++ b/data/changelog/ocaml/2025-01-08-ocaml-5.3.0.md @@ -2,6 +2,7 @@ title: Release of OCaml 5.3.0 description: Release of OCaml 5.3.0 tags: [ocaml] +versions: ["OCaml 5.3.0"] changelog: | (Changes that can break existing programs are marked with a "*") ### Restored backend: diff --git a/data/changelog/ocamlformat/2022-07-18-ocamlformat-0.24.1.md b/data/changelog/ocamlformat/2022-07-18-ocamlformat-0.24.1.md index 8a3835a02f..854e096ad3 100644 --- a/data/changelog/ocamlformat/2022-07-18-ocamlformat-0.24.1.md +++ b/data/changelog/ocamlformat/2022-07-18-ocamlformat-0.24.1.md @@ -1,6 +1,7 @@ --- title: OCamlFormat 0.24.1 tags: [ocamlformat, platform] +versions: ["0.24.0", "0.24.1"] changelog: | ### New features diff --git a/data/changelog/ocamlformat/2023-03-06-ocamlformat-0.25.1.md b/data/changelog/ocamlformat/2023-03-06-ocamlformat-0.25.1.md index 912caa5f85..d700526146 100644 --- a/data/changelog/ocamlformat/2023-03-06-ocamlformat-0.25.1.md +++ b/data/changelog/ocamlformat/2023-03-06-ocamlformat-0.25.1.md @@ -1,6 +1,7 @@ --- title: OCamlFormat 0.25.1 tags: [ocamlformat, platform] +versions: ["0.25.0", "0.25.1"] changelog: | ### Library @@ -171,4 +172,4 @@ The OCamlFormat team + else if Sys.unix then (module Unix) + else (module Fail) + : Unix_socket) - ``` \ No newline at end of file + ``` diff --git a/data/changelog/ocamlformat/2024-12-02-ocamlformat-0.27.0.md b/data/changelog/ocamlformat/2024-12-02-ocamlformat-0.27.0.md new file mode 100644 index 0000000000..fcc3b0fd1a --- /dev/null +++ b/data/changelog/ocamlformat/2024-12-02-ocamlformat-0.27.0.md @@ -0,0 +1,130 @@ +--- +title: OCamlformat 0.27.0 +tags: [ocamlformat, platform] +changelog: | + ### Highlight + + - \* Support OCaml 5.2 syntax (#2519, #2544, #2590, #2596, #2621, #2628, @Julow, @EmileTrotignon, @hhugo) + This includes local open in types, raw identifiers, and the new + representation for functions. + This might change the formatting of some functions due to the formatting code + being completely rewritten. + + - Support OCaml 5.3 syntax (#2609, #2610, #2611, #2622, #2623, #2562, #2624, #2625, #2627, @Julow, @Zeta611) + This adds support for effect patterns, short functor type arguments and utf8 + identifiers. + To format code using the new `effect` syntax, add this option to your + `.ocamlformat`: + ``` + ocaml-version = 5.3 + ``` + + - Documentation comments are now formatted by default (#2390, @Julow) + Use the option `parse-docstrings = false` to restore the previous behavior. + + - \* Consistent indentation of polymorphic variant arguments (#2427, @Julow) + Increases the indentation by one to make the formatting consistent with + normal variants. For example: + ``` + ... + (* before *) + (`Msg + (foo bar)) + (* after *) + (`Msg + (foo bar)) + ``` + + - Build on OCaml 5.3 (#2603, @adamchol, @Julow) + + ### Added + + - Improve the emacs plugin (#2577, #2600, @gridbugs, @thibautbenjamin) + Allow a custom command to be used to run ocamlformat and add compatibility + with emacs ocaml tree-sitter modes. + + - Added option `let-binding-deindent-fun` (#2521, @henrytill) + to control the indentation of the `fun` in: + ``` + let f = + fun foo -> + bar + ``` + + - Added back the flag `--disable-outside-detected-project` (#2439, @gpetiot) + It was removed in version 0.22. + + - Support newer Odoc syntax (#2631, #2632, #2633, @Julow) + + ### Changed + + - \* Consistent formatting of comments (#2371, #2550, @Julow) + This is mostly an internal change but some comments might be formatted differently. + + - \* Improve formatting of type constraints with type variables (#2437, @gpetiot) + For example: + ``` + let f : type a b c. + a -> b -> c = + ... + ``` + + - \* Improve formatting of functor arguments (#2505, @Julow) + This also reduce the indentation of functor arguments with long signatures. + + - Improvements to the Janestreet profile (#2445, #2314, #2460, #2593, #2612, @Julow, @tdelvecchio-jsc) + + - \* Undo let-bindings and methods normalizations (#2523, #2529, @gpetiot) + This remove the rewriting of some forms of let-bindings and methods: + + `let f x = (x : int)` is no longer rewritten into `let f x : int = x` + + `let f (type a) (type b) ...` is no longer rewritten into `let f (type a b) ...` + + `let f = fun x -> ...` is no longer rewritten into `let f x = ...` + + - \* The `break-colon` option is now taken into account for method type constraints (#2529, @gpetiot) + + - \* Force a break around comments following an infix operator (fix non-stabilizing comments) (#2478, @gpetiot) + This adds a line break: + ``` + a + || + (* this comment is now on its own line *) + b + ``` + + ### Fixed + + - Fix placement of comments in some cases (#2471, #2503, #2506, #2540, #2541, #2592, #2617, @gpetiot, @Julow) + Some comments were being moved or causing OCamlformat to crash. + OCamlformat refuses to format if a comment would be missing in its output, to avoid loosing code. + + - Fix attributes being dropped or moved (#2247, #2459, #2551, #2564, #2602, @EmileTrotignon, @tdelvecchio-jsc, @Julow) + OCamlformat refuses to format if the formatted code has a different meaning than the original code, for example, if an attribute is removed. + We also try to avoid moving attributes even if that doesn't change the original code, for example we no longer format `open[@attr] M` as `open M [@@attr]`. + + - Remove trailing space inside a wrapping empty signature (#2443, @Julow) + - Fix extension-point spacing in structures (#2450, @Julow) + - \* Consistent break after string constant argument (#2453, @Julow) + - \* Fix cinaps comment formatting to not change multiline string contents (#2463, @tdelvecchio-jsc) + - \* Fix the indentation of tuples in attributes and extensions (#2488, @Julow) + - \* Fix weird indentation and line breaks after comments (#2507, #2589, #2606, @Julow) + - \* Fix unwanted alignment in if-then-else (#2511, @Julow) + - Fix missing parentheses around constraint expressions with attributes (#2513, @alanechang) + - Fix formatting of type vars in GADT constructors (#2518, @Julow) + - Fix `[@ocamlformat "disable"]` in some cases (#2242, #2525, @EmileTrotignon) + This caused a bug inside `class type` constructs and when attached to a `let ... in` + - Display `a##b` instead of `a ## b` and similarly for operators that start with # (#2580, @v-gb) + - \* Fix arrow type indentation with `break-separators=before` (#2598, @Julow) + - Fix missing parentheses around a let in class expressions (#2599, @Julow) + - Fix formatting of paragraphs in lists in documentation (#2607, @Julow) + - Avoid unwanted space in references and links text in documentation (#2608, @Julow) + - \* Improve the indentation of attributes in patterns (#2613, @Julow) + - \* Avoid large indentation in patterns after `let%ext` (#2615, @Julow) +--- + +After almost a year of work, OCamlformat 0.27.0 is finally available with +support for 5.3 syntax! + +This release includes the new function syntax from OCaml 5.2, the `effect` +keyword from OCaml 5.3 and a large number of bug fixes and improvements. + +An other notable change, is that comments are now formatted by default. diff --git a/data/changelog/omp/2020-04-15-omp-1.7.1.md b/data/changelog/omp/2020-04-15-omp-1.7.1.md index b6f54871bd..f611d08eaa 100644 --- a/data/changelog/omp/2020-04-15-omp-1.7.1.md +++ b/data/changelog/omp/2020-04-15-omp-1.7.1.md @@ -1,6 +1,7 @@ --- title: Omp ocaml-migrate-parsetree-1.7.1 tags: [omp] +versions: ["v1.7.1"] changelog: | - Fix build with OCaml < 4.08 diff --git a/data/changelog/omp/2020-04-20-omp-1.7.2.md b/data/changelog/omp/2020-04-20-omp-1.7.2.md index 8af14fb70d..08344b98a0 100644 --- a/data/changelog/omp/2020-04-20-omp-1.7.2.md +++ b/data/changelog/omp/2020-04-20-omp-1.7.2.md @@ -1,6 +1,7 @@ --- title: Omp ocaml-migrate-parsetree-1.7.2 tags: [omp] +versions: ["v1.7.2"] changelog: | - Remove toplevel `Option` module accidentally added in 1.7.0 --- diff --git a/data/changelog/omp/2020-05-07-omp-1.7.3.md b/data/changelog/omp/2020-05-07-omp-1.7.3.md index 2cf38bc750..6e9d03d9d1 100644 --- a/data/changelog/omp/2020-05-07-omp-1.7.3.md +++ b/data/changelog/omp/2020-05-07-omp-1.7.3.md @@ -1,6 +1,7 @@ --- title: Omp ocaml-migrate-parsetree-1.7.3 tags: [omp] +versions: ["v1.7.3"] changelog: | - Fix magic numbers for the 4.11 ast (#96, @hhugo) --- diff --git a/data/changelog/omp/2020-08-12-omp-2.0.0.md b/data/changelog/omp/2020-08-12-omp-2.0.0.md index 5a30f12f39..69e8dbbccf 100644 --- a/data/changelog/omp/2020-08-12-omp-2.0.0.md +++ b/data/changelog/omp/2020-08-12-omp-2.0.0.md @@ -1,6 +1,7 @@ --- title: Omp ocaml-migrate-parsetree-2.0.0 tags: [omp] +versions: ["v2.0.0"] changelog: | - No longer expose the unwrapped modules (#94, @jonludlam) - Remove everything but Ast versions and upgrade/downgrade diff --git a/data/changelog/omp/2020-10-22-omp-2.1.0.md b/data/changelog/omp/2020-10-22-omp-2.1.0.md index a834b3f29c..199e95523b 100644 --- a/data/changelog/omp/2020-10-22-omp-2.1.0.md +++ b/data/changelog/omp/2020-10-22-omp-2.1.0.md @@ -1,6 +1,7 @@ --- title: Omp ocaml-migrate-parsetree-2.1.0 tags: [omp] +versions: ["v2.1.0"] changelog: | - Add support for 4.12 (#107, @ceastlund) --- diff --git a/data/changelog/omp/2020-10-23-omp-1.8.0.md b/data/changelog/omp/2020-10-23-omp-1.8.0.md index 90ca8b61d2..fd53ca456b 100644 --- a/data/changelog/omp/2020-10-23-omp-1.8.0.md +++ b/data/changelog/omp/2020-10-23-omp-1.8.0.md @@ -1,6 +1,7 @@ --- title: Omp ocaml-migrate-parsetree-1.8.0 tags: [omp] +versions: ["v1.8.0"] changelog: | Oops, we went looking but didn't find the changelog for this release 🙈 --- diff --git a/data/changelog/omp/2021-06-22-omp-2.2.0.md b/data/changelog/omp/2021-06-22-omp-2.2.0.md index 187681eb9a..c9e9b21cfc 100644 --- a/data/changelog/omp/2021-06-22-omp-2.2.0.md +++ b/data/changelog/omp/2021-06-22-omp-2.2.0.md @@ -1,6 +1,7 @@ --- title: Omp ocaml-migrate-parsetree-2.2.0 tags: [omp] +versions: ["v2.2.0"] changelog: | - Add support for 4.13 (#114, @kit-ty-kate) --- diff --git a/data/changelog/opam-publish/2018-09-19-opam-publish-2.0.0.md b/data/changelog/opam-publish/2018-09-19-opam-publish-2.0.0.md index 67cf58808f..f6cef2b71d 100644 --- a/data/changelog/opam-publish/2018-09-19-opam-publish-2.0.0.md +++ b/data/changelog/opam-publish/2018-09-19-opam-publish-2.0.0.md @@ -1,6 +1,7 @@ --- title: Opam-publish 2.0.0 tags: [opam-publish, platform] +versions: ["2.0.0", "2.0.0: Merge pull request #66 from rjbou/push-on-master"] changelog: | * Switch default branch from 2.0.0 to master * Minor fix diff --git a/data/changelog/opam/2024-05-22-opam-2-1-6.md b/data/changelog/opam/2024-05-22-opam-2-1-6.md index 1565d24391..f879c29c1b 100644 --- a/data/changelog/opam/2024-05-22-opam-2-1-6.md +++ b/data/changelog/opam/2024-05-22-opam-2-1-6.md @@ -1,6 +1,7 @@ --- title: opam 2.1.5 authors: [ "Raja Boujbel" ] +versions: ["2.1.6"] description: "Release of opam 2.1.5" tags: [opam, platform] changelog: | diff --git a/data/changelog/opam/2024-06-10-opam-2-2-0-beta3.md b/data/changelog/opam/2024-06-10-opam-2-2-0-beta3.md index 1aa20be4b2..78e05ddf0e 100644 --- a/data/changelog/opam/2024-06-10-opam-2-2-0-beta3.md +++ b/data/changelog/opam/2024-06-10-opam-2-2-0-beta3.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.2.0~beta3"] description: "Beta3 release of opam 2.2.0" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-06-21-opam-2-2-0-rc1.md b/data/changelog/opam/2024-06-21-opam-2-2-0-rc1.md index c2b7a02e7b..73e3013218 100644 --- a/data/changelog/opam/2024-06-21-opam-2-2-0-rc1.md +++ b/data/changelog/opam/2024-06-21-opam-2-2-0-rc1.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.2.0~rc1"] description: "RC1 release of opam 2.2.0" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-07-01-opam-2-2-0.md b/data/changelog/opam/2024-07-01-opam-2-2-0.md index 0ac013e64c..25bde4f9df 100644 --- a/data/changelog/opam/2024-07-01-opam-2-2-0.md +++ b/data/changelog/opam/2024-07-01-opam-2-2-0.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.2.0"] description: "Release of opam 2.2.0" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-08-22-opam-2-2-1.md b/data/changelog/opam/2024-08-22-opam-2-2-1.md index 77f52fa9c5..86b1fdd280 100644 --- a/data/changelog/opam/2024-08-22-opam-2-2-1.md +++ b/data/changelog/opam/2024-08-22-opam-2-2-1.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.2.1"] description: "opam 2.2.1 release" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-09-19-opam-2-3-0-alpha1.md b/data/changelog/opam/2024-09-19-opam-2-3-0-alpha1.md index 2b952b0a67..b5521a8c89 100644 --- a/data/changelog/opam/2024-09-19-opam-2-3-0-alpha1.md +++ b/data/changelog/opam/2024-09-19-opam-2-3-0-alpha1.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.3.0~alpha1"] description: "Release of opam 2.3.0~alpha1" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-10-15-opam-2-3-0-beta1.md b/data/changelog/opam/2024-10-15-opam-2-3-0-beta1.md index fbdbf068c1..47b02486d8 100644 --- a/data/changelog/opam/2024-10-15-opam-2-3-0-beta1.md +++ b/data/changelog/opam/2024-10-15-opam-2-3-0-beta1.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.3.0~beta1"] description: "Release of opam 2.3.0~beta1" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-10-24-opam-2-3-0-beta2.md b/data/changelog/opam/2024-10-24-opam-2-3-0-beta2.md index 806c585285..40e4b3a521 100644 --- a/data/changelog/opam/2024-10-24-opam-2-3-0-beta2.md +++ b/data/changelog/opam/2024-10-24-opam-2-3-0-beta2.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.3.0~beta2"] description: "Release of opam 2.3.0~beta2" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-10-30-opam-2-3-0-rc1.md b/data/changelog/opam/2024-10-30-opam-2-3-0-rc1.md index 8291b8b004..266b9fafbc 100644 --- a/data/changelog/opam/2024-10-30-opam-2-3-0-rc1.md +++ b/data/changelog/opam/2024-10-30-opam-2-3-0-rc1.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.3.0~rc1"] description: "Release of opam 2.3.0~rc1" tags: [opam, platform] --- diff --git a/data/changelog/opam/2024-11-13-opam-2-3-0.md b/data/changelog/opam/2024-11-13-opam-2-3-0.md index 3be08a7fe1..0ab543adc5 100644 --- a/data/changelog/opam/2024-11-13-opam-2-3-0.md +++ b/data/changelog/opam/2024-11-13-opam-2-3-0.md @@ -5,6 +5,7 @@ authors: [ "Kate Deplaix", "David Allsopp", ] +versions: ["2.3.0"] description: "Release of opam 2.3.0" tags: [opam, platform] --- diff --git a/src/ocamlorg_data/data_intf.ml b/src/ocamlorg_data/data_intf.ml index 32f8b1d0da..6c723a46da 100644 --- a/src/ocamlorg_data/data_intf.ml +++ b/src/ocamlorg_data/data_intf.ml @@ -129,6 +129,8 @@ module Changelog = struct body_html : string; body : string; authors : string list; + project_name : string; + versions : string list; } [@@deriving of_yaml, show] end diff --git a/tool/ood-gen/bin/scrape.ml b/tool/ood-gen/bin/scrape.ml index 709f82fa3a..fb90491cd8 100644 --- a/tool/ood-gen/bin/scrape.ml +++ b/tool/ood-gen/bin/scrape.ml @@ -1,7 +1,12 @@ open Cmdliner open Ood_gen -let term_scrapers = [ ("planet", Blog.Scraper.scrape); ("video", Video.scrape) ] +let term_scrapers = + [ + ("planet", Blog.Scraper.scrape); + ("video", Video.scrape); + ("changelog", Changelog.Scraper.scrape); + ] let cmds = Cmd.group (Cmd.info "ood-scrape") diff --git a/tool/ood-gen/lib/changelog.ml b/tool/ood-gen/lib/changelog.ml index 8ae1409d8f..56410a76c8 100644 --- a/tool/ood-gen/lib/changelog.ml +++ b/tool/ood-gen/lib/changelog.ml @@ -1,22 +1,50 @@ open Data_intf.Changelog +(** Location from where to check for new releases while scraping. Keys are + 'tags' listed in changelogs. *) +let projects_release_feeds = + [ + ("ocamlformat", `Github "https://github.com/ocaml-ppx/ocamlformat"); + ("dune", `Github "https://github.com/ocaml/dune"); + ("dune-release", `Github "https://github.com/tarides/dune-release"); + ("mdx", `Github "https://github.com/realworldocaml/mdx"); + ("merlin", `Github "https://github.com/ocaml/merlin"); + ("ocaml", `Github "https://github.com/ocaml/ocaml"); + ("ocaml-lsp", `Github "https://github.com/ocaml/ocaml-lsp"); + ("ocp-indent", `Github "https://github.com/OCamlPro/ocp-indent"); + ("odoc", `Github "https://github.com/ocaml/odoc"); + ("opam", `Github "https://github.com/ocaml/opam/"); + ("opam-publish", `Github "https://github.com/ocaml-opam/opam-publish"); + ("ppxlib", `Github "https://github.com/ocaml-ppx/ppxlib"); + ("utop", `Github "https://github.com/ocaml-community/utop"); + ("omp", `Github "https://github.com/ocaml-ppx/ocaml-migrate-parsetree"); + ] + type metadata = { title : string; tags : string list; authors : string list option; description : string option; changelog : string option; + versions : string list option; } [@@deriving of_yaml, stable_record ~version:t ~remove:[ changelog; description ] - ~modify:[ authors ] - ~add:[ slug; changelog_html; body_html; body; date ]] + ~modify:[ authors; versions ] + ~add:[ slug; changelog_html; body_html; body; date; project_name ]] -let of_metadata m = metadata_to_t m ~modify_authors:(Option.value ~default:[]) +let of_metadata m = + metadata_to_t m ~modify_authors:(Option.value ~default:[]) + ~modify_versions:(Option.value ~default:[]) -let re_date_slug = +let re_slug = let open Re in + let re_project_name = + let w = rep1 alpha in + seq [ w; rep (seq [ char '-'; w ]) ] + in + let re_version_string = seq [ digit; rep1 any ] in compile (seq [ @@ -30,19 +58,24 @@ let re_date_slug = group (rep1 digit); ]; char '-'; + opt + (seq + [ group re_project_name; set "-."; group re_version_string; eos ]); ]) -let parse_date_from_slug s = - match Re.exec_opt re_date_slug s with +let parse_slug s = + match Re.exec_opt re_slug s with | None -> None | Some g -> let int n = Re.Group.get g n |> int_of_string in let year = int 1 in let month = int 2 in let day = int 3 in - Some (Printf.sprintf "%04d-%02d-%02d" year month day) + let version = Re.Group.get_opt g 5 in + Some (Printf.sprintf "%04d-%02d-%02d" year month day, version) let decode (fname, (head, body)) = + let project_name = Filename.basename (Filename.dirname fname) in let slug = Filename.basename (Filename.remove_extension fname) in let metadata = metadata_of_yaml head |> Result.map_error (Utils.where fname) @@ -64,15 +97,21 @@ let decode (fname, (head, body)) = |> Hilite.Md.transform |> Cmarkit_html.of_doc ~safe:false) in - let date = - match parse_date_from_slug slug with + let date, version = + match parse_slug slug with | Some x -> x | None -> failwith - "date is not present in metadata and could not be parsed from \ - slug" + ("date is not present in metadata and could not be parsed from \ + slug: " ^ slug) + in + let metadata = + match (metadata.versions, version) with + | None, Some v -> { metadata with versions = Some [ v ] } + | _ -> metadata in - of_metadata ~slug ~changelog_html ~body ~body_html ~date metadata) + of_metadata ~slug ~changelog_html ~body ~body_html ~date ~project_name + metadata) metadata let all () = @@ -105,3 +144,54 @@ let all = %a |ocaml} (Fmt.brackets (Fmt.list pp ~sep:Fmt.semi)) (all ()) + +module Scraper = struct + module SMap = Map.Make (String) + module SSet = Set.Make (String) + + let warning_count = ref 0 + + let warn fmt = + let flush out = + Printf.fprintf out "\n%!"; + incr warning_count + in + Printf.kfprintf flush stderr fmt + + let fetch_github repo = + [ River.fetch { River.name = repo; url = repo ^ "/releases.atom" } ] + |> River.posts + |> List.map (fun post -> River.title post) + + let group_releases_by_project all = + List.fold_left + (fun acc t -> + List.fold_left + (fun acc v -> SMap.add_to_list t.project_name v acc) + acc t.versions) + SMap.empty all + + let check_if_uptodate project known_versions = + let known_versions = SSet.of_list known_versions in + let check scraped_versions = + List.iter + (fun v -> + if not (SSet.mem v known_versions) then + warn "No changelog entry for %S version %S\n%!" project v) + scraped_versions + in + match List.assoc_opt project projects_release_feeds with + | Some (`Github repo) -> check (fetch_github repo) + | None -> + warn + "Don't know how to lookup project %S. Please update \ + 'tool/ood-gen/lib/changelog.ml'\n\ + %!" + project + + (** This does not generate any file. Instead, it exits with an error if a + changelog entry is missing. *) + let scrape () = + all () |> group_releases_by_project |> SMap.iter check_if_uptodate; + if !warning_count > 0 then exit 1 +end diff --git a/tool/ood-gen/test/test_ood_gen.ml b/tool/ood-gen/test/test_ood_gen.ml index 05f55bf233..0f7e2a6db0 100644 --- a/tool/ood-gen/test/test_ood_gen.ml +++ b/tool/ood-gen/test/test_ood_gen.ml @@ -3,14 +3,23 @@ let test_parse_date_from_slug = ( name, `Quick, fun () -> - let got = Ood_gen.Changelog.parse_date_from_slug s in - Alcotest.check (Alcotest.option Alcotest.string) __LOC__ expected got ) + let got = Ood_gen.Changelog.parse_slug s in + Alcotest.(check (option (pair string (option string)))) + __LOC__ expected got ) in [ - test ~name:"ok" "2020-03-02-something.md" ~expected:(Some "2020-03-02"); + test ~name:"ok" "2020-03-02-something.md" + ~expected:(Some ("2020-03-02", None)); test ~name:"no date" "something.md" ~expected:None; test ~name:"day not padded correctly" "2021-1-2-title.md" - ~expected:(Some "2021-01-02"); + ~expected:(Some ("2021-01-02", None)); + test ~name:"ok with project-version" "2025-01-31-project-1.2.3" + ~expected:(Some ("2025-01-31", Some "1.2.3")); + test ~name:"ok with project.version" "2025-01-31-project.1.2.3" + ~expected:(Some ("2025-01-31", Some "1.2.3")); + test ~name:"ok with project.version-suffix" + "2025-01-31-project.1.2.3-something" + ~expected:(Some ("2025-01-31", Some "1.2.3-something")); ] let tests = [ ("parse_date_from_slug", test_parse_date_from_slug) ]