Skip to content

Commit 17c9cf6

Browse files
committed
`Update registration methods for BC plugins and engines
* BC plugins: `bcasl_register(manager)` -> `@bc_register` or `bcasl_register(manager)` * Engines: `registry.register(MyEngine)` -> `engine_register(MyEngine)`
1 parent 2a7f5e5 commit 17c9cf6

3 files changed

Lines changed: 42 additions & 21 deletions

File tree

docs/About_Sdks.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ BC plugins are pre-compilation plugins that validate, prepare, and optimize the
2323
- Clean workspace before compilation
2424

2525
**Key Characteristics:**
26-
- **Registration:** Uses `bcasl_register(manager)` function to register with BCASL
26+
- **Registration:** Uses `@bc_register` decorator or `bcasl_register(manager)` function
2727
- **Version Compatibility:** Plugins declare required versions for BCASL, Core, and SDK components
2828
- **User Interaction:** Uses `Dialog` API from `Plugins_SDK.GeneralContext` for logging and user prompts
2929
- **Context Access:** Receives `PreCompileContext` with workspace info and file iteration utilities
@@ -48,7 +48,7 @@ Engines are compilation tools that transform Python code into executables. They
4848
- Engine-specific configuration management
4949

5050
**Key Characteristics:**
51-
- **Registration:** Self-register via `registry.register(MyEngine)` on import
51+
- **Registration:** Self-register via `engine_register(MyEngine)` or `registry.register(MyEngine)` (alias)
5252
- **Version Compatibility:** Engines declare `required_core_version` and `required_sdk_version`
5353
- **Discovery:** Auto-discovered from `ENGINES/` directory (packages only)
5454
- **UI Integration:** Optional tab creation via `create_tab(gui)` method
@@ -164,13 +164,19 @@ def bcasl_register(manager):
164164
### Engine Registration
165165

166166
```python
167-
# Self-register at module level
167+
# Self-register at module level (new method)
168+
from engine_sdk import engine_register
169+
168170
class MyEngine(CompilerEngine):
169171
id = "my_engine"
170172
name = "My Engine"
171173
# ...
172174

173-
registry.register(MyEngine)
175+
engine_register(MyEngine)
176+
177+
# Or using the legacy alias (still supported)
178+
from engine_sdk import register
179+
register(MyEngine)
174180
```
175181

176182
**Discovery:**
@@ -300,7 +306,7 @@ See [ARK Configuration Guide](./ARK_Configuration.md) for global configuration d
300306
|--------|---------------------|---------|
301307
| **Purpose** | Pre-compilation validation/preparation (BC phase) | Compilation execution |
302308
| **When** | Before build starts | During build |
303-
| **Registration** | `bcasl_register(manager)` | `registry.register(MyEngine)` |
309+
| **Registration** | `@bc_register` or `bcasl_register(manager)` | `engine_register(MyEngine)` or `register(MyEngine)` |
304310
| **Discovery** | `Plugins/` directory | `ENGINES/` directory |
305311
| **UI** | None (uses Dialog API) | Optional tab via `create_tab()` |
306312
| **i18n** | No (static messages) | Yes (via `apply_i18n()`) |

docs/how_to_create_a_BC_plugin.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ Create `Plugins/my.plugin.id/__init__.py`:
2525
from __future__ import annotations
2626

2727
from pathlib import Path
28+
from bcasl import bc_register
2829
from Plugins_SDK.BcPluginContext import BcPluginBase, PluginMeta, PreCompileContext
2930
from Plugins_SDK.GeneralContext import Dialog
3031

3132
# Create Dialog instances for user interaction and logging
3233
log = Dialog()
3334
dialog = Dialog()
3435

35-
META = PluginMeta(
36+
PLUGIN_META = PluginMeta(
3637
id="my.plugin.id",
3738
name="My BC Plugin",
3839
version="1.0.0",
@@ -47,9 +48,14 @@ META = PluginMeta(
4748
)
4849

4950

51+
@bc_register
5052
class MyPlugin(BcPluginBase):
53+
'''My BC Plugin description.'''
54+
55+
meta = PLUGIN_META
56+
5157
def __init__(self) -> None:
52-
super().__init__(META)
58+
super().__init__(meta=PLUGIN_META)
5359

5460
def on_pre_compile(self, ctx: PreCompileContext) -> None:
5561
"""Execute pre-compilation actions.
@@ -81,11 +87,15 @@ class MyPlugin(BcPluginBase):
8187
except Exception as e:
8288
log.log_error(f"Plugin error: {e}")
8389
raise
90+
```
8491

92+
**Alternative: Using old-style registration**
8593

86-
# Create plugin instance
87-
PLUGIN = MyPlugin()
94+
If you prefer the old-style registration, you can still use it:
8895

96+
```python
97+
# Old-style registration (still supported)
98+
PLUGIN = MyPlugin()
8999

90100
def bcasl_register(manager):
91101
"""Register the plugin with the BCASL manager."""

docs/how_to_create_an_engine.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ class MyEngine(CompilerEngine):
7777
pass
7878

7979

80-
# Register the engine
81-
from Core.engines_loader.registry import register
82-
register(MyEngine)
80+
# Register the engine using the new engine_register function
81+
from engine_sdk import engine_register
82+
engine_register(MyEngine)
8383
```
8484

8585
Create `ENGINES/my_engine/mapping.json`:
@@ -152,9 +152,12 @@ class MyEngine(CompilerEngine):
152152

153153
```python
154154
# At module level, after class definition
155-
register(MyEngine)
155+
from engine_sdk import engine_register
156+
engine_register(MyEngine)
156157
```
157158

159+
**Note:** The old `register` function is still available as an alias for backward compatibility, but `engine_register` is the recommended new name.
160+
158161
### 2.4) Create mapping.json
159162

160163
```json
@@ -177,22 +180,24 @@ register(MyEngine)
177180

178181
### 3.1) Registry API
179182

180-
The `Core.engines_loader.registry` module provides the registration system:
183+
The `engine_sdk` module provides the registration system via `engine_register`:
181184

182185
```python
183-
from Core.engines_loader.registry import (
184-
register, # Register an engine class
185-
get_engine, # Get engine class by ID
186-
available_engines, # List all registered engine IDs
187-
create, # Create an engine instance
186+
from engine_sdk import (
187+
engine_register, # Register an engine class (new name)
188+
register, # Register an engine class (alias for backward compatibility)
189+
CompilerEngine,
188190
)
189191

190-
# Register your engine
191-
register(MyEngine)
192+
# Register your engine (using new name)
193+
engine_register(MyEngine)
192194

193195
# Later, retrieve it
196+
from Core.engines_loader.registry import get_engine, available_engines, create
197+
194198
engine_cls = get_engine("my_engine")
195199
engine_instance = create("my_engine")
200+
available = available_engines()
196201
```
197202

198203
### 3.2) Registration rules

0 commit comments

Comments
 (0)