Skip to content

Commit 4890db4

Browse files
zthaspeddro
andauthored
Touch ups to LSP and Tools packages (#830)
* name changes and other touch ups * add sample zero cost variant version of docgen representation * Polish: LSP and Tools package (#833) * update ci, readme and contributing.md * fix * add Cli.resi and rescript.json * fixes * restore some changes --------- Co-authored-by: Pedro Castro <aspeddro@gmail.com>
1 parent 65c25b0 commit 4890db4

17 files changed

+106
-55
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ Analysis bin is what we currently call the OCaml code that does deeper language
192192

193193
We're happy to gather more resources over time here, including more in-depth getting started guides.
194194

195-
## Release
195+
## Releasing the VSCode extension and standalone LSP package
196+
197+
_This below will automatically release the LSP package as well._
196198

197199
1. Bump the version to an _even minor_ version number in `package.json` and `server/package.json` and their lockfiles. It's very important that it's an even minor like `1.8.0`, and not `1.7.0`. This is because even minors are reserved for actual releases, and uneven minors for pre-releases. Commit and push the version bump.
198200
2. Make sure @ryyppy is aware of your changes. He needs to sync them over to the vim plugin.
@@ -208,4 +210,8 @@ If that somehow does not work, you can do the above steps manually:
208210
2. Go to the appropriate [VSCode Marketplace Publisher](https://marketplace.visualstudio.com/manage/publishers/chenglou92), select the three dots next to the extension name, and choose `Update`. Upload your `.vsix` there.
209211
3. Not done! Make a new manual release [here](https://github.com/rescript-lang/rescript-vscode/releases), and make sure you attach the generated `.vsix` onto that new release as well. This is for folks who don't use the VSCode marketplace.
210212

211-
For beta releases, ask folks to try the `.vsix` from CI directly.
213+
For beta releases, ask folks to use the pre-release version installable from the VSCode Marketplace.
214+
215+
## Releasing the `@rescript/tools` package
216+
217+
The tools package is released by bumping the version in `tools/package.json`, running `npm i` in the `tools/` folder, and then pushing those changes with the commit message `publish tools`.

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)

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "0.0.0",
55
"description": "ReScript's language-client",
66
"keywords": [],
7-
"author": "chenglou",
7+
"author": "ReScript Team",
88
"license": "MIT",
99
"dependencies": {
1010
"vscode-languageclient": "8.1.0-next.5"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "rescript-vscode",
33
"displayName": "ReScript",
44
"description": "ReScript language support (official)",
5-
"author": "chenglou",
5+
"author": "ReScript Team",
66
"license": "MIT",
77
"version": "1.20.0",
88
"repository": {

server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ resciptls --stdio
1515
```sh
1616
ReScript Language Server
1717

18-
Usage: rescriptls [options]
18+
Usage: rescript-ls [options]
1919

2020
Options:
2121

server/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"name": "@rescript/lsp",
33
"description": "LSP server for ReScript",
44
"version": "1.20.0",
5-
"author": "chenglou",
5+
"author": "ReScript Team",
66
"license": "MIT",
77
"bin": {
8-
"rescriptls": "./out/cli.js"
8+
"rescript-ls": "./out/cli.js"
99
},
1010
"keywords": [
1111
"ReScript",

server/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const args = process.argv.slice(2)
66

77
const help = `ReScript Language Server
88
9-
Usage: rescriptls [options]
9+
Usage: rescript-ls [options]
1010
1111
Options:
1212

tools/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ npm install --save-dev @rescript/tools
99
## CLI Usage
1010

1111
```sh
12-
restools --help
12+
rescript-tools --help
1313
```
1414

1515
### Generate documentation
1616

1717
Print JSON:
1818

1919
```sh
20-
restools doc src/EntryPointLibFile.res
20+
rescript-tools doc src/EntryPointLibFile.res
2121
```
2222

2323
Write JSON:
2424

2525
```sh
26-
restools doc src/EntryPointLibFile.res > doc.json
26+
rescript-tools doc src/EntryPointLibFile.res > doc.json
2727
```
2828

2929
### Reanalyze
3030

3131
```sh
32-
restools reanalyze --help
32+
rescript-tools reanalyze --help
3333
```
3434

3535
## Decode JSON

tools/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"name": "@rescript/tools",
33
"description": "ReScript Tools",
44
"version": "0.1.0",
5-
"author": "chenglou",
5+
"author": "ReScript Team",
66
"license": "MIT",
77
"bin": {
8-
"restools": "./src/Cli.bs.js"
8+
"rescript-tools": "./src/Cli.bs.js"
99
},
1010
"keywords": [
1111
"ReScript",
@@ -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.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ let docHelp = `ReScript Tools
4343
4444
Output documentation to standard output
4545
46-
Usage: restools doc <FILE>
46+
Usage: rescript-tools doc <FILE>
4747
48-
Example: restools doc ./path/to/EntryPointLib.res`
48+
Example: rescript-tools doc ./path/to/EntryPointLib.res`
4949

5050
let help = `ReScript Tools
5151
52-
Usage: restools [command]
52+
Usage: rescript-tools [command]
5353
5454
Commands:
5555

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)