Skip to content

Commit 9891292

Browse files
authored
Documentation: Imrpove "Contributing" (and amend Sphinx builders) (#4494)
* Documentation: Improve "Contributing" Also fix some warnings when compiling the documentation with Sphinx. * Documentation: Nix uses `make` to build documentation
1 parent 3474a52 commit 9891292

File tree

6 files changed

+52
-63
lines changed

6 files changed

+52
-63
lines changed

.readthedocs.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: 2
22

33
sphinx:
4+
builder: "html"
45
configuration: docs/conf.py
56

67
build:

docs/Makefile

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Minimal makefile for Sphinx documentation
2-
#
32

43
# You can set these variables from the command line, and also
54
# from the environment for the first two.
@@ -8,13 +7,7 @@ SPHINXBUILD ?= sphinx-build
87
SOURCEDIR = .
98
BUILDDIR = _build
109

11-
# Put it first so that "make" without argument is like "make help".
12-
help:
13-
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
10+
.PHONY: Makefile
1411

15-
.PHONY: help Makefile
16-
17-
# Catch-all target: route all unknown targets to Sphinx using the new
18-
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19-
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
12+
html: Makefile
13+
@$(SPHINXBUILD) -n -W "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/contributing/contributing.md

+39-46
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
The Haskell tooling dream is near, we need your help!
44

5-
## How to contact the haskell ide team
5+
## How to contact the Haskell Language Server (HLS) team
66

7-
- Join the [haskell-language-server channel](https://matrix.to/#/#haskell-language-server:matrix.org) in [matrix](https://matrix.org/) (primary communication channel).
7+
- Join the [haskell-language-server channel](https://matrix.to/#/#haskell-language-server:matrix.org) on [matrix](https://matrix.org/) (primary communication channel).
88
- Join [our IRC channel](https://web.libera.chat/?channels=#haskell-language-server) at `#haskell-language-server` on [`libera`](https://libera.chat/) (secondary communication channel - all messages in this IRC channel are automatically bridged to the Matrix channel).
99
- Visit [the project GitHub repo](https://github.com/haskell/haskell-language-server) to view the source code, or open issues or pull requests.
1010

@@ -17,7 +17,7 @@ $ git clone https://github.com/haskell/haskell-language-server
1717

1818
The project can then be built with both `cabal build` and `stack build`.
1919

20-
### Using Cabal
20+
### Building with Cabal
2121

2222
```shell
2323
# If you have not run `cabal update` in a while
@@ -26,15 +26,15 @@ $ cabal update
2626
$ cabal build
2727
```
2828

29-
### Using Stack
29+
### Building with Stack
3030

3131
```shell
3232
$ stack build
3333
```
3434

35-
### Using Nix
35+
### Building with Nix
3636

37-
The instructions below show how to set up a Cachix binary cache and open a nix shell for local development.
37+
The instructions below show how to set up a Cachix binary cache and open a Nix shell for local development.
3838

3939
```shell
4040
$ cachix use haskell-language-server
@@ -45,19 +45,19 @@ $ cabal build
4545

4646
#### Flakes support
4747

48-
If you are using nix 2.4 style command (enabled by `experimental-features = nix-command`),
48+
If you are using Nix 2.4 style commands (enabled by `experimental-features = nix-command`),
4949
you can use `nix develop` instead of `nix-shell` to enter the development shell. To enter the shell with specific GHC versions:
5050

51-
* `nix develop` - default GHC version
52-
* `nix develop .#shell-ghc90` - GHC 9.0.1 (substitute GHC version as appropriate)
51+
* `nix develop` - default GHC version,
52+
* `nix develop .#shell-ghc90` - GHC 9.0.1 (substitute GHC version as appropriate).
5353

54-
If you are looking for a Nix expression to create haskell-language-server binaries, see https://github.com/haskell/haskell-language-server/issues/122
54+
If you are looking for a Nix expression to create `haskell-language-server` binaries, see https://github.com/haskell/haskell-language-server/issues/122
5555

5656
## Testing
5757

5858
The tests make use of the [Tasty](https://github.com/feuerbach/tasty) test framework.
5959

60-
There are two test suites in the main haskell-language-server package, functional tests, and wrapper tests.
60+
There are two test suites in the main `haskell-language-server` package, functional tests, and wrapper tests.
6161
Some of the wrapper tests expect `stack` to be present on the system, or else they fail.
6262
Other project packages, like the core library or plugins, can have their own test suite.
6363

@@ -92,7 +92,7 @@ $ cabal test hls-refactor-plugin-tests
9292
Running a subset of tests
9393

9494
Tasty supports providing
95-
[Patterns](https://github.com/feuerbach/tasty#patterns) as command
95+
[patterns](https://github.com/feuerbach/tasty#patterns) as command
9696
line arguments, to select the specific tests to run.
9797

9898
```bash
@@ -126,7 +126,7 @@ If you want to test HLS while hacking on it (you can even test it on HLS codebas
126126
3. (Every time you change the HLS code) Rebuild HLS
127127
4. (Every time you change the HLS code) Restart the LSP workspace
128128
129-
### Find the path to the hacked HLS you build
129+
### Find the path to your HLS build
130130
Note that unless you change the GHC version or the HLS version between builds, the path should remain the same, this is why you need to set it only once.
131131
132132
#### Using Cabal
@@ -145,9 +145,9 @@ $ echo $(pwd)/$(stack path --dist-dir)/build/haskell-language-server/haskell-lan
145145
<some long path>/haskell-language-server
146146
```
147147

148-
### Configure your editor to use it
148+
### Configuring your editor to use your HLS build
149149

150-
#### VS Code
150+
#### Configuring VS Code
151151
When using VS Code you can set up each project to use a specific HLS executable:
152152

153153
- If it doesn't already exist in your project directory, create a directory called `.vscode`.
@@ -158,7 +158,7 @@ When using VS Code you can set up each project to use a specific HLS executable:
158158
}
159159
```
160160

161-
#### Emacs
161+
#### Configuring Emacs
162162
There are several ways to configure the HLS server path:
163163
- `M-x customize-group<RET>lsp-haskell<RET>Lsp Haskell Server Path`
164164
- Evaluate `(setq lsp-haskell-server-path "/path/to/your/hacked/haskell-language-server")`
@@ -180,73 +180,66 @@ There are several ways to configure the HLS server path:
180180

181181
The project includes a [`.editorconfig`](https://editorconfig.org) [file](https://github.com/haskell/haskell-language-server/blob/master/.editorconfig) with the editor basic settings used by the project.
182182
However, most editors will need some action to honour those settings automatically.
183-
For example vscode needs to have installed a specific [extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig).
183+
For example VS Code needs to have installed a specific [extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig).
184184
Please, try to follow those basic settings to keep the codebase as uniform as possible.
185185

186186
### Formatter pre-commit hook
187187

188-
We are using [pre-commit](https://pre-commit.com/) to configure git pre-commit hook for formatting. Although it is possible to run formatting manually, we recommend you to use it to set pre-commit hook as our CI checks pre-commit hook is applied or not.
188+
We are using [pre-commit](https://pre-commit.com/) to configure the git pre-commit hook for formatting. Although it is possible to format code manually, we recommend you to use the pre-commit hook as our CI checks if the hook was applied or not.
189189

190-
If you are using Nix or Gitpod, pre-commit hook is automatically installed. Otherwise, follow instructions on
191-
[https://pre-commit.com/](https://pre-commit.com/) to install the `pre-commit` tool, then run the following command:
190+
If you are using Nix or Gitpod, the pre-commit hook is automatically installed. Otherwise, follow the instructions on
191+
[https://pre-commit.com/](https://pre-commit.com/) to install the `pre-commit` tool. Then run the following command:
192192

193193
```sh
194194
pre-commit install
195195
```
196196

197-
#### Why some components are excluded from automatic formatting?
197+
#### Why are some components excluded from automatic formatting?
198198

199-
- `test/testdata` and `test/data` are there as we want to test formatting plugins.
200-
- `hie-compat` is there as we want to keep its code as close to GHC as possible.
199+
- `test/testdata` and `test/data` are excluded because we want to test formatting plugins.
200+
- `hie-compat` is excluded because we want to keep its code as close to GHC as possible.
201201

202-
## Introduction tutorial
202+
## Plugin tutorial
203203

204-
See the [tutorial](./plugin-tutorial.md) on writing a plugin in HLS.
204+
See the [tutorial on writing a plugin in HLS](./plugin-tutorial.md).
205205

206206
## Measuring, benchmarking and tracing
207207

208208
### Benchmarks
209209

210-
If you are touching performance sensitive code, take the time to run a differential
211-
benchmark between HEAD and master using the benchHist script. This assumes that
212-
"master" points to the upstream master.
210+
If you are touching performance sensitive code, take the time to run a differential benchmark between `HEAD` and `origin/master` (see [bench/README](https://github.com/haskell/haskell-language-server/blob/master/bench/README.md)).
213211

214-
Run the benchmarks with `cabal bench`.
215-
216-
It should take around 25 minutes and the results will be stored in the `bench-results` folder. To interpret the results, see the comments in the `bench/Main.hs` module.
217-
218-
More details in [bench/README](https://github.com/haskell/haskell-language-server/blob/master/bench/README.md)
212+
Run the benchmarks with `cabal bench`. The runtime is about 25 minutes and the results will be stored in the `bench-results` folder. To interpret the results, see the comments in the [bench/Main.hs](https://github.com/haskell/haskell-language-server/blob/master/bench/Main.hs) module.
219213

220214
### Tracing
221215

222-
HLS records opentelemetry [eventlog traces](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime_control.html#rts-eventlog) via [opentelemetry](https://hackage.haskell.org/package/opentelemetry). To generate the traces, build with `-eventlog` and run with `+RTS -l`. To visualize the traces, install [Tracy](https://github.com/wolfpld/tracy) and use [eventlog-to-tracy](https://hackage.haskell.org/package/opentelemetry-extra) to open the generated eventlog.
216+
HLS records [eventlog traces](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/runtime_control.html#rts-eventlog) via [opentelemetry](https://hackage.haskell.org/package/opentelemetry). To generate the traces, build with `-eventlog` and run with `+RTS -l`. To visualize the traces, install [Tracy](https://github.com/wolfpld/tracy) and use [eventlog-to-tracy](https://hackage.haskell.org/package/opentelemetry-extra) to open the generated eventlog.
223217

224218
## Adding support for a new editor
225219

226220
Adding support for new editors is fairly easy if the editor already has good support for generic LSP-based extensions.
227-
In that case, there will likely be an editor-specific support system for this (like `lsp-mode` for Emacs).
228-
This will typically provide instructions for how to support new languages.
221+
In that case, there will likely be an editor-specific support system (e.g., `lsp-mode` for Emacs).
222+
The support system will typically provide instructions for how to add support for new languages.
229223

230-
In some cases you may need to write a small bit of additional client support, or expose a way for the user to set the server's [configuration options](../configuration.md#configuring-haskell-language-server) and
231-
for them to configure how the server is started.
224+
In some cases you may need to write a small bit of additional client support, or expose a way for the user to set the server's [configuration options](../configuration.md#configuring-haskell-language-server) and for them to configure how the server is started.
232225

233-
## Building the docs
226+
## Building the documentation
234227

235-
The docs are built with [Sphinx](https://www.sphinx-doc.org/en/master/) and [ReadTheDocs](https://docs.readthedocs.io/en/stable/index.html), the documentation for both is helpful.
228+
The documentation is built with [Sphinx](https://www.sphinx-doc.org/en/master/) and [ReadTheDocs](https://docs.readthedocs.io/en/stable/index.html), the documentation of both is helpful.
236229

237-
To build the docs you need to install some Python prerequisites. You can either `pip install -r docs/requirements.txt`, or simply enter a `nix-shell`.
230+
You need to install some Python prerequisites. You can either `pip install -r docs/requirements.txt`, or simply enter a `nix-shell`.
238231

239-
Then to build and preview the docs:
232+
Then to build and preview the documentation:
240233

241234
```
242235
cd docs
243236
make html
244237
firefox _build/html/index.html
245238
```
246239

247-
Alternatively, you can build the entire thing as a Nix derivation from the flake with `nix build .#docs`.
240+
Alternatively, you can build the documentation as a Nix derivation from the Flake with `nix build .#docs`.
248241

249-
The docs are also built and previewed on every PR, so you can check them from the PR status.
242+
The documentation is also built and previewed on every PR, so you can check them from the PR status.
250243

251244
## Working on code actions
252245

@@ -255,8 +248,8 @@ To make HLS easier to maintain, please follow these design guidelines when addin
255248
1. Prefer `ghc-exactprint` to manual text parsing.
256249
2. Prefer `ghc-exactprint` to manual code generation.
257250
3. Code generating actions should not try to format the generated code. Assume that the user is also leveraging HLS for automated code formatting.
258-
4. Put new code actions in their own plugin unless they are very closely aligned with an existing ghcide code action.
251+
4. Put new code actions in their own plugin unless they are very closely aligned with an existing code action.
259252

260253
## Sponsorship
261254

262-
If you want to contribute financially you can do so via [open-collective](https://opencollective.com/haskell-language-server). In the past the funding has been used to sponsor [summer student projects](https://mpickering.github.io/ide/posts/2021-07-22-summer-of-hls.html).
255+
If you want to contribute financially, you can do so via [open-collective](https://opencollective.com/haskell-language-server). In the past, the funding was used to sponsor [summer student projects](https://mpickering.github.io/ide/posts/2021-07-22-summer-of-hls.html).

docs/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
haskell-language-server
22
=======================
33

4-
Official Haskell Language Server implementation. :ref:`Read more<What is haskell-language-server?>`.
4+
Official Haskell Language Server implementation. :ref:`Read more<What is the Haskell Language Server?>`.
55

66
.. toctree::
77
:maxdepth: 2

docs/what-is-hls.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# What is haskell-language-server?
1+
# What is the Haskell Language Server?
22

3-
The `haskell-language-server` (HLS) project is an implementation of a server (a "language server") for the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) (LSP).
3+
The Haskell Language Server (HLS) is an implementation of a server (a "language server") for the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) (LSP).
44
A language server talks to a client (typically an editor), which can ask the server to perform various operations, such as reporting errors or providing code completions.
55
The advantage of this system is that clients and servers can interoperate more easily so long as they all speak the LSP protocol.
66
In the case of HLS, that means that it can be used with many different editors, since editor support for the LSP protocol is now widespread.
@@ -35,7 +35,7 @@ Here are a few pieces of jargon that you may come across in the HLS docs or when
3535
- *Semantic highlighting*: Special syntax highlighting performed by the server.
3636
- *Method*: A LSP method is a function in the LSP protocol that the client can invoke to perform some action, e.g. ask for completions at a point.
3737

38-
## haskell-language-server
38+
## Haskell Language Server
3939

4040
### HLS and its wrapper
4141

@@ -51,7 +51,7 @@ Plugins can also be disabled independently to allow users to customize the behav
5151

5252
These plugins all (currently) live in the HLS repository and are developed in tandem with the core HLS functionality.
5353

54-
See the [configuration page](./configuration.md#generic-plugin-configuration) for more on configuring plugins.
54+
See the [configuration page](./configuration.md#Generic plugin configuration) for more on configuring plugins.
5555

5656
### hie-bios
5757

flake.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
name = "hls-docs";
2828
src = pkgs.lib.sourceFilesBySuffices ./. [ ".py" ".rst" ".md" ".png" ".gif" ".svg" ".cabal" ];
2929
buildInputs = [ pythonWithPackages ];
30-
# -n gives warnings on missing link targets, -W makes warnings into errors
31-
buildPhase = ''cd docs; sphinx-build -n -W . $out'';
30+
buildPhase = ''
31+
cd docs
32+
make --makefile=${./docs/Makefile} html BUILDDIR=$out
33+
'';
3234
dontInstall = true;
3335
};
3436

0 commit comments

Comments
 (0)