Skip to content

Commit

Permalink
tools: fix dir_sep and update rescript files
Browse files Browse the repository at this point in the history
  • Loading branch information
aspeddro committed Jan 27, 2024
1 parent 79e7e1e commit 10818a4
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 16 deletions.
8 changes: 8 additions & 0 deletions tools/npm/RescriptTools.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tools/npm/Tools_Docgen.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tools/npm/Tools_Docgen.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ type detail =
| @as("record") Record({items: array<field>})
| @as("variant") Variant({items: array<constructor>})

type source = {
filepath: string,
line: int,
col: int,
}

@tag("kind")
type rec item =
| @as("value")
Expand All @@ -31,6 +37,7 @@ type rec item =
signature: string,
name: string,
deprecated?: string,
source: source,
})
| @as("type")
Type({
Expand All @@ -39,6 +46,7 @@ type rec item =
signature: string,
name: string,
deprecated?: string,
source: source,
/** Additional documentation for constructors and record fields, if available. */
detail?: detail,
})
Expand All @@ -48,20 +56,23 @@ type rec item =
docstrings: array<string>,
deprecated?: string,
name: string,
source: source,
items: array<item>,
})
| @as("moduleAlias")
ModuleAlias({
id: string,
docstrings: array<string>,
name: string,
source: source,
items: array<item>,
})

type doc = {
name: string,
deprecated: option<string>,
docstrings: array<string>,
source: source,
items: array<item>,
}

Expand Down
18 changes: 17 additions & 1 deletion tools/npm/Tools_Docgen.resi
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ type detail =
| @as("record") Record({items: array<field>})
| @as("variant") Variant({items: array<constructor>})

type source = {
filepath: string,
line: int,
col: int,
}

@tag("kind")
type rec item =
| @as("value")
Expand All @@ -30,6 +36,7 @@ type rec item =
signature: string,
name: string,
deprecated?: string,
source: source,
})
| @as("type")
Type({
Expand All @@ -38,6 +45,7 @@ type rec item =
signature: string,
name: string,
deprecated?: string,
source: source,
/** Additional documentation for constructors and record fields, if available. */
detail?: detail,
})
Expand All @@ -47,16 +55,24 @@ type rec item =
docstrings: array<string>,
deprecated?: string,
name: string,
source: source,
items: array<item>,
})
| @as("moduleAlias")
ModuleAlias({
id: string,
docstrings: array<string>,
name: string,
source: source,
items: array<item>,
})

type doc = {name: string, deprecated: option<string>, docstrings: array<string>, items: array<item>}
type doc = {
name: string,
deprecated: option<string>,
docstrings: array<string>,
source: source,
items: array<item>,
}

let decodeFromJson: Js.Json.t => doc
9 changes: 6 additions & 3 deletions tools/src/tools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ let typeDetail typ ~env ~full =
let makeId modulePath ~identifier =
identifier :: modulePath |> List.rev |> SharedTypes.ident

(**
Get relative path to res/resi file
*)
let findRelativePath ~rootPath ~path =
let open Filename in
let realPath =
Expand All @@ -290,7 +293,7 @@ let findRelativePath ~rootPath ~path =
in
let rec loop dirPath acc =
match dirname dirPath = realPath with
| true -> basename dirPath :: acc |> String.concat dir_sep
| true -> basename dirPath :: acc |> String.concat "/"
| false -> (
match dirPath with
| "/" -> failwith "Failed to find relative path of package"
Expand Down Expand Up @@ -359,8 +362,8 @@ let extractDocs ~entryPointFile ~debug =
| true -> file.uri |> Uri.toPath
| false ->
findRelativePath ~rootPath ~path:(file.uri |> Uri.toPath));
line = 0;
col = 0;
line = 1;
col = 1;
};
items =
structure.items
Expand Down
4 changes: 2 additions & 2 deletions tools/tests/src/expected/DocExtraction2.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"docstrings": ["Module level doc here."],
"source": {
"filepath": "src/DocExtraction2.resi",
"line": 0,
"col": 0
"line": 1,
"col": 1
},
"items": [
{
Expand Down
4 changes: 2 additions & 2 deletions tools/tests/src/expected/DocExtraction2.resi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"docstrings": ["Module level doc here."],
"source": {
"filepath": "src/DocExtraction2.resi",
"line": 0,
"col": 0
"line": 1,
"col": 1
},
"items": [
{
Expand Down
8 changes: 4 additions & 4 deletions tools/tests/src/expected/DocExtractionRes.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"docstrings": ["Module level documentation goes here."],
"source": {
"filepath": "src/DocExtractionRes.res",
"line": 0,
"col": 0
"line": 1,
"col": 1
},
"items": [
{
Expand Down Expand Up @@ -242,8 +242,8 @@
"docstrings": [],
"source": {
"filepath": "src/DocExtractionRes.res",
"line": 0,
"col": 0
"line": 1,
"col": 1
},
"items": [
{
Expand Down
4 changes: 2 additions & 2 deletions tools/tests/src/expected/ModC.res.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"docstrings": [],
"source": {
"filepath": "src/ModC.resi",
"line": 0,
"col": 0
"line": 1,
"col": 1
},
"items": [
{
Expand Down
4 changes: 2 additions & 2 deletions tools/tests/src/expected/ModC.resi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"docstrings": [],
"source": {
"filepath": "src/ModC.resi",
"line": 0,
"col": 0
"line": 1,
"col": 1
},
"items": [
{
Expand Down

0 comments on commit 10818a4

Please sign in to comment.