7

I'm generating asciidoc snippets using spring rest docs.

I can include the generated snippets in my doc page. However, I want to define the structure of each secion once in a seperate adoc file, and have a single line for each of those in my index file.

Currently my index.adoc file looks like this:

= My Http Api Docs

= GET /units/:id

== Path Parameters
include::{snippets}/units/get/path-parameters.adoc[]

== Response Fields
include::{snippets}/units/get/response-fields.adoc[]

I want it to be like this instead

index.adoc

= My Http Api Docs

usemytemplates::mytemplate.adoc[method='get', url='units', desc='/units/:id']

mytemplate.adoc

= {method} {desc}

== Path Parameters
include::{snippets}/{url}/{method}/path-parameters.adoc[]

== Response Fields
include::{snippets}/{url}/{method}/response-fields.adoc[]

Anyone know how something like this can be done?

ddouglascarr
  • 1,334
  • 3
  • 14
  • 23

1 Answers1

11

I was able to solve this by using the substitution syntax before each include statement.

My index.adoc file looks like this and it works:

:method: get
:url: units
:desc: /utils/:id
include::mytemplate.adoc[]

:method: get
:url: members
:desc: /members/:id
include::mytemplate.adoc[]
ddouglascarr
  • 1,334
  • 3
  • 14
  • 23
  • 1
    Here is an example in the off. doc: https://asciidoctor.org/docs/user-manual/#include-multiple – Cepr0 Jul 15 '18 at 11:37