Skip to content

Commit 5896242

Browse files
authored
fix(graindoc): Use value_descriptions and type_declarations defined by the module signature (#1241)
* fix(graindoc): Use value_descriptions and type_declarations defined by the module signature * Regen Map docs
1 parent f8a0891 commit 5896242

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

compiler/graindoc/docblock.re

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,19 @@ let for_type_declaration =
140140
let for_signature_item =
141141
(~env: Env.t, ~comments, sig_item: Types.signature_item) => {
142142
switch (sig_item) {
143-
| TSigValue(ident, vd) =>
144-
let vd = Env.find_value(vd.val_fullpath, env);
145-
let docblock = for_value_description(~comments, ~ident, vd);
143+
| TSigValue(ident, ovd) =>
144+
// Fetch original location as signatures don't contain real locations
145+
let vd = Env.find_value(ovd.val_fullpath, env);
146+
let val_loc = vd.val_loc;
147+
let docblock =
148+
for_value_description(~comments, ~ident, {...ovd, val_loc});
146149
Some(docblock);
147-
| TSigType(ident, td, _rec) =>
148-
let td = Env.find_type(td.type_path, env);
149-
let docblock = for_type_declaration(~comments, ~ident, td);
150+
| TSigType(ident, otd, _rec) =>
151+
// Fetch original location as signatures don't contain real locations
152+
let td = Env.find_type(otd.type_path, env);
153+
let type_loc = td.type_loc;
154+
let docblock =
155+
for_type_declaration(~comments, ~ident, {...otd, type_loc});
150156
Some(docblock);
151157
| _ => None
152158
};

stdlib/map.gr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ record Bucket<k, v> {
1818
mut next: Option<Bucket<k, v>>,
1919
}
2020

21+
/**
22+
* @section Types: Type declarations included in the Map module.
23+
*/
24+
2125
record Map<k, v> {
2226
mut size: Number,
2327
mut buckets: Array<Option<Bucket<k, v>>>,
@@ -35,6 +39,7 @@ record Map<k, v> {
3539
*
3640
* @since v0.2.0
3741
*/
42+
3843
// TODO: This could take an `eq` function to custom comparisons
3944
export let makeSized = size => {
4045
let buckets = Array.make(size, None)

stdlib/map.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ No other changes yet.
1313
import Map from "map"
1414
```
1515

16+
## Types
17+
18+
Type declarations included in the Map module.
19+
20+
### Map.**Map**
21+
22+
```grain
23+
type Map<k, v>
24+
```
25+
1626
## Values
1727

1828
Functions for working with Maps.

0 commit comments

Comments
 (0)