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

Refactor comment parsing to use odoc-parser and cmarkit #1088

Merged
merged 11 commits into from
Jun 8, 2023

Conversation

tmattio
Copy link
Collaborator

@tmattio tmattio commented May 8, 2023

Omd 2.X doesn't support printing markdown, so OCaml LSP is blocked to Omd 1.X. This creates conflicts with codebases that have migrated to Omd 2.X (e.g. in ocamlorg).

To avoid conflicts for users of Omd 2.X, we migrate to cmarkit, which has a smaller dependency profile and supports printing to markdown.

Not complete yet, the support for tags is incomplete and I'll add a few more tests to make sure we're not breaking anything.

cc @tatchi @ddickstein

@tmattio
Copy link
Collaborator Author

tmattio commented May 8, 2023

also cc @dbuenzli as you might be interested in this. Certainly not as solid as ocamlmark in the current state, but this essentially implements the reverse transformations you implemented in the PR on odoc-parser.

dune-project Outdated Show resolved Hide resolved
@tmattio tmattio marked this pull request as ready for review May 17, 2023 11:47
Copy link
Collaborator Author

@tmattio tmattio left a comment

Choose a reason for hiding this comment

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

@3Rafal I've rebased the PR on master. I left a few comments in the tests for things that appear to be broken - we'll need to fix them before the PR can be merged.

@tmattio tmattio changed the title [WIP] Refactor comment parsing to use odoc-parser and cmarkit Refactor comment parsing to use odoc-parser and cmarkit May 17, 2023
@coveralls
Copy link

coveralls commented May 17, 2023

Pull Request Test Coverage Report for Build 3802

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 147 (0.0%) changed or added relevant lines in 1 file are covered.
  • 4400 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.5%) to 17.36%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ocaml-lsp-server/src/doc_to_md.ml 0 147 0.0%
Files with Coverage Reduction New Missed Lines %
ocaml-lsp-server/src/configuration.ml 8 45.45%
ocaml-lsp-server/src/merlin_config.ml 17 17.26%
lsp/src/server_notification.ml 20 45.45%
ocaml-lsp-server/src/progress.ml 20 5.71%
lsp/src/client_notification.ml 21 24.0%
ocaml-lsp-server/src/ocaml_lsp_server.ml 39 36.39%
lsp/src/types.ml 4275 10.55%
Totals Coverage Status
Change from base Build 3733: 0.5%
Covered Lines: 4073
Relevant Lines: 23462

💛 - Coveralls

Omd 2.X doesn't support printing markdown, so OCaml LSP is blocked to Omd 1.X. This creates conflicts with codebases that have migrated to Omd 2.X (e.g. in ocamlorg).

To avoid conflicts for users of Omd 2.X, we migrate to cmarkit, which has a smaller dependency profile and supports printing to markdown.

Co-authored-by: Rafał Gwoździński <[email protected]>
; location
} ->
let info_string =
match metadata with
| None -> None
| None -> Some ("ocaml", loc_to_meta code_loc)
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 don't think that's right, can we assume that every ocamldoc code block is in ocaml?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume that we default to ocaml when lang header is missing. See: https://ocaml.github.io/odoc/odoc_for_authors.html#ocaml_code_blocks

Also, I've added an explicit test case for this

@tmattio
Copy link
Collaborator Author

tmattio commented May 17, 2023

@rgrinberg this should be ready to review/merge. The support is incomplete, but there shouldn't be any regression compared to the current implementation (and we're actually fixing a couple of issues as demonstrated in the tests).


#### Module List

* * *
***@param*** \`x\` dividend
*Array
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Module list are still broken

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, for some reason I thought that I should fix only commented stuff. 😅 I'll try to fix it asap.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wow, this is more involved. It didn't work previously so we can fix it later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I misunderstood the feature. The list is fixed now :)

@tmattio
Copy link
Collaborator Author

tmattio commented May 17, 2023

Spoke too soon, the lists are still broken. Should be ready to review though.

@rgrinberg
Copy link
Member

@Khady can you take a look? Since you're the original author of this feature.

@3Rafal
Copy link
Collaborator

3Rafal commented May 18, 2023

@tmattio , lists are already working. I've created an issue in cmarkit, so that it works by default in future:
dbuenzli/cmarkit#9

@Khady
Copy link
Collaborator

Khady commented May 19, 2023

actually I think that @jorisgio is the original author, but I'll try to have a look at it too

@rgrinberg rgrinberg mentioned this pull request Jun 5, 2023
_
Signed-off-by: Rudi Grinberg <[email protected]>
@rgrinberg rgrinberg added this to the 1.16.0 milestone Jun 8, 2023
@rgrinberg rgrinberg merged commit fe72fab into ocaml:master Jun 8, 2023
rgrinberg added a commit to rgrinberg/opam-repository that referenced this pull request Jun 18, 2023
CHANGES:

## Fixes

- Disable code lens by default. The support can be re-enabled by explicitly
  setting it in the configuration. (ocaml/ocaml-lsp#1134)

- Fix initilization of `ocamlformat-rpc` in some edge cases when ocamlformat is
  initialized concurrently (ocaml/ocaml-lsp#1132)

- Kill unnecessary `$ dune ocaml-merlin` with SIGTERM rather than SIGKILL
  (ocaml/ocaml-lsp#1124)

- Refactor comment parsing to use `odoc-parser` and `cmarkit` instead of
  `octavius` and `omd` (ocaml/ocaml-lsp#1088)

  This allows users who migrated to omd 2.X to install ocaml-lsp-server in the
  same opam switch.

  We also slightly improved markdown generation support and fixed a couple in
  the generation of inline heading and module types.

- Allow opening documents that were already open. This is a workaround for
  neovim's lsp client (ocaml/ocaml-lsp#1067)

- Disable type annotation for functions (ocaml/ocaml-lsp#1054)

- Respect codeActionLiteralSupport capability (ocaml/ocaml-lsp#1046)

- Fix a document syncing issue when utf-16 is the position encoding (ocaml/ocaml-lsp#1004)

- Disable "Type-annotate" action for code that is already annotated.
  ([ocaml/ocaml-lsp#1037](ocaml/ocaml-lsp#1037)), fixes
  [ocaml/ocaml-lsp#1036](ocaml/ocaml-lsp#1036)

- Fix semantic highlighting of long identifiers when using preprocessors
  ([ocaml/ocaml-lsp#1049](ocaml/ocaml-lsp#1049), fixes
  [ocaml/ocaml-lsp#1034](ocaml/ocaml-lsp#1034))

- Fix the type of DocumentSelector in cram document registration (ocaml/ocaml-lsp#1068)

- Accept the `--clientProcessId` command line argument. (ocaml/ocaml-lsp#1074)

- Accept `--port` as a synonym for `--socket`. (ocaml/ocaml-lsp#1075)

- Fix connecting to dune rpc on Windows. (ocaml/ocaml-lsp#1080)

## Features

- Add "Remove type annotation" code action. (ocaml/ocaml-lsp#1039)

- Support settings through `didChangeConfiguration` notification (ocaml/ocaml-lsp#1103)

- Add "Extract local" and "Extract function" code actions. (ocaml/ocaml-lsp#870)

- Depend directly on `merlin-lib` 4.9 (ocaml/ocaml-lsp#1070)
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.

6 participants