-
-
Notifications
You must be signed in to change notification settings - Fork 36
Extending the registry is not defined and difficult #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think a few other things to call out. An implementation will probably have its own registry copy, with whatever is has chosen to locally extend included. For example, the A plug-in library, by contrast, might want to be somewhat implementation agnostic. It's implementer might want it to be entirely self-contained, so its registry file would contain complete descriptions of the selectors and formatters it provides (even if these override the default ones in an implementation). This makes sense because the code being called is separate from that of the implementation. Presumably the plug-in masks any conflicts, at least within it's namespace. In practice, each implementation will define calling conventions and APIs necessary for this kind of behavior. We might not want to solve this for 2.0 and leave some room for implementation experience to inform future standardization. The purpose of the default registry in 2.0 is to set a floor for selectors and formatters functionality and to help ensure message interoperability between implementations. We'll probably want to push implementations to adopt more functions in a standardized way (rather than plugging-in separate different formatters for the same things). |
To expand on that somewhat, an important function of the registry is to communicate to non-formatter-implementation tools how the functions used in MF2 work. We want to make it easy for someone using implementation A together with plugins B and C to have their tools (validation/linting, XLIFF target file template generator, others) understand the relevant parts of how the functions of A, B, and C all work, and which ones override which others. |
Fair enough. We should write this into |
Thanks for starting this discussion, it's useful and timely.
I tend to think the opposite: that multiple signatures make it easy to extend the registry. <!-- The parent registry. -->
<function name="datetime">
<!-- The root signature with common options. -->
<formatSignature>
<option name="dateStyle" values="full long medium short">
<description>The predefined date formatting style to use.</description>
</option>
<option name="timeStyle" values="full long medium short">
<description>The predefined time formatting style to use.</description>
</option>
<option name="calendar" values="buddhist chinese ...">
<description>The calendar system to use.</description>
</option>
</formatSignature>
</function> <!-- The child registry. -->
<function name="datetime">
<!-- The extension. -->
<formatSignature>
<!-- Options without details inherit from the root signature. -->
<!-- Options not repeated here are not available in this signature. -->
<option name="calendar"/>
<!-- Extend the signature with a custom option. -->
<option name="icu:skeleton" validationRule="...">
<description>...</description>
</option>
</formatSignature>
</function>
I think using some kind of specificity should be good enough, although I don't have the exact algorithm ready in my head. The two use-cases that I'd like to keep in mind are:
|
* Describe registry use and conformance Addresses my comments in #561 * Fix bad copypasta * Apply suggestions from code review Co-authored-by: Eemeli Aro <[email protected]> * Remove redundant normative sentence ... and other wording changes to clarify the usage section --------- Co-authored-by: Eemeli Aro <[email protected]>
@stasm Given that our current Edit: Or, wait, does the |
@stasm suggested that each function should have a single "root signature" and then 0 or more But the signatures for So maybe this would be something to add a design doc for? |
Per our last call (2024-02-05) this is non-blocking. |
Uh oh!
There was an error while loading. Please reload this page.
With our current registry definition, each
<function>
may contain multiple<formatSignature>
and<matchSignature>
elements, each of which separately defines their inputs and options. I think this structure allows too much variation and is difficult to extend.For context, let us consider a registry that extends our base registry by adding an option
icu:skeleton
to the:datetime
formatter. What does that registry look like, and what changes are required to make that possible and easy to use?First, this child registry needs some way of indicating which parent registry it's extending. One possibility is a new attribute with a URL value:
Are there other alternatives? Is there some more natively XML-ish way to express this sort of parent-child relationship?
Next, we need a way to identify the parent registry's formatter definition to which we're adding the option. At the moment, as we allow for and use more than one
<formatSignature>
in<function name="datetime">
, this is difficult. I can think of a couple of different solutions:id
on each<formatSignature>
and use that to link the parent and child signatures.<formatSignature>
and<matchSignature>
in each<function>
.<formatSignature>
and<matchSignature>
elements, and indicate otherwise whether the function supports formatting and matching, and which options affect either.Are there other possibilities that could be considered? One additional required change here changing the
<function name>
to be aID
rather than anNMTOKEN
.My own preference would be the third one, because that would also solve another potential problem: Currently, we allow for each function option to have completely independent and different meanings in each
<formatSignature>
and<matchSignature>
. So the permitted values for an optionfoo
can change entirely depending on whether another optionbar
is set, and where in the message it's used. This is unnecessarily liberal.Alternatively, we could take the approach used by
<alias>
, and add asupports=format|match|all
attribute to<function>
and<option>
, with the latter being defined directly under<function>
. This way, each option would only have a single definition that's independent of its position in the message.If we choose either the second or third option, we should consider adding an attribute like
conflicts
orexcludes
on<option>
to allow for the definition of mutually incompatible baskets of options.To sketch out this possibility in more detail, here's what the
registry.xml
could look like if the changes from #560 are also incorporated: https://github.com/eemeli/message-format-wg/blob/extend-registry/spec/registry.xmlFinally, we need a definition of how the merge happens. Do we only support extending the whole
<registry>
, or also individual<function>
and other elements? Do we support localization of the descriptions as an extension, or should that require a manual copy?The text was updated successfully, but these errors were encountered: