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?
The AsciiDoc syntax is more concise than (or at least as concise as) Markdown. At the same time, AsciiDoc offers power and flexibility without requiring the use of HTML or “flavors” for essential syntax such as tables, description lists, admonitions (tips, notes, warnings, etc.) and table of contents.
The original processor, named AsciiDoc, is written in Python. A more modern implementation, named Asciidoctor, is written in Ruby.
AsciiDoc is a text document format that was explicitly designed with the needs of publishing in mind, both print and web. It supports all the structural elements necessary for writing notes, documentation, articles, books, ebooks, slideshows, web pages, technical manuals and blogs.
GitHub uses Asciidoctor in safe mode to render files with the extension . adoc , . ad , and . asciidoc .
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[]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With