Skip to content

Commit 8d28a85

Browse files
author
Daniils Petrovs
authored
Add initial mkdocs documentation website (#619)
* Add initial mkdocs docsite * Add guide on mkdocs website dev * Add Mkdocs website deployment stages
1 parent 87b48c6 commit 8d28a85

File tree

16 files changed

+436
-0
lines changed

16 files changed

+436
-0
lines changed

.github/workflows/release-asset.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,22 @@ jobs:
8585
asset_path: ./elixir-ls.zip
8686
asset_name: elixir-ls.zip
8787
asset_content_type: application/zip
88+
89+
build-docsite:
90+
name: Build Mkdocs website
91+
runs-on: ubuntu-latest
92+
container:
93+
image: squidfunk/mkdocs-material
94+
steps:
95+
- name: Build
96+
run: mkdocs build -s
97+
98+
publish-docsite:
99+
name: Publish Mkdocs website to GH Pages
100+
runs-on: ubuntu-latest
101+
steps:
102+
- name: Publish
103+
uses: JamesIves/[email protected]
104+
with:
105+
branch: mkdocs
106+
folder: site

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ erl_crash.dump
3232
# But many contributors will use their own to specify their own minimum
3333
# supported version
3434
.tool-versions
35+
36+
# Mkdocs static website build directory
37+
/site

DEVELOPMENT.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,23 @@ Publish the draft release
2626
If you're debugging a running server than `IO.inspect` is a good approach, any messages you create with it will be sent to your LSP client as a log message
2727

2828
To debug in tests you can use `IO.inspect(Process.whereis(:user), message, label: "message")` to send your output directly to the group leader of the test process.
29+
30+
# Documentation website
31+
32+
The documentation website is built using the [Mkdocs](https://www.mkdocs.org) static website generator. The content is written in Markdown format in the directory [docs](./docs) and is configured via the [mkdocs.yml](./mkdocs.yml) file.
33+
34+
## Development
35+
36+
Make sure you have a recent version of Python 3 and [Pip](https://pip.readthedocs.io/en/stable/installing/) installed.
37+
38+
Install `mkdocs` and the `material` theme with Pip:
39+
40+
```shell
41+
pip install mkdocs mkdocs-material
42+
```
43+
44+
Once installed, simply run `mkdocs serve` from the project root. This will start a local web server with a file watcher.
45+
46+
## Build
47+
48+
To compile the website for deployment, run `mkdocs build` from the project root. The built static assets will be located in the `site` directory. These can then be served by any web hosting solution.

docs/features.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Features
2+
3+
- Debugger support
4+
- Automatic, incremental Dialyzer analysis
5+
- Automatic inline suggestion of @specs based on Dialyzer's inferred success typings
6+
- Inline reporting of build warnings and errors
7+
- Documentation lookup on hover
8+
- Go-to-definition
9+
- Code completion
10+
- Code formatter
11+
- Find references to functions and modules (Thanks to @mattbaker)
12+
- Quick symbol lookup in file (Thanks to @mattbaker)
13+
- Quick symbol lookup in workspace and stdlib (both Elixir and erlang) (@lukaszsamson)
14+
15+
## Automatic builds and error reporting
16+
17+
Builds are performed automatically when files are saved. If you want this to happen automatically when you type, you can turn on "autosave" in your IDE.
18+
19+
Starting in Elixir 1.6, Mix compilers adhere to the [Mix.Task.Compiler](https://hexdocs.pm/mix/master/Mix.Task.Compiler.html) behaviour and return their error and warning diagnostics in a standardized way. Errors and warnings will be shown inline in your code as well as in the "Problems" pane in the IDE. If you're using an earlier version of Elixir, you'll need to look at the text log from the extension to see the errors and warnings.
20+
21+
## Dialyzer integration
22+
23+
ElixirLS will automatically analyze your project with [Dialyzer](http://erlang.org/doc/apps/dialyzer/dialyzer_chapter.html) after each successful build. It maintains a "manifest" file in `.elixir_ls/dialyzer_manifest` that stores the results of the analysis. The initial analysis for a project can take a few minutes, but after that's completed, modules are re-analyzed only if necessary, so subsequent analyses are typically very fast -- often less than a second. It also looks at your modules' abstract code to determine whether they reference any modules that haven't been analyzed and includes them automatically.
24+
25+
You can control which warnings are shown using the `elixirLS.dialyzerWarnOpts` setting in your project or IDE's `settings.json`. Find available options in Erlang [docs](http://erlang.org/doc/man/dialyzer.html) at section "Warning options".
26+
27+
To disable Dialyzer completely, set `elixirLS.dialyzerEnabled` to false.
28+
29+
Check usage details in Dialyxir docs on [GitHub](https://github.com/jeremyjh/dialyxir#usage) and [hexdocs](https://hexdocs.pm/dialyxir/readme.html).
30+
31+
ElixirLS's Dialyzer integration uses internal, undocumented Dialyzer APIs, and so it won't be robust against changes to these APIs in future Erlang versions.
32+
33+
## Code completion
34+
35+
ElixirLS bundles an advanced code completion provider. The provider builds on [Elixir Sense](https://github.com/elixir-lsp/elixir_sense) library and utilizes two main mechanisms. The first one is reflection - getting information about compiled modules from Erlang and Elixir APIs. The second one is AST analysis of the current text buffer. While reflection gives precise results, it is not well suited for on demand completion of symbols from the currently edited file. The compiled version is likely to be outdated or the file may not compile at all. AST analysis helps in that case but it has its limitations. Unfortunately it is infeasible to be 100% accurate, especially with Elixir being a metaprogramming heavy language.
36+
37+
The completions include:
38+
39+
- keywords
40+
- special form snippets
41+
- functions
42+
- macros
43+
- modules
44+
- variables
45+
- struct fields (only if the struct type is explicitly stated or can be inferred from the variable binding)
46+
- atom map keys (if map keys can be inferred from variable binding)
47+
- attributes
48+
- types (in typespecs)
49+
- behaviour callbacks (inside the body of implementing module)
50+
- protocol functions (inside the body of implementing module)
51+
- keys in keyword functions arguments (if defined in spec)
52+
- function returns (if defined in spec)
53+
54+
## Workspace Symbols
55+
56+
With Dialyzer integration enabled ElixirLS will build an index of symbols (modules, functions, types and callbacks). The symbols are taken from the current workspace, all dependencies and stdlib (Elixir and erlang). This feature enables quick navigation to symbol definitions.
57+

docs/getting-started/emacs.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Emacs
2+
3+
## Setup
4+
5+
Download the latest release:
6+
`https://github.com/elixir-lsp/elixir-ls/releases/latest` and unzip it into a
7+
directory (this is the directory referred to as the
8+
`"path-to-elixir-ls/release"` below)
9+
10+
If using `lsp-mode` add this configuration:
11+
```elisp
12+
(use-package lsp-mode
13+
:commands lsp
14+
:ensure t
15+
:diminish lsp-mode
16+
:hook
17+
(elixir-mode . lsp)
18+
:init
19+
(add-to-list 'exec-path "path-to-elixir-ls/release"))
20+
```
21+
22+
For `eglot` users:
23+
```elisp
24+
(require 'eglot)
25+
;; This is optional. It automatically runs `M-x eglot` for you whenever you are in `elixir-mode`
26+
(add-hook 'elixir-mode-hook 'eglot-ensure)
27+
;; Make sure to edit the path appropriately, use the .bat script instead for Windows
28+
(add-to-list 'eglot-server-programs '(elixir-mode "path-to-elixir-ls/release/language_server.sh"))
29+
```
30+
31+
The official `lsp-mode` package includes a client for the Elixir
32+
Language Server.
33+
34+
Whenever opening a project for the first time, you will be prompted by
35+
`emacs-lsp` to select the correct project root. In that occasion, you
36+
also have the opportunity to _blacklist_ projects. Information about
37+
projects is stored in a file pointed by the `lsp-session-file`
38+
variable. Its default location is `~/.emacs.d/.lsp-session-v1`. You
39+
may need to prune or amend this file if you change your mind about
40+
blacklisting a project or if you erroneously select a project
41+
root. For more information about the `lsp-session-file` and
42+
`emacs-lsp` in general, please refer to the [official
43+
documentation](https://emacs-lsp.github.io/lsp-mode/).
44+
45+
Remember that ElixirLS requires **Erlang/OTP 22** and **Elixir 1.10.0** or
46+
higher to run, so ensure that Erlang and Elixir are available in your `PATH`.
47+
This can be achieved, for example, by using the
48+
[exec-path-from-shell](https://github.com/purcell/exec-path-from-shell)
49+
Emacs package.
50+
51+
## Restarting the language server
52+
53+
You may want to quickly restart the language server for a given
54+
workspace (e.g. after an update or in case of a server crash). To do
55+
so:
56+
57+
```
58+
M-x lsp-workspace-restart
59+
```
60+
61+
## Troubleshooting
62+
63+
To be sure that you don't have outdated or incompatible packages
64+
installed, you may also want to rename your `~/.emacs.d` directory
65+
while you are troubleshooting your ElixirLS Emacs setup.
66+
67+
Also, ensure that Erlang, Elixir (i.e. `erl`, `escript` and friends) and the
68+
`language_server.sh` script are all available in your `PATH`. If they are
69+
not, you can try the following:
70+
71+
```elisp
72+
;; Ensure your Emacs environment looks like your user's shell one
73+
(package-require 'exec-path-from-shell)
74+
(exec-path-from-shell-initialize)
75+
```
76+
77+
Finally, to enable logging on the client-side, just:
78+
79+
```elisp
80+
(setq lsp-log-io t)
81+
```
82+
83+
You can then follow the client logs for the current workspace by doing:
84+
85+
```
86+
M-x lsp-workspace-show-log
87+
```
88+
89+
## Tips and Tricks
90+
91+
### Shortcuts for code lenses and quick actions
92+
93+
You can run `M-x lsp-avy-lens` to show _letters_ next to code
94+
lenses. You can then press those letters to trigger the respective
95+
action.
96+
97+
If your `sideline` is enabled (`(setq lsp-ui-sideline-enable t)`), you
98+
can also use `M-x lsp-execute-code-action` to trigger quick-fix
99+
actions.

docs/getting-started/kakoune.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Kakoune
2+
3+
## Setup
4+
5+
Install the [kak-lsp](https://github.com/kak-lsp/kak-lsp) client for the [Kakoune](http://kakoune.org) editor.
6+
7+
## Limitations
8+
9+
### Encoding
10+
11+
kak-lsp works only with UTF-8 documents.
12+
13+
### `Position.character` interpretation
14+
15+
Currently, kak-lsp doesn't conform to the spec regarding the interpretation of `Position.character`.
16+
LSP spec says that
17+
18+
____
19+
A position inside a document (see Position definition below) is expressed as a zero-based line and
20+
character offset. The offsets are based on a UTF-16 string representation. So for a string of the
21+
form `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀` is
22+
1 and the character offset of `b` is 3 since `𐐀` is represented using two code units in UTF-16.
23+
____
24+
25+
However, kak-lsp treats `Position.character` as an offset in UTF-8 code points by default.
26+
Fortunately, it appears to produce the same result within the Basic Multilingual Plane (BMP) which
27+
includes a lot of characters.
28+
29+
Unfortunately, many language servers violate the spec as well, and in an inconsistent manner. Please
30+
refer https://github.com/Microsoft/language-server-protocol/issues/376 for more information. There
31+
are two main types of violations we met in the wild:
32+
33+
1) Using UTF-8 code points, just like kak-lsp does. Those should work well with kak-lsp for
34+
characters outside BMP out of the box.
35+
36+
2) Using UTF-8 code units (bytes), just like Kakoune does. Those are supported by kak-lsp but
37+
require adding `offset_encoding = "utf-8"` to the language server configuration in `kak-lsp.toml`.
38+

docs/getting-started/kate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Kate
2+
3+
## Setup
4+
5+
Use the built-in [LSP client for Kate.](https://kate-editor.org/post/2020/2020-01-01-kate-lsp-client-status/)

docs/getting-started/neovim.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Setup
2+
3+
There are several plugins available for NeoVim:
4+
5+
| Plugin | Notes |
6+
|:--|:--|
7+
| [coc.nvim](https://github.com/neoclide/coc.nvim) | Does not support debugger |
8+
| [nvim-dap](https://github.com/mfussenegger/nvim-dap) | Only debugger |
9+
| [ALE](https://github.com/w0rp/ale) | Does not support debugger or typespec suggestions |
10+
| [elixir-lsp/coc-elixir](https://github.com/elixir-lsp/coc-elixir) | Does not support debugger |
11+
| [vim-lsp](https://github.com/prabirshrestha/vim-lsp) | Does not support debugger |

docs/getting-started/nova.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Nova
2+
3+
## Setup
4+
5+
Install the [extension for Nova](https://github.com/raulchedrese/nova-elixir-ls).

docs/getting-started/overview.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Getting Started
2+
3+
The Erlang LS language server works with all text editors and IDEs
4+
which adhere to the _LSP_ protocol. The list of supported editors
5+
include _Emacs_, _Vim_, _VS Code_, _Sublime Text 3_ and more.
6+
7+
These pages contain all the information needed to configure your
8+
favourite text editor or IDE to use ErlangLS. You will also find
9+
instructions on how to configure the server to recognize the structure
10+
of your projects and to troubleshoot your installation when things do
11+
not work as expected.
12+
13+
* [Emacs](emacs.md)
14+
* [Kakoune](kakoune.md)
15+
* [Kate](kate.md)
16+
* [Neovim](neovim.md)
17+
* [Nova](nova.md)
18+
* [Sublime Text 3](sublime.md)
19+
* [VS Code](vscode.md)
20+

docs/getting-started/sublime.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Sublime
2+
3+
## Setup
4+
5+
Install the extension [LSP-Elixir](https://github.com/sublimelsp/LSP-elixir).
6+
7+
Note that it does not have debugger support.

docs/getting-started/vscode.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Emacs
2+
3+
## Setup
4+
5+
Install the official [ElixirLS extension](https://github.com/elixir-lsp/vscode-elixir-ls) and enable it.
6+
7+
## Debugger
8+
9+
ElixirLS includes debugger support adhering to the [VS Code debugger protocol](https://code.visualstudio.com/docs/extensionAPI/api-debugging) which is closely related to the Language Server Protocol. At the moment, only line breakpoints are supported.
10+
11+
When debugging in Elixir or Erlang, only modules that have been "interpreted" (using `:int.ni/1` or `:int.i/1`) will accept breakpoints or show up in stack traces. The debugger in ElixirLS automatically interprets all modules in the Mix project and dependencies prior to launching the Mix task, so you can set breakpoints anywhere in your project or dependency modules.
12+
13+
In order to debug modules in `.exs` files (such as tests), they must be specified under `requireFiles` in your launch configuration so they can be loaded and interpreted prior to running the task. For example, the default launch configuration for "mix test" in the VS Code plugin looks like this:
14+
15+
```json
16+
{
17+
"type": "mix_task",
18+
"name": "mix test",
19+
"request": "launch",
20+
"task": "test",
21+
"taskArgs": ["--trace"],
22+
"projectDir": "${workspaceRoot}",
23+
"requireFiles": [
24+
"test/**/test_helper.exs",
25+
"test/**/*_test.exs"
26+
]
27+
}
28+
```
29+
30+
In order to debug a single test or a single test file it is currently necessary to modify `taskArgs` and make sure no other tests are required in `requireFiles`.
31+
32+
```json
33+
{
34+
"type": "mix_task",
35+
"name": "mix test",
36+
"request": "launch",
37+
"task": "test",
38+
"taskArgs": ["tests/some_test.exs:123"],
39+
"projectDir": "${workspaceRoot}",
40+
"requireFiles": [
41+
"test/**/test_helper.exs",
42+
"test/some_test.exs"
43+
]
44+
}
45+
```
46+
47+
Please note that due to `:int` limitation NIF modules cannot be interpreted and need to be excluded via `excludeModules` option. This option can be also used to disable interpreting for some modules when it is not desirable e.g. when performance is not satisfactory.
48+
49+
```json
50+
{
51+
"type": "mix_task",
52+
"name": "mix test",
53+
"request": "launch",
54+
"task": "test",
55+
"taskArgs": ["--trace"],
56+
"projectDir": "${workspaceRoot}",
57+
"requireFiles": [
58+
"test/**/test_helper.exs",
59+
"test/**/*_test.exs"
60+
],
61+
"excludeModules": [
62+
":some_nif",
63+
"Some.SlowModule"
64+
]
65+
}
66+
```

docs/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Welcome to ElixirLS
2+
3+
Implementing features such as _auto-complete_ or _go-to-definition_
4+
for a programming language is not trivial. Traditionally, this work
5+
had to be repeated for each development tool and it required a mix of
6+
expertise in both the targeted programming language and the
7+
programming language internally used by the development tool of
8+
choice.
9+
10+
The [Elixir Language Server][git] (ElixirLS) provides a server that runs in the background, providing IDEs, editors, and other tools with information about Elixir Mix projects. It adheres to the _LSP_, a standard for frontend-independent IDE support. Debugger integration is accomplished through the similar VS Code Debug Protocol.
11+
12+
These pages contain all the information needed to configure your
13+
favourite text editor or IDE and to work with the ElixirLS. You will also
14+
find instructions on how to configure the server to recognize the
15+
structure of your projects and to troubleshoot your installation when
16+
things do not work as expected.
17+
18+
[git]:https://github.com/elixir-lsp/elixir-ls
19+
[lsp]:https://microsoft.github.io/language-server-protocol/
20+
[elixir]:https://www.elixir-lang.org
21+
[issue]:https://github.com/elixir-lsp/elixir-ls/issues

0 commit comments

Comments
 (0)