feat: addon registry with runtime introspection API (#253) #258

Merged
forbes merged 1 commits from feat/addon-registry-api into main 2026-02-16 23:41:19 +00:00
Owner

Summary

Exposes a runtime addon registry via FreeCAD.getAddonRegistry() for introspecting loaded addons, their versions, status, and registered contexts.

Changes

src/Mod/Create/addon_loader.py

  • AddonManifest.contexts: New list[str] field tracking context IDs an addon provides
  • AddonRegistry.register_context(addon_name, context_id): Runtime context registration for addons
  • AddonRegistry.contexts(): Returns {context_id: [addon_names]} mapping
  • <contexts> XML parsing: Reads <context> elements from <kindred> in package.xml
  • getAddonRegistry(): Module-level function returning the registry singleton

src/Mod/Create/Init.py

  • Exposes getAddonRegistry as FreeCAD.getAddonRegistry after addon loading

API

registry = FreeCAD.getAddonRegistry()
registry.get('ztools')        # AddonManifest for ztools
registry.loaded()             # list of loaded addons
registry.failed()             # list of failed addons
registry.skipped()            # list of skipped addons
registry.is_loaded('silo')    # True/False
registry.contexts()           # {context_id: [addon_names]}

Addons can declare contexts in package.xml:

<kindred>
  <contexts>
    <context>partdesign.body</context>
  </contexts>
</kindred>

Or register at runtime:

FreeCAD.KindredAddons.register_context('ztools', 'partdesign.body')

Closes #253

## Summary Exposes a runtime addon registry via `FreeCAD.getAddonRegistry()` for introspecting loaded addons, their versions, status, and registered contexts. ## Changes ### `src/Mod/Create/addon_loader.py` - **`AddonManifest.contexts`**: New `list[str]` field tracking context IDs an addon provides - **`AddonRegistry.register_context(addon_name, context_id)`**: Runtime context registration for addons - **`AddonRegistry.contexts()`**: Returns `{context_id: [addon_names]}` mapping - **`<contexts>` XML parsing**: Reads `<context>` elements from `<kindred>` in `package.xml` - **`getAddonRegistry()`**: Module-level function returning the registry singleton ### `src/Mod/Create/Init.py` - Exposes `getAddonRegistry` as `FreeCAD.getAddonRegistry` after addon loading ## API ```python registry = FreeCAD.getAddonRegistry() registry.get('ztools') # AddonManifest for ztools registry.loaded() # list of loaded addons registry.failed() # list of failed addons registry.skipped() # list of skipped addons registry.is_loaded('silo') # True/False registry.contexts() # {context_id: [addon_names]} ``` Addons can declare contexts in `package.xml`: ```xml <kindred> <contexts> <context>partdesign.body</context> </contexts> </kindred> ``` Or register at runtime: ```python FreeCAD.KindredAddons.register_context('ztools', 'partdesign.body') ``` Closes #253
forbes added 1 commit 2026-02-16 23:33:48 +00:00
feat: addon registry with runtime introspection API (#253)
All checks were successful
Build and Test / build (pull_request) Successful in 44m33s
9dd43a7cc3
Add FreeCAD.getAddonRegistry() function for runtime addon introspection.

Changes to addon_loader.py:
- Add contexts field to AddonManifest for tracking context IDs
- Add register_context() method for addons to declare contexts at runtime
- Add contexts() method returning {context_id: [addon_names]} mapping
- Parse <contexts> element from <kindred> in package.xml
- Add getAddonRegistry() function returning the registry singleton

Changes to Init.py:
- Expose getAddonRegistry as FreeCAD.getAddonRegistry after loading

Usage:
  registry = FreeCAD.getAddonRegistry()
  registry.get('ztools')        # AddonManifest for ztools
  registry.loaded()             # list of loaded addons
  registry.is_loaded('silo')    # True/False
  registry.contexts()           # {context_id: [addon_names]}

Closes #253
forbes merged commit 33026b6ff9 into main 2026-02-16 23:41:19 +00:00
forbes deleted branch feat/addon-registry-api 2026-02-16 23:41:21 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/create#258