Skip to content

Commit ba7ac0a

Browse files
authored
Polish: LSP and Tools package (#833)
* update ci, readme and contributing.md * fix * add Cli.resi and rescript.json * fixes * restore some changes
1 parent 282334f commit ba7ac0a

File tree

6 files changed

+27
-36
lines changed

6 files changed

+27
-36
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ A screenshot of the result:
176176

177177
![Shows the end result in VSCode, with ReScript related files nested under eachother appropriately.](https://user-images.githubusercontent.com/1457626/168123647-400e2f09-31e3-45a2-b74b-190c7c207446.png)
178178

179-
## ⌨️ Use with Other Editors
180-
181-
This repo also contains a language server that can power other editors. **However, the language server in this project is a pure implementation detail. We don't guarantee its stability for other editors' consumption** apart from Vim and Sublime Text.
182-
183-
Still, if you'd like to use this language-server with other editors:
184-
185-
- Get the release binaries from the Github Releases page.
186-
- Unzip the `.vsix` and get the `server` folder. That's the only folder you need.
187-
- The language server will be at `server/out/server.js`. Call it through node, and optionally pass `--stdio` if your editor doesn't support the default JSONRPC.
188-
189179
## 📰 Changelog
190180

191181
See [CHANGELOG](CHANGELOG.md)

tools/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"src/*.res",
1818
"src/*.resi",
1919
"analysis_binaries/",
20+
"rescript.json",
2021
"README.md"
2122
],
2223
"engines": {

tools/rescript.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"version": "0.1.0",
44
"sources": [
55
{
6-
"dir": "src",
7-
"public": ["RescriptTools"]
6+
"dir": "src"
87
}
98
],
109
"suffix": ".bs.js",

tools/src/Cli.resi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tools/src/Tools_Docgen.res

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ type field = {
33
docstrings: array<string>,
44
signature: string,
55
optional: bool,
6-
deprecated: option<string>,
6+
deprecated?: string,
77
}
88

99
type constructor = {
1010
name: string,
1111
docstrings: array<string>,
1212
signature: string,
13-
deprecated: option<string>,
13+
deprecated?: string,
1414
}
1515

1616
@tag("kind")
1717
type detail =
18-
| @as("record") Record(array<field>)
19-
| @as("variant") Variant(array<constructor>)
18+
| @as("record") Record({items: array<field>})
19+
| @as("variant") Variant({items: array<constructor>})
2020

2121
@tag("kind")
2222
type rec item =
@@ -26,17 +26,17 @@ type rec item =
2626
docstrings: array<string>,
2727
signature: string,
2828
name: string,
29-
deprecated: option<string>,
29+
deprecated?: string,
3030
})
3131
| @as("type")
3232
Type({
3333
id: string,
3434
docstrings: array<string>,
3535
signature: string,
3636
name: string,
37-
deprecated: option<string>,
37+
deprecated?: string,
3838
/** Additional documentation for constructors and record fields, if available. */
39-
detail: option<detail>,
39+
detail?: detail,
4040
})
4141
| @as("module") Module(docsForModule)
4242
| @as("moduleAlias")
@@ -49,7 +49,7 @@ type rec item =
4949
and docsForModule = {
5050
id: string,
5151
docstrings: array<string>,
52-
deprecated: option<string>,
52+
deprecated?: string,
5353
name: string,
5454
items: array<item>,
5555
}
@@ -86,7 +86,7 @@ let decodeDepreacted = item => {
8686

8787
let decodeRecordFields = fields => {
8888
open Js.Json
89-
let fields = fields->Js.Array2.map(field => {
89+
let items = fields->Js.Array2.map(field => {
9090
switch field {
9191
| Object(doc) => {
9292
let name = doc->decodeStringByField("name")
@@ -98,32 +98,32 @@ let decodeRecordFields = fields => {
9898
| _ => assert(false)
9999
}
100100

101-
{name, docstrings, signature, optional, deprecated}
101+
{name, docstrings, signature, optional, ?deprecated}
102102
}
103103

104104
| _ => assert(false)
105105
}
106106
})
107-
Record(fields)
107+
Record({items: items})
108108
}
109109

110110
let decodeConstructorFields = fields => {
111111
open Js.Json
112-
let fields = fields->Js.Array2.map(field => {
112+
let items = fields->Js.Array2.map(field => {
113113
switch field {
114114
| Object(doc) => {
115115
let name = doc->decodeStringByField("name")
116116
let docstrings = doc->decodeDocstrings
117117
let signature = doc->decodeStringByField("signature")
118118
let deprecated = doc->decodeDepreacted
119119

120-
{name, docstrings, signature, deprecated}
120+
{name, docstrings, signature, ?deprecated}
121121
}
122122

123123
| _ => assert(false)
124124
}
125125
})
126-
Variant(fields)
126+
Variant({items: items})
127127
}
128128

129129
let decodeDetail = detail => {
@@ -151,7 +151,7 @@ let rec decodeValue = item => {
151151
let name = item->decodeStringByField("name")
152152
let deprecated = item->decodeDepreacted
153153
let docstrings = item->decodeDocstrings
154-
Value({id, docstrings, signature, name, deprecated})
154+
Value({id, docstrings, signature, name, ?deprecated})
155155
}
156156
and decodeType = item => {
157157
let id = item->decodeStringByField("id")
@@ -163,7 +163,7 @@ and decodeType = item => {
163163
| Some(field) => decodeDetail(field)->Some
164164
| None => None
165165
}
166-
Type({id, docstrings, signature, name, deprecated, detail})
166+
Type({id, docstrings, signature, name, ?deprecated, ?detail})
167167
}
168168
and decodeModuleAlias = item => {
169169
open Js.Json
@@ -186,7 +186,7 @@ and decodeModule = item => {
186186
| Some(Array(items)) => items->Js.Array2.map(item => decodeItem(item))
187187
| _ => assert(false)
188188
}
189-
Module({id, name, docstrings, deprecated, items})
189+
Module({id, name, docstrings, ?deprecated, items})
190190
}
191191
and decodeItem = item => {
192192
open Js.Json

tools/src/Tools_Docgen.resi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ type field = {
33
docstrings: array<string>,
44
signature: string,
55
optional: bool,
6-
deprecated: option<string>,
6+
deprecated?: string,
77
}
88
type constructor = {
99
name: string,
1010
docstrings: array<string>,
1111
signature: string,
12-
deprecated: option<string>,
12+
deprecated?: string,
1313
}
14-
type detail = Record(array<field>) | Variant(array<constructor>)
14+
type detail = Record({items: array<field>}) | Variant({items: array<constructor>})
1515
type rec item =
1616
| Value({
1717
id: string,
1818
docstrings: array<string>,
1919
signature: string,
2020
name: string,
21-
deprecated: option<string>,
21+
deprecated?: string,
2222
})
2323
| Type({
2424
id: string,
2525
docstrings: array<string>,
2626
signature: string,
2727
name: string,
28-
deprecated: option<string>,
29-
detail: option<detail>,
28+
deprecated?: string,
29+
detail?: detail,
3030
})
3131
| Module(docsForModule)
3232
| ModuleAlias({id: string, docstrings: array<string>, name: string, items: array<item>})
3333
and docsForModule = {
3434
id: string,
3535
docstrings: array<string>,
36-
deprecated: option<string>,
36+
deprecated?: string,
3737
name: string,
3838
items: array<item>,
3939
}

0 commit comments

Comments
 (0)