Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
2.0.0
-----
# 3.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This releases adds two constructors, which is a breaking change only for users that consume the entire AST. These users will break for every changes.
The Code_block constructor is changed, which breaks all known users.

These are breaking changes but require a small amount of maintenance. Given that this library exposes an AST and that every changes are breaking changes, I'd argue that we don't need to make a major release.

Also, a version number above 2.2.0 will prevent us from merging the two projects again. For which, the discussion is still open ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That all changes are breaking is a choice, because we could add versioned API support if we really wanted. I don't follow the argument about merging? It was never suggested we merge the opam packages again, so I don't see why they shouldn't have independent version numbers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We talked about merging the git repositories ? Independent version numbers are possible but a lot of work to get right. It's also not intuitive.

Why would the two projects have independent version numbers ? Both projects evolve together, I don't see the point in the added release complexity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is an important distinction. A comment written using odoc-parser syntax requires a particular version of the parser, not a particular version of odoc.

Copy link
Contributor

@Julow Julow Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't contradict giving versions to the parser according to Odoc's. "this comment is written using the parser from odoc version x".

We more often add things to the parser than we remove. I think if a comment requires a specific version of the parser, it also constraints Odoc because it'll need a recent enough version.


### 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

3 changes: 1 addition & 2 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(lang dune 2.8)
(name odoc-parser)
(version 2.0.0)
(version 3.0.0)

(generate_opam_files true)

Expand All @@ -18,7 +18,6 @@ understood by ocamldoc.")
(depends
dune
(ocaml (>= 4.02.0))
astring
result
camlp-streams
(ppx_expect :with-test)))
Expand Down
3 changes: 1 addition & 2 deletions odoc-parser.opam
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down
1 change: 0 additions & 1 deletion odoc-parser.opam.template
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"buildsInSource": "_build"
},
"dependencies": {
"@opam/astring": "^0.8.3",
"@opam/dune": "^2.8.5",
"@opam/result": "*",
"@opam/ppx_expect": "*",
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
(backend bisect_ppx))
(flags
(:standard -w -50))
(libraries astring result camlp-streams))
(libraries result camlp-streams))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is removing astring useful while Odoc uses it too ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odoc-parser is used by more than just odoc. In this particular case, since once we drop support for <=4.03 the functionality we need is entirely in stdlib, it seems just good hygiene. I'm quite keen to drop old OCaml support fairly soon (and at a major version number).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The drop of support is not planned for this release ? Then I think this can wait.

This effectively remove a dependency from OCamlformat (the only user of the parser that I know of and don't use astring) so this is still welcome. Though, I don't think accumulating "compat" code is good hygiene.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wait?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, with the planned removal of the new compat functions, I don't see a problem with adding them.

18 changes: 17 additions & 1 deletion src/lexer.mll
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
{

(* 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 begin
r := sub s (i + 1) (!j - i - 1) :: !r;
j := i
end
done;
sub s 0 !j :: !r


let unescape_word : string -> string = fun s ->
(* The common case is that there are no escape sequences. *)
match String.index s '\\' with
Expand Down Expand Up @@ -94,7 +110,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 = split_on_char '\n' s in

let least_amount_of_whitespace =
List.fold_left (fun least_so_far line ->
Expand Down
16 changes: 15 additions & 1 deletion src/parse_error.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
let capitalize_ascii = Astring.String.Ascii.capitalize
(* 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 uppercase_ascii =
let open Char in
function 'a' .. 'z' as c -> unsafe_chr (code c - 32) | c -> c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use String.capitalize and disable the warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hasn't String.capitalize gone entirely now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually checked in 5.1 before making the comment but it seems I managed to check in 4.14.1 😂. Sorry for the noise.


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

let capitalize_ascii s = apply1 uppercase_ascii s

let bad_markup : ?suggestion:string -> string -> Loc.span -> Warning.t =
fun ?suggestion -> Warning.make ?suggestion "'%s': bad markup."
Expand Down