Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor odoc-parser #430

Merged
merged 4 commits into from
Sep 26, 2023
Merged

Conversation

jonludlam
Copy link
Contributor

This PR vendors odoc-parser into the repo. This helps prevent the use of mdx in odoc's tests. In this I've vendored the latest release of odoc-parser, but once ocaml/odoc#973 is merged we'll want to adjust the script to point at the odoc repo rather than the odoc-parser repo.

Copy link
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

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

The update-odoc-parser.sh script will need quite a lot of modifications when upgrading the vendored odoc-parser, but it is still good to keep it!

cp -v $SRC/LICENSE.md odoc-parser/

git checkout odoc-parser/src/dune
git add -A .
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure, what is this line for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which, the git add? I should mention that this script was modelled closely on (copied from!) dune's equilvalent scripts, e.g. https://github.com/ocaml/dune/blob/main/vendor/update-cmdliner.sh

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I was wondering why automatically adding those files to the git index... (I'm OK with it, I just wanted to know if there was a specific reason you knew for this)

Copy link
Contributor

@gpetiot gpetiot left a comment

Choose a reason for hiding this comment

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

I left comments to update vendor/update-odoc-parser.sh to make it point to the odoc repo since the parser has been merged back.
Btw would it be possible to use git submodules for all this?

@@ -0,0 +1,26 @@
#!/bin/bash

version=ebfd3b9489e44187da2c67d79a32b6fc1e92bda4
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
version=ebfd3b9489e44187da2c67d79a32b6fc1e92bda4
version=5ac1ffc67ce1b96f5a990fa4902a157a5cdb42d0


(
cd $TMP
git clone https://github.com/ocaml-doc/odoc-parser.git
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
git clone https://github.com/ocaml-doc/odoc-parser.git
git clone https://github.com/ocaml/odoc.git


SRC=$TMP/odoc-parser

cp -v $SRC/src/*.{ml,mli,mll} odoc-parser/src
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cp -v $SRC/src/*.{ml,mli,mll} odoc-parser/src
cp -v $SRC/src/parser/*.{ml,mli,mll} odoc-parser/src

(
cd $TMP
git clone https://github.com/ocaml-doc/odoc-parser.git
cd odoc-parser
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cd odoc-parser
cd odoc

git checkout $version
)

SRC=$TMP/odoc-parser
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SRC=$TMP/odoc-parser
SRC=$TMP/odoc

@panglesd
Copy link
Collaborator

to make it point to the odoc repo since the parser has been merged back.

More modification would be needed since the new AST has changed the code block node.

Moreover, one would want to use the new syntax for "output of code blocks". Indeed, it would fix a bug where an error in the execution leads to:

{[
  let f = 1 + "2"
]}```mdx-error
An expression of type int was expected, but got a string
```

which is not valid odoc code.

@jonludlam
Copy link
Contributor Author

I think we should merge this as-is, release a version of mdx, then do the work to upgrade to the new parser API.

@trefis trefis merged commit c895263 into realworldocaml:main Sep 26, 2023
@trefis
Copy link
Collaborator

trefis commented Sep 26, 2023

I agree with this plan.

tmattio added a commit to tmattio/opam-repository that referenced this pull request Sep 27, 2023
CHANGES:

#### Added

- Add `os_type` label to enable/disable based on `Sys.os_type` (realworldocaml/mdx#433,
  @polytypic)

- Make MDX compatible with OCaml 5.1 (realworldocaml/mdx#435, @polytypic and @kit-ty-kate)

#### Changed

- Vendored the odoc-parser library, removing the need to have it
  as a dependency. (realworldocaml/mdx#430, @jonludlam)
@gpetiot
Copy link
Contributor

gpetiot commented Sep 29, 2023

Moreover, one would want to use the new syntax for "output of code blocks". Indeed, it would fix a bug where an error in the execution leads to:

{[
  let f = 1 + "2"
]}```mdx-error
An expression of type int was expected, but got a string

I had a look at it, did I miss something regarding the new syntax for the output of code blocks? this is not mentioned in the docs

@panglesd
Copy link
Collaborator

More info is available here: ocaml-doc/odoc-parser#17

I don't know if the new syntax is documented in doco master's branch, but it's normal that it is not in the doc for the released version!

nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

#### Added

- Add `os_type` label to enable/disable based on `Sys.os_type` (realworldocaml/mdx#433,
  @polytypic)

- Make MDX compatible with OCaml 5.1 (realworldocaml/mdx#435, @polytypic and @kit-ty-kate)

#### Changed

- Vendored the odoc-parser library, removing the need to have it
  as a dependency. (realworldocaml/mdx#430, @jonludlam)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants