From 96f3883ca032af81ee615adbde2c7e7f1a815c26 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Mon, 10 Jun 2024 03:26:11 -0300 Subject: [PATCH] Tools: Print module structure with signature to module path (#1018) * print module structure with signature to module path * update CHANGELOG.md --- tools/CHANGELOG.md | 4 +++ tools/src/tools.ml | 6 ++++ .../src/expected/DocExtractionRes.res.json | 36 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/tools/CHANGELOG.md b/tools/CHANGELOG.md index 394d4e421..184e006d8 100644 --- a/tools/CHANGELOG.md +++ b/tools/CHANGELOG.md @@ -12,6 +12,10 @@ ## master +### :bug: Bug Fix + +- Print module structure with signature to module path. https://github.com/rescript-lang/rescript-vscode/pull/1018 + ## 0.6.3 #### :bug: Bug Fix diff --git a/tools/src/tools.ml b/tools/src/tools.ml index b2a9fd742..9a314f92d 100644 --- a/tools/src/tools.ml +++ b/tools/src/tools.ml @@ -469,6 +469,12 @@ let extractDocs ~entryPointFile ~debug = (extractDocsForModule ~modulePath:(interface.name :: modulePath) interface)) + | Module {type_ = Constraint (Structure m, Ident _)} -> + (* module M: T = { }. Print M *) + Some + (Module + (extractDocsForModule + ~modulePath:(m.name :: modulePath) m)) | _ -> None); } in diff --git a/tools/tests/src/expected/DocExtractionRes.res.json b/tools/tests/src/expected/DocExtractionRes.res.json index 3ea8b7eb8..5f46f92db 100644 --- a/tools/tests/src/expected/DocExtractionRes.res.json +++ b/tools/tests/src/expected/DocExtractionRes.res.json @@ -306,5 +306,41 @@ "col": 3 } }] + }, + { + "id": "DocExtractionRes.M", + "name": "M", + "kind": "module", + "docstrings": ["implementation of Example module type"], + "source": { + "filepath": "src/DocExtractionRes.res", + "line": 1, + "col": 1 + }, + "items": [ + { + "id": "DocExtractionRes.M.t", + "kind": "type", + "name": "t", + "signature": "type t = int", + "docstrings": ["main type"], + "source": { + "filepath": "src/DocExtractionRes.res", + "line": 123, + "col": 3 + } + }, + { + "id": "DocExtractionRes.M.f", + "kind": "value", + "name": "f", + "signature": "let f: int => int", + "docstrings": ["identity function"], + "source": { + "filepath": "src/DocExtractionRes.res", + "line": 128, + "col": 7 + } + }] }] }