Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,36 @@ text = render_text(template)
JSON and TOML work the same way — `json_tstring.render_data()`,
`toml_tstring.render_text()`, etc.

## Editor integration (t-linter)

[t-linter](https://github.com/koxudaxi/t-linter) is a linter, formatter, and
LSP server for t-strings. It uses the same Rust backends as this project for
`check` and `format`.

```bash
pip install t-linter
```

Check templates for errors:

```bash
t-linter check src/
```

Format JSON / TOML / YAML template literals:

```bash
t-linter format src/
```

Start the LSP server for real-time editor diagnostics:

```bash
t-linter lsp
```

A [VSCode extension](https://marketplace.visualstudio.com/items?itemName=koxudaxi.t-linter) is also available.

## Rust backend API

The Rust crates also expose parser-first `check` and `format` entry points for
Expand Down Expand Up @@ -195,3 +225,4 @@ when a version tag is pushed.
- [PEP 750 – Template Strings](https://peps.python.org/pep-0750/)
- [`string.templatelib` — Template String Support](https://docs.python.org/3/library/string.templatelib.html)
- [What's New In Python 3.14](https://docs.python.org/3/whatsnew/3.14.html)
- [t-linter](https://github.com/koxudaxi/t-linter) — Linter, formatter, and LSP for t-strings
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ Pick the format you need:

- [Installation](getting-started/installation.md)
- [Quick Start](getting-started/quick-start.md)
- [Editor Integration (t-linter)](usage/editor-integration.md)
- [Architecture](architecture.md)
120 changes: 120 additions & 0 deletions docs/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Pick the format you need:

- [Installation](getting-started/installation.md)
- [Quick Start](getting-started/quick-start.md)
- [Editor Integration (t-linter)](usage/editor-integration.md)
- [Architecture](architecture.md)

---
Expand Down Expand Up @@ -604,6 +605,125 @@ Each profile's conformance claims are backed by per-profile manifests and test s

---

# Editor Integration (t-linter)

Source: https://tstring-structured-data.koxudaxi.dev/usage/editor-integration/

[t-linter](https://github.com/koxudaxi/t-linter) is a linter, formatter, and LSP server for Python template strings (PEP 750 t-strings). It uses the same Rust backends (`tstring-json`, `tstring-toml`, `tstring-yaml`) as this project for `check` and `format` operations.

## Installation

```bash
pip install t-linter
```

Or with uv:

```bash
uv add t-linter
```

## CLI usage

### Check templates for errors

Validate t-string templates in your Python files:

```bash
t-linter check file.py
t-linter check src/
```

Output format options:

```bash
t-linter check file.py --format human # default, human-readable
t-linter check file.py --format json # machine-readable JSON
t-linter check file.py --format github # GitHub Actions annotations
```

Use `--error-on-issues` to fail CI when problems are found:

```bash
t-linter check src/ --error-on-issues
```

### Format templates

Canonical formatting for JSON, YAML, and TOML template literals:

```bash
t-linter format file.py
t-linter format src/
```

Dry-run to see what would change without modifying files:

```bash
t-linter format --check file.py
```

Read from stdin:

```bash
cat file.py | t-linter format --stdin-filename file.py -
```

## LSP server

Start the built-in LSP server for real-time editor diagnostics and formatting:

```bash
t-linter lsp
```

The LSP provides:

- **Diagnostics** — syntax and semantic errors reported inline as you type
- **Formatting** — format-on-save or format-on-demand via your editor's formatting command

## VSCode integration

1. Install the binary:

```bash
pip install t-linter
```

2. Install the [t-linter extension](https://marketplace.visualstudio.com/items?itemName=koxudaxi.t-linter) from the VSCode marketplace.

3. Recommended: set `"python.languageServer": "None"` in VSCode settings to avoid conflicts with other Python language servers.

4. Optionally configure `t-linter.serverPath` in settings if the binary is not on your `PATH`.

## Other editors

Any editor that supports the Language Server Protocol can use `t-linter lsp`. Configure your editor to start `t-linter lsp` as the language server for Python files.

## Configuration

Configure t-linter via `pyproject.toml`:

```toml
[tool.t-linter]
extend-exclude = ["generated", "vendor"]
ignore-file = ".t-linterignore"
```

## How it works with tstring-structured-data

t-linter and tstring-structured-data share the same Rust parsing and formatting backends:

- **tstring-structured-data** is the **runtime library** — `render_data()` and `render_text()` parse and render templates at runtime
- **t-linter** is the **developer tooling** — `check` validates templates and `format` canonicalizes them at development time

For JSON, YAML, and TOML templates, t-linter uses:

- **Tree-sitter** for fast syntax highlighting (low-latency, no full parse)
- **Rust backends** (`tstring-json`, `tstring-yaml`, `tstring-toml`) for strict `check` and `format` operations

---

# Architecture

Source: https://tstring-structured-data.koxudaxi.dev/architecture/
Expand Down
1 change: 1 addition & 0 deletions docs/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- [YAML](https://tstring-structured-data.koxudaxi.dev/usage/yaml/): The `yaml-tstring` package provides `render_data`, `render_text`, and `render_result` for YAML templates.
- [Error Handling](https://tstring-structured-data.koxudaxi.dev/usage/error-handling/): T-string backends catch errors that f-strings silently ignore and block injection by construction.
- [Profiles](https://tstring-structured-data.koxudaxi.dev/usage/profiles/): Each backend accepts an optional `profile` keyword argument to select the target spec version.
- [Editor Integration (t-linter)](https://tstring-structured-data.koxudaxi.dev/usage/editor-integration/): [t-linter](https://github.com/koxudaxi/t-linter) is a linter, formatter, and LSP server for Python template strings (PEP 750 t-strings). It uses th...

- [Architecture](https://tstring-structured-data.koxudaxi.dev/architecture/)
## Reference
Expand Down
114 changes: 114 additions & 0 deletions docs/usage/editor-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Editor Integration (t-linter)

[t-linter](https://github.com/koxudaxi/t-linter) is a linter, formatter, and LSP server for Python template strings (PEP 750 t-strings). It uses the same Rust backends (`tstring-json`, `tstring-toml`, `tstring-yaml`) as this project for `check` and `format` operations.

## Installation

```bash
pip install t-linter
```

Or with uv:

```bash
uv add t-linter
```

## CLI usage

### Check templates for errors

Validate t-string templates in your Python files:

```bash
t-linter check file.py
t-linter check src/
```

Output format options:

```bash
t-linter check file.py --format human # default, human-readable
t-linter check file.py --format json # machine-readable JSON
t-linter check file.py --format github # GitHub Actions annotations
```

Use `--error-on-issues` to fail CI when problems are found:

```bash
t-linter check src/ --error-on-issues
```

### Format templates

Canonical formatting for JSON, YAML, and TOML template literals:

```bash
t-linter format file.py
t-linter format src/
```

Dry-run to see what would change without modifying files:

```bash
t-linter format --check file.py
```

Read from stdin:

```bash
cat file.py | t-linter format --stdin-filename file.py -
```

## LSP server

Start the built-in LSP server for real-time editor diagnostics and formatting:

```bash
t-linter lsp
```

The LSP provides:

- **Diagnostics** — syntax and semantic errors reported inline as you type
- **Formatting** — format-on-save or format-on-demand via your editor's formatting command

## VSCode integration

1. Install the binary:

```bash
pip install t-linter
```

2. Install the [t-linter extension](https://marketplace.visualstudio.com/items?itemName=koxudaxi.t-linter) from the VSCode marketplace.

3. Recommended: set `"python.languageServer": "None"` in VSCode settings to avoid conflicts with other Python language servers.

4. Optionally configure `t-linter.serverPath` in settings if the binary is not on your `PATH`.

## Other editors

Any editor that supports the Language Server Protocol can use `t-linter lsp`. Configure your editor to start `t-linter lsp` as the language server for Python files.

## Configuration

Configure t-linter via `pyproject.toml`:

```toml
[tool.t-linter]
extend-exclude = ["generated", "vendor"]
ignore-file = ".t-linterignore"
```

## How it works with tstring-structured-data

t-linter and tstring-structured-data share the same Rust parsing and formatting backends:

- **tstring-structured-data** is the **runtime library** — `render_data()` and `render_text()` parse and render templates at runtime
- **t-linter** is the **developer tooling** — `check` validates templates and `format` canonicalizes them at development time

For JSON, YAML, and TOML templates, t-linter uses:

- **Tree-sitter** for fast syntax highlighting (low-latency, no full parse)
- **Rust backends** (`tstring-json`, `tstring-yaml`, `tstring-toml`) for strict `check` and `format` operations
1 change: 1 addition & 0 deletions zensical.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nav = [
{ "YAML" = "usage/yaml.md" },
{ "Error Handling" = "usage/error-handling.md" },
{ "Profiles" = "usage/profiles.md" },
{ "Editor Integration (t-linter)" = "usage/editor-integration.md" },
]},
{ "Architecture" = "architecture.md" },
{ "Reference" = [
Expand Down
Loading