Syntax Registry concept

Hi devs,

I’ve created a JIRA issue at https://jira.xwiki.org/browse/XRENDERING-595 to introduce the concept of a Syntax Registry. The initial need came from https://jira.xwiki.org/browse/MARKDOWN-72.

I’ve pushed some code in a branch to show you what it could look like:

Please check the jira issue and let me know what you think about this idea.

Thanks

Hi Vincent,

I globally agree with a Syntax Registry concept.
Given the API you proposed on https://jira.xwiki.org/browse/XRENDERING-595?focusedCommentId=107408&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-107408

/**
 * Automatically register one or several syntaxes into the Syntax Registry. The syntaxes will be registered when
 * the implementing component is registered into the Component Manager.
 *
 * @since 12.10RC1
 */
@Unstable
@Role
public interface SyntaxRegistryInitializer
{
    /**
     * @return the list of syntaxes to register into the Syntax Registry
     */
    List<Syntax> initialize();
}

I don’t really agree with calling this method initialize since AFAIU it only returns the list of syntax to initialize: it does not perform the initialization itself.

You also said:

Note: We might also need a SyntaxTypeRegistry (not sure yet)

what would be the difference between SyntaxRegistry and SyntaxTypeRegistry?

We can discuss the name. What do you have in mind? I tried to find better names and came short so far.

Ideas:

  • SyntaxRegistrySyntaxProvider
  • SyntaxProvider
  • SyntaxRegistrator
  • SyntaxRegistryEntry
  • more?

Same as what we have now. SyntaxTypeRegistry would allow you to register SyntaxType objects and SyntaxRegistry would allow you to register Syntax objects.

EDIT: As I said I’m not sure we need one but without one it means several modules that provide different syntaxes for the same syntax type need to either have syntax type duplication or some common module or depend on one another (for example).

I was not talking about the name of the class but just of the name of the method.
We could just have a getSyntax in it: apparently we use that in MandatoryDocumentInitializer where there’s a getDocumentReference.

Indeed. Could actually make sense for dedup as you mentioned and also for other usecases such as allowing registering a variant only if a syntax type is already registered.

it’s the same. It’s important to have the class and method names aligned. A Provider provides, an Initializer initializes, a Factory creates, etc. IMO you cannot disagree about initialize() but agree that it’s called SyntaxRegistryInitializer.