Skip to content

Commit 28fc690

Browse files
committed
Update docs
1 parent fc94180 commit 28fc690

4 files changed

Lines changed: 52 additions & 10 deletions

File tree

docs/concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ flowchart LR
5353

5454
**Sequential mode** (default): handlers run one after another. Each handler can read the accumulated result so far via `context.current_result`. Useful when handlers depend on each other's output (e.g. formatter → save-to-disk).
5555

56-
**Concurrent mode** (`run_handlers_concurrently: true`): all handlers run in parallel and results are merged afterward. Accessing `context.current_result` in concurrent mode raises `RuntimeError`. Useful for independent linters.
56+
**Concurrent mode** (`HANDLER_EXECUTION = HandlerExecution.CONCURRENT`): all handlers run in parallel and results are merged afterward. Accessing `context.current_result` in concurrent mode raises `RuntimeError`. Useful for independent linters.
5757

5858
## Service
5959

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can declare or extend actions directly in your project:
3333
source = "finecode_extension_api.actions.lint.LintAction"
3434
handlers = [
3535
{ name = "ruff", source = "fine_python_ruff.RuffLintFilesHandler", env = "dev_no_runtime", dependencies = ["fine_python_ruff~=0.2.0"] },
36-
{ name = "mypy", source = "fine_python_mypy.MypyLintHandler", env = "dev_no_runtime", dependencies = ["fine_python_mypy~=0.3.0"] },
36+
{ name = "mypy", source = "fine_python_mypy.MypyLintFilesHandler", env = "dev_no_runtime", dependencies = ["fine_python_mypy~=0.3.0"] },
3737
]
3838
```
3939

@@ -46,7 +46,7 @@ To completely replace the handlers from presets for an action:
4646
source = "finecode_extension_api.actions.lint.LintAction"
4747
handlers_mode = "replace"
4848
handlers = [
49-
{ name = "mypy", source = "fine_python_mypy.MypyLintHandler", env = "dev_no_runtime", dependencies = ["fine_python_mypy~=0.3.0"] },
49+
{ name = "mypy", source = "fine_python_mypy.MypyLintFilesHandler", env = "dev_no_runtime", dependencies = ["fine_python_mypy~=0.3.0"] },
5050
]
5151
```
5252

docs/glossary.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ A named operation (for example `lint`, `format`, `build_artifact`).
88

99
A concrete implementation of an action. Multiple handlers can be registered for a single action, and they run sequentially or concurrently.
1010

11+
## Collection Action
12+
13+
An action whose payload carries multiple items and whose result describes that batch, often with per-item entries. Used when handlers need to iterate over, correlate, or optimize across the full set of items.
14+
1115
## Execution Environment
1216

1317
A named, isolated context in which handlers and project code execute (e.g. `runtime`, `dev_workspace`, `dev_no_runtime`). Each execution environment has its own dependency set, serving a specific purpose — for example, the project's runtime, dev tooling, or test execution. The concept is inter-language; in Python each execution environment is materialized as a virtual environment. Configuration uses the shorthand `env`.
@@ -16,6 +20,10 @@ A named, isolated context in which handlers and project code execute (e.g. `runt
1620

1721
A process that runs inside a specific execution environment and executes action handler code. The Workspace Manager spawns one ER per (project, execution environment) pair, on demand. ERs communicate with the WM over JSON-RPC. The concept is inter-language — `finecode_extension_runner` is the Python implementation.
1822

23+
## Item Action
24+
25+
An action whose payload carries one item and whose result describes that one item. Used when handlers naturally operate on a single unit of work.
26+
1927
## Preset
2028

2129
A reusable, distributable bundle of action and handler declarations. Users reference a preset in their project configuration; its declarations merge with the project's own configuration, giving full control to override or disable individual handlers. The concept is inter-language — in Python, presets are distributed as packages installed into the `dev_workspace` execution environment.

docs/reference/actions.md

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Format a source artifact or specific files.
6262
| `file_paths` | `list[Path]` | `[]` | Files to format (required when `target="files"`) |
6363

6464
!!! note
65-
The `save` payload field controls whether changes are written to disk. The built-in `SaveFormatFilesHandler` reads this flag. If you omit the save handler from your preset, files won't be written regardless.
65+
The `save` payload field controls whether changes are written to disk. The built-in `SaveFormatFileHandler` reads this flag. If you omit the save handler from your preset, files won't be written regardless.
6666

6767
---
6868

@@ -73,20 +73,54 @@ Format a specific set of files. Internal action dispatched by `format`.
7373
- **Source:** `finecode_extension_api.actions.FormatFilesAction`
7474
- **Default handler execution:** sequential
7575

76-
The built-in `FormatFilesDispatchHandler` groups the given files by language and dispatches each language's batch to the matching language subaction — any action declaring `PARENT_ACTION = FormatFilesAction` and the corresponding `LANGUAGE`.
76+
The built-in `FormatFilesIterateHandler` iterates over all files and delegates each to `format_file`. Language routing is handled by `format_file` via its dispatch handler — `format_files` has no language awareness.
7777

7878
---
7979

80-
## `format_python_files`
80+
## `format_file`
8181

82-
Format Python source files. Language-specific subaction of `format_files`.
82+
Format a single file. Item-level action; handlers run sequentially as a pipeline.
8383

84-
- **Source:** `finecode_extension_api.actions.FormatPythonFilesAction`
84+
- **Source:** `finecode_extension_api.actions.FormatFileAction`
8585
- **Default handler execution:** sequential
8686

87-
**Payload fields:** same as `format_files`.
87+
**Payload fields:**
88+
89+
| Field | Type | Description |
90+
|---|---|---|
91+
| `file_path` | `ResourceUri` | The single file to format |
92+
| `save` | `bool` | Whether to write the result back to disk |
93+
94+
**Run context kwargs** (`FormatFileCallerRunContextKwargs`):
95+
96+
| Field | Type | Default | Description |
97+
|---|---|---|---|
98+
| `file_editor_session` | `IFileEditorSession \| None` | `None` | Shared session from a parent action. If absent, the context opens its own. |
99+
| `file_info` | `FileInfo \| None` | `None` | Pre-read file content. If absent, the context reads the file itself (with `block=True`). |
100+
101+
When called standalone (e.g. IDE on-save), no kwargs are needed — the context creates its own session and reads the file. When called from `format_files`, the iterate handler passes the parent session. When called from the dispatch handler into a language subaction, both session and file info are passed to avoid redundant reads.
102+
103+
**Result fields:**
104+
105+
| Field | Type | Description |
106+
|---|---|---|
107+
| `changed` | `bool` | Whether the file content was modified |
108+
| `code` | `str` | The formatted content |
109+
110+
Handlers read and update `run_context.file_info` to pass formatted content to the next handler in the pipeline.
111+
112+
---
113+
114+
## `format_python_file`
115+
116+
Format a single Python file. Language-specific item-level subaction of `format_file`.
117+
118+
- **Source:** `finecode_extension_api.actions.FormatPythonFileAction`
119+
- **Default handler execution:** sequential
120+
121+
**Payload fields:** same as `format_file`.
88122

89-
Register Python formatting tools (ruff, black, …) as handlers for this action.
123+
Register Python formatting tools (ruff, isort, …) as handlers for this action. Handler order matters — they run sequentially as a pipeline.
90124

91125
---
92126

0 commit comments

Comments
 (0)