From 7831c8f12bb5fa398ca2c354f8f01f6d97be2291 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 29 Dec 2023 04:04:26 -0300 Subject: [PATCH 1/4] get docstrings from module file --- analysis/src/DocExtraction.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/analysis/src/DocExtraction.ml b/analysis/src/DocExtraction.ml index 26f338186..398a6e712 100644 --- a/analysis/src/DocExtraction.ml +++ b/analysis/src/DocExtraction.ml @@ -294,17 +294,17 @@ let extractDocs ~path ~debug = let id = (modulePath |> List.rev |> List.hd) ^ "." ^ item.name in - let items = + let items, docstring = match ProcessCmt.fileForModule ~package:full.package aliasToModule with - | None -> [] + | None -> ([], []) | Some file -> let docs = extractDocsForModule ~modulePath:[id] file.structure in - docs.items + (docs.items, docs.docstring) in Some (ModuleAlias @@ -312,7 +312,7 @@ let extractDocs ~path ~debug = id; name = item.name; items; - docstring = item.docstring |> List.map String.trim; + docstring = docstring |> List.map String.trim; }) | Module (Structure m) -> (* module Whatever = {} in res or module Whatever: {} in resi. *) From dab411ed0f34613d298dc00ba73458a917ec34ff Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 29 Dec 2023 04:05:29 -0300 Subject: [PATCH 2/4] update tests --- analysis/tests/src/expected/DocExtractionRes.res.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt index 29e35a1e3..53622fae5 100644 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ b/analysis/tests/src/expected/DocExtractionRes.res.txt @@ -97,7 +97,7 @@ extracting docs for src/DocExtractionRes.res "id": "DocExtractionRes.LinkedModule", "kind": "moduleAlias", "name": "LinkedModule", - "docstrings": ["This links another module. Neat."], + "docstrings": [], "items": [] }, { From 39b41936adacae2fabba152e884fbb3334f3a1dc Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 29 Dec 2023 18:41:40 -0300 Subject: [PATCH 3/4] [skip ci]: update CHANGELOG.md --- tools/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/CHANGELOG.md b/tools/CHANGELOG.md index 9bb8e42f9..ff661799f 100644 --- a/tools/CHANGELOG.md +++ b/tools/CHANGELOG.md @@ -12,6 +12,10 @@ ## master +#### :bug: Bug Fix + +- Fix docstrings for module alias. Get internal docstrings of module file. https://github.com/rescript-lang/rescript-vscode/pull/878 + ## 0.3.0 #### :rocket: New Feature From 8167de8bfc660bf23744cdfe666b8153c925a04e Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 30 Dec 2023 15:52:45 -0300 Subject: [PATCH 4/4] get both docstrings --- analysis/src/DocExtraction.ml | 4 ++-- analysis/tests/src/expected/DocExtractionRes.res.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/analysis/src/DocExtraction.ml b/analysis/src/DocExtraction.ml index 398a6e712..2774c8259 100644 --- a/analysis/src/DocExtraction.ml +++ b/analysis/src/DocExtraction.ml @@ -294,7 +294,7 @@ let extractDocs ~path ~debug = let id = (modulePath |> List.rev |> List.hd) ^ "." ^ item.name in - let items, docstring = + let items, internalDocstrings = match ProcessCmt.fileForModule ~package:full.package aliasToModule @@ -312,7 +312,7 @@ let extractDocs ~path ~debug = id; name = item.name; items; - docstring = docstring |> List.map String.trim; + docstring = item.docstring @ internalDocstrings |> List.map String.trim; }) | Module (Structure m) -> (* module Whatever = {} in res or module Whatever: {} in resi. *) diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt index 53622fae5..29e35a1e3 100644 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ b/analysis/tests/src/expected/DocExtractionRes.res.txt @@ -97,7 +97,7 @@ extracting docs for src/DocExtractionRes.res "id": "DocExtractionRes.LinkedModule", "kind": "moduleAlias", "name": "LinkedModule", - "docstrings": [], + "docstrings": ["This links another module. Neat."], "items": [] }, {