Skip to content

Tools: fix tagged variant module and export more functions #866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog

> **Tags:**
>
> - :boom: [Breaking Change]
> - :eyeglasses: [Spec Compliance]
> - :rocket: [New Feature]
> - :bug: [Bug Fix]
> - :memo: [Documentation]
> - :house: [Internal]
> - :nail_care: [Polish]

## master

#### :rocket: New Feature

- Expose more `decode` functions. https://github.com/rescript-lang/rescript-vscode/pull/866

#### :bug: Bug Fix

- Fix tagged variant for `Module` and add attr to interface files. https://github.com/rescript-lang/rescript-vscode/pull/866
18 changes: 9 additions & 9 deletions tools/package-lock.json

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

4 changes: 2 additions & 2 deletions tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rescript/tools",
"description": "ReScript Tools",
"version": "0.1.3",
"version": "0.2.0",
"author": "ReScript Team",
"license": "MIT",
"bin": {
Expand Down Expand Up @@ -36,6 +36,6 @@
"build": "rescript build"
},
"dependencies": {
"rescript": "^11.0.0-rc.4"
"rescript": "^11.0.0-rc.7"
}
}
2 changes: 1 addition & 1 deletion tools/rescript.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rescript/tools",
"version": "0.1.0",
"version": "0.2.0",
"sources": [
{
"dir": "src"
Expand Down
16 changes: 8 additions & 8 deletions tools/src/Tools_Docgen.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ type rec item =
/** Additional documentation for constructors and record fields, if available. */
detail?: detail,
})
| @as("module") Module(docsForModule)
| @as("module")
Module({
id: string,
docstrings: array<string>,
deprecated?: string,
name: string,
items: array<item>,
})
| @as("moduleAlias")
ModuleAlias({
id: string,
docstrings: array<string>,
name: string,
items: array<item>,
})
and docsForModule = {
id: string,
docstrings: array<string>,
deprecated?: string,
name: string,
items: array<item>,
}

let decodeDocstrings = item => {
open Js.Json
Expand Down
45 changes: 33 additions & 12 deletions tools/src/Tools_Docgen.resi
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,52 @@ type constructor = {
signature: string,
deprecated?: string,
}
type detail = Record({items: array<field>}) | Variant({items: array<constructor>})
@tag("kind")
type detail =
| @as("record") Record({items: array<field>})
| @as("variant") Variant({items: array<constructor>})

@tag("kind")
type rec item =
| Value({
| @as("value")
Value({
id: string,
docstrings: array<string>,
signature: string,
name: string,
deprecated?: string,
})
| Type({
| @as("type")
Type({
id: string,
docstrings: array<string>,
signature: string,
name: string,
deprecated?: string,
/** Additional documentation for constructors and record fields, if available. */
detail?: detail,
})
| Module(docsForModule)
| ModuleAlias({id: string, docstrings: array<string>, name: string, items: array<item>})
and docsForModule = {
id: string,
docstrings: array<string>,
deprecated?: string,
name: string,
items: array<item>,
}
| @as("module")
Module({
id: string,
docstrings: array<string>,
deprecated?: string,
name: string,
items: array<item>,
})
| @as("moduleAlias")
ModuleAlias({
id: string,
docstrings: array<string>,
name: string,
items: array<item>,
})

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

let decodeValue: Js.Dict.t<Js.Json.t> => item
let decodeType: Js.Dict.t<Js.Json.t> => item
let decodeModule: Js.Dict.t<Js.Json.t> => item
let decodeModuleAlias: Js.Dict.t<Js.Json.t> => item
let decodeItem: Js.Json.t => item
let decodeFromJson: Js.Json.t => doc