Skip to content
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

Add first support for registering converter instances #933

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robertpanzer
Copy link
Member

Thank you for opening a pull request and contributing to AsciidoctorJ!

Please take a bit of time giving some details about your pull request:

Kind of change

  • Bug fix
  • New non-breaking feature
  • New breaking feature
  • Documentation update
  • Build improvement

Description

What is the goal of this pull request?

The goal is to allow registering converter instances. Today it is only possible to register classes, that are instantiated by Asciidoctor for each document conversion.

How does it achieve that?

The ConverterProxy creates a single Ruby class for the class of the registered instance, and instantiates that on every registration call, passing the concrete Java converter to the initializeInstance method.

Are there any alternative ways to implement this?

Yes, similar to how the extensions work today, which is not ideal now that I have a different view on it, I could have created a new class for every registration, and each RubyClass would use the same registered Java instance.
But I think the new approach is a bit better.

Are there any implications of this pull request? Anything a user must know?

Issue

If this PR fixes an open issue, please add a line of the form:

Fixes #932

Release notes

Please add a corresponding entry to the file CHANGELOG.adoc

Note:

The PR is not final yet. There have to be a lot more tests, and there is still the problem how the ConverterRegistry should look like for looking up converters without breaking the API. Right now JavaConverterRegistry.resolve() and JavaConverterRegistry.converters() return classes, not instances or objects.
We might need to go to AsciidoctorJ 3.0.0 to support getting instances from the converter registry.

I already opened the PR early in case somebody wants to test this too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

It should be possible to register an instance in the javaConverterRegistry
1 participant