Add docs for Ruff language server (#12344)

## Summary

This PR adds documentation for the Ruff language server.

It mainly does the following:
1. Combines various READMEs containing instructions for different editor
setup in their respective section on the online docs
2. Provide an enumerated list of server settings. Additionally, it also
provides a section for VS Code specific options.
3. Adds a "Features" section which enumerates all the current
capabilities of the native server

For (2), the settings documentation is done manually but a future
improvement (easier after `ruff-lsp` is deprecated) is to move the docs
in to Rust struct and generate the documentation from the code itself.
And, the VS Code extension specific options can be generated by diffing
against the `package.json` in `ruff-vscode` repository.

### Structure

1. Setup: This section contains the configuration for setting up the
language server for different editors
2. Features: This section contains a list of capabilities provided by
the server along with short GIF to showcase it
3. Settings: This section contains an enumerated list of settings in a
similar format to the one for the linter / formatter
4. Migrating from `ruff-lsp`

> [!NOTE]
>
> The settings page is manually written but could possibly be
auto-generated via a macro similar to `OptionsMetadata` on the
`ClientSettings` struct

resolves: #11217 

## Test Plan

Generate and open the documentation locally using:
1. `python scripts/generate_mkdocs.py`
2. `mkdocs serve -f mkdocs.insiders.yml`
This commit is contained in:
Dhruv Manilawala 2024-07-18 17:41:43 +05:30 committed by GitHub
parent 2e77b775b0
commit 648cca199b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1254 additions and 731 deletions

View file

@ -8,7 +8,7 @@ import re
import shutil
import subprocess
from pathlib import Path
from typing import NamedTuple
from typing import NamedTuple, Sequence
import mdformat
import yaml
@ -22,6 +22,8 @@ class Section(NamedTuple):
title: str
filename: str
generated: bool
# If subsections is present, the `filename` and `generated` value is unused.
subsections: Sequence[Section] | None = None
SECTIONS: list[Section] = [
@ -30,6 +32,18 @@ SECTIONS: list[Section] = [
Section("Installing Ruff", "installation.md", generated=False),
Section("The Ruff Linter", "linter.md", generated=False),
Section("The Ruff Formatter", "formatter.md", generated=False),
Section(
"Editors",
"",
generated=False,
subsections=[
Section("Editor Integration", "editors/index.md", generated=False),
Section("Setup", "editors/setup.md", generated=False),
Section("Features", "editors/features.md", generated=False),
Section("Settings", "editors/settings.md", generated=False),
Section("Migrating from ruff-lsp", "editors/migration.md", generated=False),
],
),
Section("Configuring Ruff", "configuration.md", generated=False),
Section("Preview", "preview.md", generated=False),
Section("Rules", "rules.md", generated=True),
@ -108,7 +122,7 @@ def main() -> None:
Path("docs").mkdir(parents=True, exist_ok=True)
# Split the README.md into sections.
for title, filename, generated in SECTIONS:
for title, filename, generated, _ in SECTIONS:
if not generated:
continue
@ -180,7 +194,19 @@ def main() -> None:
)
# Add the nav section to mkdocs.yml.
config["nav"] = [{section.title: section.filename} for section in SECTIONS]
config["nav"] = []
for section in SECTIONS:
if section.subsections is None:
config["nav"].append({section.title: section.filename})
else:
config["nav"].append(
{
section.title: [
{subsection.title: subsection.filename}
for subsection in section.subsections
]
}
)
with Path("mkdocs.generated.yml").open("w+", encoding="utf8") as fp:
yaml.safe_dump(config, fp)