Home > database >  Specify custom snippet directory for spring-restdocs-asciidoctor?
Specify custom snippet directory for spring-restdocs-asciidoctor?

Time:10-21

I have configured a custom snippet directory with RestDocumentationExtension.

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

CodePudding user response:

You can set the snippets attribute at the top of your .adoc document, for example:

:snippets: /your/custom/location

This will override the default location that's configured by spring-restdocs-asciidoctor.

CodePudding user response:

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>
  • Related