Skip to content
  • Ethaks's avatar
    c37b89e4
    refactor: rework registries around DataModels · c37b89e4
    Ethaks authored
    This MR refactors registries (previously `BaseRegistry`, now just `Registry`)
    to contain entries based on `DataModel`s.
    With that it gets rid of some of the pre-`DataModel` handling
    (including `.data`).
    Initialisation of registries is split into two parts:
    1. The self-contained `_initialize` (which should allow future `DataModel`
      implementations for documents to refer to them for their `choices`)
    2. A `setup` step run in the `setup` hook, allowing registry entries to
      localise their own fields, replacing translation keys
    
    API documentation for registries (including an example for `DamageType`
    addition) is added.
    
    It includes **breaking changes**:
    - The previously forgotten `pf1.register<Registry>` hook is immediately replaced
      with the now-common format of `pf1Register<Registry>`.
      Its second parameter (the entry class) has been removed, as it is available
      through `registry.module` should a caller need it – which should usually not
      be necessary due to `Registry#register` taking a data object.
    - `DamageType` entries have their modifier boolean moved from a flag to the
      actual object, now using `isModifier`.
    - `module` fields are replaced with a more general `namespace`.
    c37b89e4
    refactor: rework registries around DataModels
    Ethaks authored
    This MR refactors registries (previously `BaseRegistry`, now just `Registry`)
    to contain entries based on `DataModel`s.
    With that it gets rid of some of the pre-`DataModel` handling
    (including `.data`).
    Initialisation of registries is split into two parts:
    1. The self-contained `_initialize` (which should allow future `DataModel`
      implementations for documents to refer to them for their `choices`)
    2. A `setup` step run in the `setup` hook, allowing registry entries to
      localise their own fields, replacing translation keys
    
    API documentation for registries (including an example for `DamageType`
    addition) is added.
    
    It includes **breaking changes**:
    - The previously forgotten `pf1.register<Registry>` hook is immediately replaced
      with the now-common format of `pf1Register<Registry>`.
      Its second parameter (the entry class) has been removed, as it is available
      through `registry.module` should a caller need it – which should usually not
      be necessary due to `Registry#register` taking a data object.
    - `DamageType` entries have their modifier boolean moved from a flag to the
      actual object, now using `isModifier`.
    - `module` fields are replaced with a more general `namespace`.
Loading