springasciidoctorspring-restdocs

Specify custom snippet directory for spring-restdocs-asciidoctor?


I have configured a custom snippet directory with RestDocumentationExtension.

How can I specify this snippet directory for the spring-restdocs-asciidoctor?


Solution

  • I have configured my custom snippet location with the snippets tag inside the attributes tag in the asciidoctor-maven-plugin configuration.

    <build>
        <plugins>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-docs</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            // other config
                            <attributes>
                                <snippets>${project.basedir}/src/docs/snippets</snippets>
                            </attributes>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.restdocs</groupId>
                        <artifactId>spring-restdocs-asciidoctor</artifactId>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>