Skip to content

Commit cd667e1

Browse files
add basic documentation
1 parent 757a400 commit cd667e1

File tree

12 files changed

+1436
-72
lines changed

12 files changed

+1436
-72
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,6 @@ Cargo.lock
189189
*.pdb
190190

191191
# End of https://www.toptal.com/developers/gitignore/api/rust,python
192+
193+
# mkdocs
194+
site/

.just/docs.just

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
set unstable := true
2+
3+
justfile := justfile_directory() + "/.just/docs.just"
4+
mkdoc_config := justfile_directory() + "/.mkdocs.yml"
5+
6+
[private]
7+
default:
8+
@just --list --justfile {{ justfile }}
9+
10+
[private]
11+
fmt:
12+
@just --fmt --justfile {{ justfile }}
13+
14+
# Build documentation
15+
[no-cd]
16+
build LOCATION="site": process
17+
uv run --group docs --frozen mkdocs build --config-file {{ mkdoc_config }} --site-dir {{ LOCATION }}
18+
19+
# Serve documentation locally
20+
[no-cd]
21+
serve PORT="8000": process
22+
#!/usr/bin/env sh
23+
HOST="localhost"
24+
if [ -f "/.dockerenv" ]; then
25+
HOST="0.0.0.0"
26+
fi
27+
uv run --group docs --frozen mkdocs serve --config-file {{ mkdoc_config }} --dev-addr localhost:{{ PORT }}
28+
29+
[no-cd]
30+
[private]
31+
process:
32+
uv run docs/processor.py

.mkdocs.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# yaml-language-server: $schema=https://squidfunk.github.io/mkdocs-material/schema.json
2+
extra_css:
3+
- stylesheets/extra.css
4+
markdown_extensions:
5+
- attr_list
6+
- admonition
7+
- pymdownx.emoji:
8+
emoji_index: !!python/name:material.extensions.emoji.twemoji
9+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
10+
- pymdownx.details
11+
- pymdownx.highlight:
12+
anchor_linenums: true
13+
- pymdownx.inlinehilite
14+
- pymdownx.magiclink:
15+
hide_protocol: true
16+
repo_url_shortener: true
17+
- pymdownx.snippets
18+
- pymdownx.superfences
19+
- pymdownx.tasklist:
20+
custom_checkbox: true
21+
plugins:
22+
- search
23+
repo_url: https://github.com/joshuadavidthomas/django-language-server
24+
site_author: joshuadavidthomas
25+
site_name: Django Language Server
26+
site_url: http://joshuadavidthomas.github.io/django-language-server
27+
theme:
28+
features:
29+
- navigation.instant
30+
- navigation.instant.progress
31+
- navigation.sections
32+
- navigation.tracking
33+
- search.highlight
34+
- search.suggest
35+
font:
36+
code: Fira Code
37+
text: Inter
38+
icon:
39+
repo: fontawesome/brands/github
40+
name: material
41+
palette:
42+
- media: "(prefers-color-scheme)"
43+
toggle:
44+
icon: material/brightness-auto
45+
name: Switch to light mode
46+
- media: "(prefers-color-scheme: light)"
47+
scheme: default
48+
toggle:
49+
icon: material/brightness-7
50+
name: Switch to dark mode
51+
- media: "(prefers-color-scheme: dark)"
52+
scheme: slate
53+
toggle:
54+
icon: material/brightness-4
55+
name: Switch to system preference

.readthedocs.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
version: 2
5+
6+
build:
7+
os: ubuntu-22.04
8+
tools:
9+
python: "3.13"
10+
commands:
11+
- asdf plugin add just && asdf install just latest && asdf global just latest
12+
- asdf plugin add uv && asdf install uv latest && asdf global uv latest
13+
- just docs build $READTHEDOCS_OUTPUT/html
14+
15+
mkdocs:
16+
configuration: .mkdocs.yml

Justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set dotenv-load := true
22
set unstable := true
33

4+
mod docs ".just/docs.just"
45
mod proto ".just/proto.just"
56

67
# List all available commands

README.md

Lines changed: 18 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ A language server for the Django web framework.
1313

1414
However, the foundation has been laid:
1515

16-
✅ Working server architecture
17-
18-
- ✅ Server implementing the Language Server Protocol written in Rust
19-
- ✅ Python agent running as a persistent process within the Django project's virtualenv
20-
- ✅ Server-agent communication via Protocol Buffers
21-
22-
✅ Custom template parser to support LSP features
23-
24-
- ✅ Basic HTML parsing, including style and script tags
25-
- ✅ Django variables and filters
26-
- ❌ Django block template tags
27-
- Early work on extensible template tag parsing specification (TagSpecs)
28-
29-
❌ Actual LSP features (coming soon!... hopefully)
16+
- [x] Working server architecture
17+
- [x] Server implementing the Language Server Protocol written in Rust
18+
- [x] Python agent running as a persistent process within the Django project's virtualenv
19+
- [x] Server-agent communication via Protocol Buffers
20+
- [x] Custom template parser to support LSP features
21+
- [x] Basic HTML parsing, including style and script tags
22+
- [x] Django variables and filters
23+
- [ ] Django block template tags
24+
- Early work has been done on an extensible template tag parsing specification (TagSpecs)
25+
- [ ] Actual LSP features (coming soon!... hopefully)
3026

3127
## Requirements
3228

@@ -99,64 +95,11 @@ pip install djls-agent
9995

10096
## Editor Setup
10197

102-
The Django Language Server should work with any editor that supports the Language Server Protocol (LSP). Got it working in your editor? [Help us add setup instructions!](#testing-and-documenting-editor-setup)
103-
104-
- [Neovim](#neovim)
105-
106-
### Neovim
107-
108-
Using [lazy.nvim](https://github.com/folke/lazy.nvim) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig):
109-
110-
```lua
111-
{
112-
"neovim/nvim-lspconfig",
113-
opts = {
114-
servers = {
115-
djls = {},
116-
},
117-
setup = {
118-
djls = function(_, opts)
119-
local configs = require("lspconfig.configs")
120-
local util = require("lspconfig.util")
121-
122-
if not configs.djls then
123-
configs.djls = {
124-
default_config = {
125-
cmd = { "djls", "serve" },
126-
filetypes = { "htmldjango" },
127-
root_dir = function(fname)
128-
local root = util.root_pattern("manage.py", "pyproject.toml")(fname)
129-
vim.notify("LSP root dir: " .. (root or "nil"))
130-
return root or vim.fn.getcwd()
131-
end,
132-
handlers = {
133-
["window/logMessage"] = function(_, params, _)
134-
local message_type = {
135-
[1] = vim.log.levels.ERROR,
136-
[2] = vim.log.levels.WARN,
137-
[3] = vim.log.levels.INFO,
138-
[4] = vim.log.levels.DEBUG,
139-
}
140-
vim.notify(params.message, message_type[params.type], {
141-
title = "djls",
142-
})
143-
end,
144-
},
145-
on_attach = function(client, bufnr)
146-
vim.notify("djls attached to buffer: " .. bufnr)
147-
end,
148-
},
149-
}
150-
end
151-
require("lspconfig").djls.setup({})
152-
end,
153-
},
154-
},
155-
},
156-
```
98+
The Django Language Server works with any editor that supports the Language Server Protocol (LSP). We currently have setup instructions for:
15799

158-
> [!NOTE]
159-
> This configuration is copied straight from my Neovim setup and includes a logging setup that sends LSP messages to Neovim's notification system. You can remove all the references to `vim.notify` if you don't care about this functionality.
100+
- [Neovim](/docs/editor-setup/neovim.md)
101+
102+
Got it working in your editor? [Help us add setup instructions!](#testing-and-documenting-editor-setup)
160103

161104
## Versioning
162105

@@ -190,7 +133,10 @@ The project needs help in several areas:
190133

191134
The server has only been tested with Neovim. Documentation for setting up the language server in other editors is sorely needed, particularly VS Code. However, any editor that has [LSP client](https://langserver.org/#:~:text=for%20more%20information.-,LSP%20clients,opensesame%2Dextension%2Dlanguage_server,-Community%20Discussion%20Forums) support would be welcome.
192135

193-
If you get it working in your editor, please open a PR with the setup instructions.
136+
If you get it working in your editor:
137+
138+
1. Create a new Markdown file in the `docs/editors/` directory (e.g., `docs/editors/vscode.md`)
139+
2. Include step-by-step setup instructions, any required configuration snippets, and tips for troubleshooting
194140

195141
### Feature Requests
196142

docs/editor-setup/neovim.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Neovim
2+
3+
Using <https://github.com/folke/lazy.nvim> and <https://github.com/neovim/nvim-lspconfig>:
4+
5+
```lua
6+
{
7+
"neovim/nvim-lspconfig",
8+
opts = {
9+
servers = {
10+
djls = {},
11+
},
12+
setup = {
13+
djls = function(_, opts)
14+
local configs = require("lspconfig.configs")
15+
local util = require("lspconfig.util")
16+
17+
if not configs.djls then
18+
configs.djls = {
19+
default_config = {
20+
cmd = { "djls", "serve" },
21+
filetypes = { "htmldjango" },
22+
root_dir = function(fname)
23+
local root = util.root_pattern("manage.py", "pyproject.toml")(fname)
24+
vim.notify("LSP root dir: " .. (root or "nil"))
25+
return root or vim.fn.getcwd()
26+
end,
27+
handlers = {
28+
["window/logMessage"] = function(_, params, _)
29+
local message_type = {
30+
[1] = vim.log.levels.ERROR,
31+
[2] = vim.log.levels.WARN,
32+
[3] = vim.log.levels.INFO,
33+
[4] = vim.log.levels.DEBUG,
34+
}
35+
vim.notify(params.message, message_type[params.type], {
36+
title = "djls",
37+
})
38+
end,
39+
},
40+
on_attach = function(client, bufnr)
41+
vim.notify("djls attached to buffer: " .. bufnr)
42+
end,
43+
},
44+
}
45+
end
46+
require("lspconfig").djls.setup({})
47+
end,
48+
},
49+
},
50+
}
51+
```
52+
53+
!!! note
54+
55+
This configuration is copied straight from my Neovim setup and includes a logging setup that sends LSP messages to Neovim's notification system. You can remove all the references to `vim.notify` if you don't care about this functionality.

0 commit comments

Comments
 (0)