File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1212
1313# 12.0.0-alpha.14 (Unreleased)
1414
15+ #### :bug : Bug fix
16+
17+ - ` rescript-tools doc ` no longer includes shadowed bindings in its output. https://github.com/rescript-lang/rescript/pull/7497
18+
1519# 12.0.0-alpha.13
1620
1721#### :boom : Breaking Change
Original file line number Diff line number Diff line change 11open Analysis
22
3+ module StringSet = Set. Make (String )
4+
35type fieldDoc = {
46 fieldName : string ;
57 docstrings : string list ;
@@ -458,6 +460,7 @@ let extractDocs ~entryPointFile ~debug =
458460 let env = QueryEnv. fromFile file in
459461 let rec extractDocsForModule ?(modulePath = [env.file.moduleName])
460462 (structure : Module.structure ) =
463+ let valuesSeen = ref StringSet. empty in
461464 {
462465 id = modulePath |> List. rev |> ident;
463466 docstring = structure.docstring |> List. map String. trim;
@@ -611,7 +614,18 @@ let extractDocs ~entryPointFile ~debug =
611614 (makeId ~identifier: (Path. name p)
612615 moduleTypeIdPath);
613616 })
614- | _ -> None );
617+ | _ -> None )
618+ (* Filter out shadowed bindings by keeping only the last value associated with an id *)
619+ |> List. rev
620+ |> List. filter_map (fun (docItem : docItem ) ->
621+ match docItem with
622+ | Value {id} ->
623+ if StringSet. mem id ! valuesSeen then None
624+ else (
625+ valuesSeen := StringSet. add id ! valuesSeen;
626+ Some docItem)
627+ | _ -> Some docItem)
628+ |> List. rev;
615629 }
616630 in
617631 let docs = extractDocsForModule structure in
You can’t perform that action at this time.
0 commit comments