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

SPI extensions not loading #64

Open
adpr opened this issue Jan 19, 2017 · 1 comment
Open

SPI extensions not loading #64

adpr opened this issue Jan 19, 2017 · 1 comment

Comments

@adpr
Copy link

adpr commented Jan 19, 2017

I am using asciidoctorj 1.5.4, asciidoctorj-pdf 1.5.0-alpha.11 and asciidoclet 1.5.4 in a maven project. I have defined some custom BlockProcessors and registered them using the javaExtensionRegistry and created the proper files in my META-INF/services folder.

Generating the PDF works flawlessly, and my custom BlockProcessors are recognized and rendered as they should be. In the Javadoc however, the custom BlockProcessors are not rendered at all, and asciidoctor reports the many warnings about the BlockProcessors not being recognized:

asciidoctor: WARNING: <stdin>: line 7: invalid style for paragraph: eks

If I throw a RuntimeException in the register method of my class that implements ExtensionRegistry, I can see that generating a PDF will throw the exception, but generating the Javadoc does not. It would seem that that extensions are not being loaded by AsciidoctorJ when generating the Javadoc.

Here is one of my BlockProcessors:

public class EksBlock extends BlockProcessor {

  public EksBlock(String name, Map<String, Object> config) {
    super(name, config);
  }

  @Override
  public Object process(AbstractBlock parent, Reader reader, Map<String, Object> attributes) {
    // attributes that a normal admonition would accept
    attributes.put("name", "EKS");
    attributes.put("caption", "EKS.");

    // just pass along the text
    String admonitionText = reader.read();

    return createBlock(parent, "admonition", admonitionText, attributes, new HashMap<Object, Object>());
  }
}

My ExtensionRegistry implementation:

public class BlockExtensionRegistry implements ExtensionRegistry {

  public void register(Asciidoctor asciidoctor) {
    Map<String, Object> config = new HashMap<String, Object>();
    config.put("contexts", Arrays.asList(":paragraph"));
    config.put("content_model", ":compound");

    EksBlock eksBlock = new EksBlock("eks", config);
  }
}

I also have the following file:

src/main/resources/META-INF/services/org.asciidoctor.extension.spi.ExtensionRegistry

File content:

com.example.extension.asciidoctor.BlockExtensionRegistry

Snippet from pom.xml

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-javadoc-plugin</artifactId>
	<configuration>
	  <failOnError>false</failOnError>
	  <noqualifier>all</noqualifier>
	  <show>private</show>
	  <doclet>org.asciidoctor.Asciidoclet</doclet>
	  <docletArtifact>
		<groupId>org.asciidoctor</groupId>
		<artifactId>asciidoclet</artifactId>
		<version>1.5.4</version>
	  </docletArtifact>
	  <additionalparam>
		--base-dir ${project.basedir}
		--attribute "name=${project.name}"
		--attribute "version=${project.version}"
		--attribute
		"templateDir=${project.basedir}/src/docs/asciidoc/template"
	  </additionalparam>
	</configuration>
</plugin>

Am I missing some configuration in my pom.xml that will allow Asciidoclet to register the extensions, or is this an issue with Asciidoclet?

@johncarl81
Copy link
Member

Are you expecting Asciidoclet to pick up your EksBlock block processor within your project?

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

No branches or pull requests

2 participants