2016-05-18 74 views
3

我使用spring rest文档生成asciidoc片段。将参数传递给asciidoc中的模板文件

我可以在我的文档页面中包含生成的片段。但是,我想在一个独立的adoc文件中定义每个secion的结构,并为我的索引文件中的每个文件定义一行。

目前我index.adoc文件看起来像这样:

= 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[] 

我希望它是这样的,而不是

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[] 

任何人都知道这是怎么回事?

回答

4

我能够通过在每个include语句之前使用替换语法来解决此问题。

我index.adoc文件看起来像这一点,它的工作原理:

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

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