diff --git a/CHANGES.md b/CHANGES.md index 3519969e..07f4445c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,21 +1,39 @@ -2.0.0 ------ +# 3.0.0 + +### Changed + +- Remove astring dependency (@jonludlam, #18) + +### Fixed + +- Better handling of reference syntax (@EmileTrotignon, #13) + +### Added + +- Delimited code blocks with associated output (@jonludlam, #17) +- New @hidden tag (@3Rafal, #16) +- Table syntax (@gpetiot, #11, @panglesd, #14) + +# 2.0.0 - 2022-07-07 + +### Added - New inline and display math markup (@giltho, #5) -1.0.1 ------ +# 1.0.1 - 2022-07-05 + +### Added - OCaml 5.0 support (@talex5, #6) -1.0.0 ------ +# 1.0.0 - 2021-12-11 + +### Added - New syntax to allow associating metadata with code blocks (@Julow, #2, #3) -0.9.0 ------ +# 0.9.0 - 2021-07-02 - Extracted from odoc repository diff --git a/dune-project b/dune-project index 55706d52..16a29afa 100644 --- a/dune-project +++ b/dune-project @@ -1,6 +1,6 @@ (lang dune 2.8) (name odoc-parser) -(version 2.0.0) +(version 3.0.0) (generate_opam_files true) @@ -18,7 +18,6 @@ understood by ocamldoc.") (depends dune (ocaml (>= 4.02.0)) - astring result camlp-streams (ppx_expect :with-test))) diff --git a/odoc-parser.opam b/odoc-parser.opam index 7d485752..ea6a86dc 100644 --- a/odoc-parser.opam +++ b/odoc-parser.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "2.0.0" +version: "3.0.0" synopsis: "Parser for ocaml documentation comments" description: """ Odoc_parser is a library for parsing the contents of OCaml documentation @@ -18,7 +18,6 @@ doc: "https://ocaml-doc.github.io/odoc-parser/" depends: [ "dune" {>= "2.8"} "ocaml" {>= "4.02.0"} - "astring" "result" "camlp-streams" "ppx_expect" {with-test} diff --git a/odoc-parser.opam.template b/odoc-parser.opam.template index 47ac9f5d..6c2730a2 100644 --- a/odoc-parser.opam.template +++ b/odoc-parser.opam.template @@ -4,7 +4,6 @@ doc: "https://ocaml-doc.github.io/odoc-parser/" depends: [ "dune" {>= "2.8"} "ocaml" {>= "4.02.0"} - "astring" "result" "camlp-streams" "ppx_expect" {with-test} diff --git a/package.json b/package.json index 9a1623b6..888b094c 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "buildsInSource": "_build" }, "dependencies": { - "@opam/astring": "^0.8.3", "@opam/dune": "^2.8.5", "@opam/result": "*", "@opam/ppx_expect": "*", diff --git a/src/compat.ml b/src/compat.ml index a7b535d1..97ccc957 100644 --- a/src/compat.ml +++ b/src/compat.ml @@ -29,4 +29,37 @@ module String = struct else false in aux 0 + + (* This is taken from the OCaml stdlib (more or less) - only here because we support + 4.02 and capitalize_ascii only arrived in 4.03. When we drop support + for 4.02 we can remove the following 3 functions *) + + let capitalize_ascii = + let uppercase_ascii = + let open Char in + function 'a' .. 'z' as c -> unsafe_chr (code c - 32) | c -> c + in + + let apply1 f s = + let open String in + if length s = 0 then s + else + let r = sub s 1 (length s - 1) in + make 1 (f (unsafe_get s 0)) ^ r + in + + apply1 uppercase_ascii + + (* The following function is taken from the OCaml stdlib. It's here because we support building + om OCaml < 4.04. Once we drop support for 4.03 and before we can remove the following function *) + let split_on_char sep s = + let open String in + let r = ref [] in + let j = ref (length s) in + for i = length s - 1 downto 0 do + if unsafe_get s i = sep then ( + r := sub s (i + 1) (!j - i - 1) :: !r; + j := i) + done; + sub s 0 !j :: !r end diff --git a/src/dune b/src/dune index 36bd5bf2..c0db1e31 100644 --- a/src/dune +++ b/src/dune @@ -7,4 +7,4 @@ (backend bisect_ppx)) (flags (:standard -w -50)) - (libraries astring result camlp-streams)) + (libraries result camlp-streams)) diff --git a/src/lexer.mll b/src/lexer.mll index 0cde0b43..2af3b866 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -94,7 +94,7 @@ let trim_leading_whitespace : first_line_offset:int -> string -> string = count_leading_whitespace' 0 len in - let lines = Astring.String.cuts ~sep:"\n" s in + let lines = String.split_on_char '\n' s in let least_amount_of_whitespace = List.fold_left (fun least_so_far line -> diff --git a/src/parse_error.ml b/src/parse_error.ml index 4ee22c47..8b454a5c 100644 --- a/src/parse_error.ml +++ b/src/parse_error.ml @@ -1,5 +1,3 @@ -let capitalize_ascii = Astring.String.Ascii.capitalize - let bad_markup : ?suggestion:string -> string -> Loc.span -> Warning.t = fun ?suggestion -> Warning.make ?suggestion "'%s': bad markup." @@ -7,27 +5,29 @@ let leading_zero_in_heading_level : string -> Loc.span -> Warning.t = Warning.make "'%s': leading zero in heading level." let should_not_be_empty : what:string -> Loc.span -> Warning.t = - fun ~what -> Warning.make "%s should not be empty." (capitalize_ascii what) + fun ~what -> + Warning.make "%s should not be empty." (String.capitalize_ascii what) let markup_should_not_be_used : what:string -> Loc.span -> Warning.t = fun ~what -> Warning.make "%s should not be used because it has no effect." - (capitalize_ascii what) + (String.capitalize_ascii what) let should_begin_on_its_own_line : what:string -> Loc.span -> Warning.t = fun ~what -> - Warning.make "%s should begin on its own line." (capitalize_ascii what) + Warning.make "%s should begin on its own line." (String.capitalize_ascii what) let should_be_followed_by_whitespace : what:string -> Loc.span -> Warning.t = fun ~what -> Warning.make "%s should be followed by space, a tab, or a new line." - (capitalize_ascii what) + (String.capitalize_ascii what) let not_allowed : ?suggestion:string -> what:string -> in_what:string -> Loc.span -> Warning.t = fun ?suggestion ~what ~in_what -> - Warning.make ?suggestion "%s is not allowed in %s." (capitalize_ascii what) + Warning.make ?suggestion "%s is not allowed in %s." + (String.capitalize_ascii what) in_what let unclosed_bracket :