Skip to content

Commit 6f8e21e

Browse files
committed
Clarifier les guides de configuration
1 parent b39d675 commit 6f8e21e

3 files changed

Lines changed: 70 additions & 61 deletions

File tree

docs/ark_main_config.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
## **ark.yml** Workspace Configuration
1+
## **ark.yml** - Workspace Configuration
22

3-
This file defines the project settings used to build the normalized **BuildContext**. It lives at the workspace root and is created automatically when the workspace is first set in the GUI (if missing).
3+
This file defines the project settings used to build the normalized **BuildContext**. It lives at the workspace root and is created automatically when the workspace is first configured in the GUI, if missing.
44

5-
The configuration is loaded by `Core/Configs/` and serves as the primary source of truth for project metadata.
5+
The configuration is loaded by `Core/Configs/` and is the primary source of truth for project metadata.
66

77
## Minimal Example
88

@@ -37,8 +37,8 @@ plugins:
3737

3838
Behavior:
3939

40-
- When a build is triggered (CLI or GUI), this entrypoint is used to populate the `BuildContext`.
41-
- In the GUI, you can select any file to compile, but the `project.entry` remains the default configuration.
40+
- When a build is triggered from the CLI or GUI, this entrypoint is used to populate the `BuildContext`.
41+
- In the GUI, you can select any file to compile, but `project.entry` remains the default configuration.
4242
- If it is missing or invalid, compilation is blocked until a valid entrypoint is selected.
4343

4444
GUI shortcuts:
@@ -60,7 +60,7 @@ The fields in `ark.yml` are mapped directly to the `BuildContext` data structure
6060
| `build.data` | `data_mappings` |
6161
| `build.icon` | `icon` |
6262

63-
> **Note**: `workspace.exclude` is exclusive to the GUI workspace view filtering (file explorer). `build.exclude` is what determines which files are ignored during the actual compilation (engine) and BCASL phases.
63+
> **Note**: `workspace.exclude` is used only for the GUI workspace view filter. `build.exclude` determines which files are ignored during compilation and BCASL phases.
6464

6565
## Plugins Configuration
6666

@@ -71,7 +71,7 @@ plugins:
7171
bcasl_enabled: true # Global toggle for the BCASL pipeline
7272
```
7373

74-
If `bcasl_enabled` is set to `false`, the entire pipeline is skipped during compilation. This setting is also manageable via the **BCASL Pipeline** dialog in the GUI.
74+
If `bcasl_enabled` is set to `false`, the entire pipeline is skipped during compilation. You can also change this setting in the **BCASL Pipeline** dialog in the GUI.
7575

7676
## Advanced Config Editor (GUI)
7777

docs/how_to_create_a_bc_plugin.md

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
## **BC Plugin Guide**
1+
## **BCASL Plugin Guide**
22

3-
## **BCASL = Before Compilation Action System & Loader.**
3+
**BCASL = Before-Compilation Action System & Loader.**
44

55
**Overview**
6-
A BC plugin (BCASL) is a package placed in `Plugins/` and executed before compilation. It registers automatically, respects execution order (priority, tags, dependencies), and uses `PreCompileContext` to work with the workspace.
6+
A BC plugin is a package placed in `Plugins/` and executed before compilation. It registers automatically, respects execution order (priority, tags, dependencies), and uses `PreCompileContext` to work with the workspace.
77

8-
The BCASL engine and loader are **pure-Python** modules, meaning they can run in headless environments (CLI, CI) without any Qt dependencies. UI integration is provided separately by the ARK GUI.
8+
The BCASL loader and runtime are **pure-Python**. They run in headless environments (CLI, CI) without Qt dependencies. UI integration is provided separately by the ARK GUI.
99

1010
**Discovery And Loading**
1111

1212
- Plugins are discovered in `Plugins/<plugin_name>/`.
1313
- The folder must contain an `__init__.py`.
1414
- The loader imports each package and detects plugins via `@bc_register` or `bcasl_register(manager)`.
15-
- If `bcasl.yml` is missing, a default file is generated.
15+
- If `bcasl.yml` is missing, BCASL generates a best-effort default file when it runs.
1616

1717
**Package Layout**
1818

@@ -53,8 +53,8 @@ class ExampleClean(BcPluginBase):
5353
super().__init__(META)
5454

5555
def on_pre_compile(self, ctx: PreCompileContext) -> None:
56-
# ctx.root est un objet Path pointant vers la racine du workspace
57-
# iter_files() utilise par défaut les patterns d'inclusion/exclusion du projet
56+
# ctx.root is a Path to the workspace root.
57+
# iter_files() uses the configured include/exclude patterns by default.
5858
for pyc in ctx.iter_files(["**/*.pyc"]):
5959
try:
6060
pyc.unlink()
@@ -81,7 +81,7 @@ def bcasl_register(manager: BCASL) -> None:
8181
**PluginMeta And Compatibility**
8282
Important fields.
8383

84-
- `id`: unique and stable id (used in `bcasl.yml`).
84+
- `id`: unique, stable id used in `bcasl.yml`.
8585
- `name`, `version`, `description`, `author`.
8686
- `tags`: used for default ordering when no explicit order is provided.
8787
- `required_*_version`: compatibility requirements (BCASL, Core, SDK, Context).
@@ -99,8 +99,8 @@ Validation.
9999

100100
**Configuration (bcasl.yml)**
101101
For plugin authors, `bcasl.yml` is the canonical workspace config file.
102-
`PreCompileContext` helpers and validity checks rely on it directly, so it is
103-
the format you should target in examples and real plugin code.
102+
`PreCompileContext` helpers and validation logic read it directly, so target
103+
this format in examples and plugin code.
104104

105105
Example.
106106

@@ -131,40 +131,40 @@ Important notes.
131131
- Global BCASL activation is managed by **`ark.yml`** (`plugins.bcasl_enabled`).
132132
- Keys in `plugins` are the `PluginMeta.id` values.
133133
- `plugin_order` forces ordering and adjusts priority.
134-
- If `bcasl.yml` is missing, a default file is generated.
134+
- If `bcasl.yml` is missing, the workspace tools can generate a default file.
135135
- In plugin code, assume `bcasl.yml` lives at the workspace root.
136136

137137
**Execution Context (PreCompileContext)**
138138
Key properties and methods.
139139

140-
- `root`: Path object pointant vers la racine du workspace.
141-
- `name`: Nom du dossier workspace.
142-
- `config`: Dictionnaire complet de configuration (`bcasl.yml`).
143-
- `build_context`: Objet `BuildContext` contenant les paramètres de compilation (si disponible).
144-
- `file_patterns`: Patterns d'inclusion définis.
145-
- `exclude_patterns`: Patterns d'exclusion définis.
146-
- `iter_files(include, exclude)`: Itérateur optimisé (respecte les exclusions par défaut).
140+
- `root`: Path object pointing to the workspace root.
141+
- `name`: Workspace folder name.
142+
- `config`: Full `bcasl.yml` configuration dictionary.
143+
- `build_context`: `BuildContext` with compilation settings, when available.
144+
- `file_patterns`: Configured include patterns.
145+
- `exclude_patterns`: Configured exclude patterns.
146+
- `iter_files(include, exclude)`: Optimized iterator that respects exclusions by default.
147147

148-
Usage du BuildContext :
148+
BuildContext usage:
149149

150150
```python
151151
def on_pre_compile(self, ctx: PreCompileContext) -> None:
152152
if ctx.build_context:
153-
# Accès au dossier de sortie défini dans ark.yml ou le verrou
153+
# Access the output directory defined in ark.yml or the lock file.
154154
output_dir = ctx.build_context.output_dir
155155
...
156156
```
157157

158-
*Exemple concret : Le plugin **OutputCleaner** utilise `ctx.build_context.output_dir` pour vider le dossier de sortie avant la compilation.*
158+
*Example: the **OutputCleaner** plugin uses `ctx.build_context.output_dir` to clear the output directory before compilation.*
159159

160-
Usage simplifié :
160+
Simplified usage:
161161

162162
```python
163-
# Parcourt tous les fichiers du projet selon la config bcasl.yml
163+
# Iterate over all project files using the bcasl.yml configuration.
164164
for path in ctx.iter_files():
165165
...
166166
167-
# Recherche spécifique tout en respectant les exclusions globales
167+
# Search specific files while still respecting global exclusions.
168168
for path in ctx.iter_files(["**/*.json"]):
169169
...
170170
```
@@ -180,8 +180,8 @@ ok = set_selected_workspace("/path/to/new/workspace")
180180

181181
Behavior.
182182

183-
- The request is accepted by contract (returns True).
184-
- The target directory is created if needed (besteffort).
183+
- The request is accepted by contract (returns `True`).
184+
- The target directory is created if needed, best effort.
185185
- If the UI is present, the Core applies the change and may stop ongoing builds.
186186
- After requesting a switch, avoid using the old `ctx` for sensitive actions.
187187

@@ -190,10 +190,10 @@ Behavior.
190190
- Use `Plugins_SDK.GeneralContext.Dialog` for messages and progress.
191191
- When running in the GUI, dialogs are routed through the UI thread and inherit the theme.
192192
- In headless/CLI mode, these are routed to standard output.
193-
- **Important**: Plugins should avoid direct Qt imports to remain compatible with headless execution. Direct Qt dialogs (like `QProgressDialog`) are not supported in sandboxed or headless runs.
193+
- **Important**: Avoid direct Qt imports to remain compatible with headless execution. Direct Qt dialogs such as `QProgressDialog` are not supported in sandboxed or headless runs.
194194

195195
**Plugin UI Config Tabs**
196-
BCASL can expose perplugin configuration tabs in the BCASL config UI.
196+
BCASL can expose per-plugin configuration tabs in the BCASL config UI.
197197

198198
Implement:
199199

@@ -207,12 +207,13 @@ Notes.
207207

208208
- `config` is a dict to read/write.
209209
- `on_save(config_dict)` can return an updated dict.
210-
- Saved under `plugins.<id>.config` in `bcasl.yml`.
210+
- Each plugin entry stores its config in the `config` field inside the `plugins` collection in `bcasl.yml`.
211+
- `build_config_tab(...)` may return a widget, a `(title, widget)` tuple, a `(title, widget, on_save)` tuple, or a dict with `title`, `widget`, and `on_save`.
211212

212213
**Plugin i18n (GeneralContext)**
213214
Plugins can use the SDK i18n system with a `languages/` folder in the plugin package.
214-
The Core now propagates language changes to the Plugin SDK automatically, and the
215-
SDK loads translations for all plugins found in `Plugins/` (by folder name).
215+
The Core propagates language changes to the Plugin SDK, and the SDK loads
216+
translations for plugins found in `Plugins/` by folder name.
216217

217218
Example layout:
218219

@@ -224,7 +225,7 @@ Plugins/MyPlugin/
224225
fr.json
225226
```
226227

227-
Load and use (with live updates when the language changes):
228+
Load and use, with live updates when the language changes:
228229

229230
```python
230231
from Plugins_SDK.GeneralContext import (
@@ -251,10 +252,10 @@ Notes.
251252

252253
- If `options.sandbox` is `true`, plugins can run in isolated processes.
253254
- Resource limits via `options.plugin_limits` (mem, cpu, files, size).
254-
- Note: Global timeout and parallelism are no longer supported to ensure sequential stability.
255+
- Note: global timeout and parallelism are no longer supported to keep execution sequential.
255256

256257
**Plugins_SDK Utilities**
257-
The SDK provides many helpers.
258+
The SDK provides helpers for:
258259

259260
- Project and Python file analysis.
260261
- Dependency and venv inspection.

docs/how_to_create_an_engine.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A PyCompiler_ARK engine is a Python package placed in `engines/` and auto‑load
1010

1111
- Engines are discovered only in `engines/<engine_id>/`.
1212
- The folder must contain an `__init__.py`.
13-
- At startup, `EngineLoader` scans `engines/` and imports each package.
13+
- Discovery is lazy: the registry loads engines on first real access such as `get_engine`, `available_engines`, `create`, or `bind_tabs`.
1414
- Auto discovery can be disabled with `ARK_ENGINES_AUTO_DISCOVER=0`.
1515

1616
### **Package Layout**
@@ -55,9 +55,12 @@ class MyEngine(CompilerEngine):
5555

5656
### **Workspace Entrypoint**
5757

58-
The workspace can define a single build entrypoint in `ark.yml`.
59-
When `build.entrypoint` is set, the Core will compile only that file and pass it
60-
to your engine as the `entry_point` in the `BuildContext`. See `docs/ark.md`.
58+
The workspace defines its entrypoint in `ark.yml` under `project.entry`.
59+
That value is normalized by Core into `BuildContext.entry_point` and used as the
60+
primary script for compilation. A legacy `build.entrypoint` key is still accepted
61+
as a fallback during normalization, but `project.entry` is the canonical field.
62+
63+
See `docs/ark_main_config.md`.
6164

6265
### **Full API**
6366

@@ -98,8 +101,8 @@ Tools and dependencies.
98101

99102
- In `create_tab`, create widgets and store them on `self` (ex: `self._opt_onefile`).
100103
- Avoid heavy work in `__init__` to keep loading fast.
101-
- Wire signals locally and use `gui.log.append(...)` for logs.
102-
- No need to wrap your tab in a scroll area: the UI handles large tabs automatically when needed.
104+
- Wire signals locally and prefer `gui.log.append(...)` for logs.
105+
- Do not add your own scroll area unless you need custom behavior; the host wraps large engine tabs automatically.
103106
- **IMPORTANT**: Do not include UI components for **Icon** selection or **Output directory** in your engine tab. These are globally managed in `ark.yml` and passed to your engine via the `BuildContext`. Focus only on engine‑specific flags and options.
104107
- Prefer grouping options with `QGroupBox` sections and compact hints, following the built-in engines layout style.
105108
- Keep widget attribute names stable once they are used by config persistence or compilation logic.
@@ -146,8 +149,7 @@ Notes.
146149

147150
### **Advanced Config Control (Special Engines)**
148151

149-
Special engines can fully control where/how config is stored and whether the UI
150-
is allowed to save it.
152+
Special engines can override where config is stored and whether the UI may save it.
151153

152154
New hooks:
153155

@@ -158,8 +160,9 @@ New hooks:
158160
- `load_config(gui, workspace_dir) -> dict | None`: custom loader
159161
- `save_config(gui, workspace_dir, options) -> bool | None`: custom saver
160162

161-
If a custom loader/saver returns `None`, Core falls back to the default
162-
`.ark/<engine_id>/config.json` behavior.
163+
If a custom loader returns `None`, Core falls back to the default
164+
`.ark/<engine_id>/config.json` behavior. A custom saver that returns `None`
165+
also falls back to the default storage path.
163166

164167
#### Example: custom path + read‑only UI
165168

@@ -348,14 +351,18 @@ Notes.
348351
- If a key is missing, always provide a safe fallback string.
349352

350353
**Auto Command Builder (Integrated)**
351-
The auto‑builder is now integrated directly into the core compilation pipeline. It automatically reads a `mapping.json` in your engine's root directory to generate options from detected imports.
354+
The auto-builder is integrated into the core compilation pipeline. It can read
355+
`mapping.json` from the engine package, the workspace `engines/<engine_id>/`
356+
folder, or the `PYCOMPILER_MAPPING` environment variable to generate options
357+
from detected modules.
352358

353359
You no longer need to call `compute_auto_for_engine` manually in your `build_command`. The core runner will:
354360

355-
1. Detect modules imported in the project.
356-
2. Read your engine's `mapping.json`.
357-
3. Generate the appropriate flags.
358-
4. Automatically insert them into your command (usually before the entry point).
361+
1. Prefer `requirements.txt` or `requirements.in` when present.
362+
2. Fall back to `pyproject.toml` dependencies.
363+
3. Fall back to scanning Python imports.
364+
4. Read the engine mapping and generate the appropriate flags.
365+
5. Insert them into your command, usually before the entry point.
359366

360367
#### **Minimal mapping.json example.**
361368

@@ -374,10 +381,11 @@ You no longer need to call `compute_auto_for_engine` manually in your `build_com
374381

375382
Key points.
376383

377-
- Toplevel keys are package names.
384+
- Top-level keys are package names.
378385
- Engine values accept `str`, `list[str]`, or `dict` with `args` or `flags`.
379-
- `"{import_name}"` is replaced by the actual import name.
380-
- For advanced logic, expose `AUTO_BUILDER` in `engines/<engine_id>/auto_plugins.py`.
386+
- `"{import_name}"` is replaced by the matched import name.
387+
- For advanced logic, expose `AUTO_BUILDER`, `get_auto_builder()`, or
388+
`register_auto_builder()` in `engines/<engine_id>/auto_plugins.py`.
381389

382390
**Deep Examples Catalog (40)**
383391
Each example includes context, intent, and a working pattern. Adjust IDs and labels to match your engine.
@@ -795,7 +803,7 @@ def get_auto_builder():
795803

796804
Notes.
797805

798-
- Use when simple mapping is not enough.
806+
- Use this when simple mapping is not enough.
799807

800808
1. mapping.json for torch (example).
801809

@@ -820,7 +828,7 @@ Notes.
820828
1. Detection source (requirements preferred).
821829

822830
```python
823-
# Auto builder prioritizes requirements.txt when present
831+
# Auto-builder prioritizes `requirements.txt` or `requirements.in` when present.
824832
```
825833

826834
Notes.

0 commit comments

Comments
 (0)