feat: addon registry with runtime introspection API (#253) #258
Reference in New Issue
Block a user
Delete Branch "feat/addon-registry-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.pyAddonManifest.contexts: Newlist[str]field tracking context IDs an addon providesAddonRegistry.register_context(addon_name, context_id): Runtime context registration for addonsAddonRegistry.contexts(): Returns{context_id: [addon_names]}mapping<contexts>XML parsing: Reads<context>elements from<kindred>inpackage.xmlgetAddonRegistry(): Module-level function returning the registry singletonsrc/Mod/Create/Init.pygetAddonRegistryasFreeCAD.getAddonRegistryafter addon loadingAPI
Addons can declare contexts in
package.xml:Or register at runtime:
Closes #253
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