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

Example with maven site plugin and diagrams #238

Open
raoulvdberge opened this issue Jan 11, 2024 · 1 comment
Open

Example with maven site plugin and diagrams #238

raoulvdberge opened this issue Jan 11, 2024 · 1 comment

Comments

@raoulvdberge
Copy link

raoulvdberge commented Jan 11, 2024

Hello,

Would it be possible to provide an example with the maven site plugin and asciidoctor-diagrams?

I tried myself, and it does properly generate the diagram, but it doesn't copy it to the resources/images directory. It stores it next to my source adoc file.

After configuring imagesoutdir, it does generate the diagram in the correct location, but it seems too late for the site plugin to see the asset and ends up not copying anything to the target folder.

This is my config:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.12.1</version>
                <configuration>
                    <generateReports>false</generateReports>
                    <generateSitemap>true</generateSitemap>
                    <relativizeDecorationLinks>false</relativizeDecorationLinks>
                    <locales>en</locales>
                    <inputEncoding>UTF-8</inputEncoding>
                    <outputEncoding>UTF-8</outputEncoding>
                    <asciidoc>
                        <requires>
                            <require>asciidoctor-diagram</require>
                        </requires>
                        <attributes>
                            <source-highlighter>coderay</source-highlighter>
                            <coderay-css>style</coderay-css>
                            <imagesoutdir>${project.basedir}/src/site/resources/images</imagesoutdir>
                        </attributes>
                    </asciidoc>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctor-maven-plugin</artifactId>
                        <version>2.2.4</version>
                    </dependency>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj-diagram</artifactId>
                        <version>2.2.14</version>
                    </dependency>
                </dependencies>
            </plugin>
@abelsromero
Copy link
Member

abelsromero commented Jan 11, 2024

There's a limitation in how docs are converted to get them in a form that can be embedded in a site. The workaround is to configure the target path for images as described in https://docs.asciidoctor.org/diagram-extension/latest/output/, for instance, add this attribute to your example and it should work.

<attributes>
    <imagesoutdir>${project.build.directory}/site/images</imagesoutdir>

If you have some complex setup with multiple depths, you can also setup :imagesoutdir: in each AsciiDoc source file.

The path can vary depending on sources and target location set by the user in the pom and maven-site plugin. So there's not much we can do to automate it without a lot of hacky parsing the pom and some guesses (not counting inheritance configurations).
Given that I think it's a really good idea to have it in the example with a note, do you want to extend the current example by adding the diagram configuration? we can take some of the examples from the stand-alone diagram example.

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