Skip to content

Commit 2e920e7

Browse files
Reorganize clients directory and migrate doc processing to MkDocs hooks
1 parent aba3398 commit 2e920e7

File tree

14 files changed

+118
-834
lines changed

14 files changed

+118
-834
lines changed

.just/docs.just

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,15 @@ fmt:
1313

1414
# Build documentation
1515
[no-cd]
16-
build LOCATION="site": process
16+
build LOCATION="site":
1717
uv run --group docs --frozen mkdocs build --config-file {{ mkdoc_config }} --site-dir {{ LOCATION }}
1818

1919
# Serve documentation locally
2020
[no-cd]
21-
serve PORT="8000": process
21+
serve PORT="8000":
2222
#!/usr/bin/env sh
2323
HOST="localhost"
2424
if [ -f "/.dockerenv" ]; then
2525
HOST="0.0.0.0"
2626
fi
2727
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# yaml-language-server: $schema=https://squidfunk.github.io/mkdocs-material/schema.json
22
extra_css:
33
- stylesheets/extra.css
4+
hooks:
5+
- docs/hooks.py
46
markdown_extensions:
57
- attr_list
68
- admonition
@@ -18,8 +20,11 @@ markdown_extensions:
1820
- pymdownx.superfences
1921
- pymdownx.tasklist:
2022
custom_checkbox: true
23+
- pymdownx.tilde
2124
plugins:
2225
- search
26+
- include-markdown:
27+
rewrite_relative_urls: false
2328
repo_name: django-language-server
2429
repo_url: https://github.com/joshuadavidthomas/django-language-server
2530
site_author: joshuadavidthomas

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cog.outl(f"![Django Version](https://img.shields.io/badge/django-{'%20%7C%20'.jo
2222
A language server for the Django web framework.
2323

2424
> [!CAUTION]
25-
> This project is in early stages. ~All~ Most features are incomplete and missing.
25+
> This project is in early stages. ~~All~~ Most features are incomplete and missing.
2626
2727
## Features
2828

@@ -105,7 +105,7 @@ The package provides pre-built wheels with the Rust-based LSP server compiled fo
105105

106106
The Django Language Server works with any editor that supports the Language Server Protocol (LSP). We currently have setup instructions for:
107107

108-
- [Neovim](docs/editors/neovim.md)
108+
- [Neovim](clients/nvim/README.md)
109109

110110
Got it working in your editor? [Help us add setup instructions!](#testing-and-documenting-editor-setup)
111111

@@ -141,15 +141,15 @@ The server has only been tested with Neovim. Documentation for setting up the la
141141

142142
If you run into issues setting up the language server:
143143

144-
1. Check the existing documentation in `docs/editors/`
144+
1. Check the existing documentation in `docs/clients/`
145145
2. [Open an issue](../../issues/new) describing your setup and the problems you're encountering
146146
- Include your editor and any relevant configuration
147147
- Share any error messages or unexpected behavior
148148
- The more details, the better!
149149

150150
If you get it working in your editor:
151151

152-
1. Create a new Markdown file in the `docs/editors/` directory (e.g., `docs/editors/vscode.md`)
152+
1. Create a new Markdown file in the `docs/clients/` directory (e.g., `docs/clients/vscode.md`)
153153
2. Include step-by-step setup instructions, any required configuration snippets, and tips for troubleshooting
154154

155155
Your feedback and contributions will help make the setup process smoother for everyone! 🙌

editors/nvim/README.md renamed to clients/nvim/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The plugin takes advantage of lazy.nvim's spec loading by providing a `lazy.lua`
2626
"neovim/nvim-lspconfig",
2727
},
2828
config = function(plugin, opts)
29-
vim.opt.rtp:append(plugin.dir .. "/editors/nvim")
29+
vim.opt.rtp:append(plugin.dir .. "/clients/nvim")
3030
require("djls").setup(opts)
3131
end,
3232
}
File renamed without changes.

docs/clients/neovim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Neovim
3+
---
4+
5+
{% include-markdown "../../clients/nvim/README.md" %}

docs/editors/neovim.md

Lines changed: 0 additions & 63 deletions
This file was deleted.

docs/hooks.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
from __future__ import annotations
2+
3+
import re
4+
5+
6+
def on_page_markdown(markdown, page, config, files):
7+
markdown = _convert_admonitions(markdown)
8+
markdown = _convert_image_paths(markdown)
9+
markdown = _convert_repo_links(markdown, config.repo_url)
10+
return markdown
11+
12+
13+
def _convert_admonitions(content):
14+
ADMONITION_MAP = {
15+
"NOTE": "note",
16+
"TIP": "tip",
17+
"IMPORTANT": "important",
18+
"WARNING": "warning",
19+
"CAUTION": "warning",
20+
"ALERT": "danger",
21+
"DANGER": "danger",
22+
"INFO": "info",
23+
"TODO": "todo",
24+
"HINT": "tip",
25+
}
26+
27+
def process_match(match):
28+
admonition_type = ADMONITION_MAP.get(match.group(1).upper(), "note")
29+
content_lines = match.group(2).rstrip().split("\n")
30+
cleaned_lines = [line.lstrip("> ") for line in content_lines]
31+
indented_content = "\n".join(
32+
f" {line}" if line.strip() else "" for line in cleaned_lines
33+
)
34+
trailing_newlines = len(match.group(2)) - len(match.group(2).rstrip("\n"))
35+
return f"!!! {admonition_type}\n\n{indented_content}" + "\n" * trailing_newlines
36+
37+
pattern = r"(?m)^>\s*\[!(.*?)\]\s*\n((?:>.*(?:\n|$))+)"
38+
return re.sub(pattern, process_match, content)
39+
40+
41+
def _convert_repo_links(content, repo_url):
42+
def replace_link(match):
43+
text, path = match.group(1), match.group(2)
44+
45+
if path.startswith(("#", "http://", "https://", "./assets/", "assets/")):
46+
return match.group(0)
47+
48+
if "clients/nvim/README.md" in path:
49+
return f"[{text}](clients/neovim.md)"
50+
51+
clean_path = path.replace("../", "").replace("./", "").lstrip("/")
52+
return f"[{text}]({repo_url.rstrip('/')}/blob/main/{clean_path})"
53+
54+
pattern = r"(?<!!)\[((?:[^][]|\[[^]]*\])*)\]\(([^)]+)\)"
55+
return re.sub(pattern, replace_link, content)
56+
57+
58+
def _convert_image_paths(content):
59+
return re.sub(r"!\[([^\]]*)\]\(\.\/docs\/assets\/", r"![\1](./assets/", content)

0 commit comments

Comments
 (0)