conditional include in asciidoc

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

conditional include in asciidoc

pmucha
sorry for crosspost from stackoverflow, i thought thats the main channel... I am using Spring RestDoc together with AsciiDoc to describe my rest api. RestDoc generates different files depending if there are request parameters described / response fields etc. I would like to have one template conditionally including whatever file exists. something like this:
Request:

include::{reqresPath}/http-request.adoc[]

Response:
include::{reqresPath}/http-response.adoc[]

Parameters:
ifeval::[{{reqresPath}/request-parameters.adoc}.exists]
  include::{reqresPath}/request-parameters.adoc[]
endif::[]
ifeval::[{{reqresPath}/request-parameters.adoc}.exists]
  include::{reqresPath}/request-parameters.adoc[]
endif::[]
or at least exclude warnings in case of a missing file. But I could not figure out how to suppress these. thanks for any help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: conditional include in asciidoc

mojavelinux
Administrator
You can exclude warnings for a missing file by writing an IncludeProcessor that takes over including the file. Then, you can choose not to warn if the file does not exist.

Since we haves to control what happens when an attribute is missing, perhaps we should have flags to control what happens if an include file is missing. Right now, it's always seen as a warning.

-Dan

On Fri, Dec 16, 2016 at 1:24 AM, pmucha [via Asciidoctor :: Discussion] <[hidden email]> wrote:
sorry for crosspost from stackoverflow, i thought thats the main channel... I am using Spring RestDoc together with AsciiDoc to describe my rest api. RestDoc generates different files depending if there are request parameters described / response fields etc. I would like to have one template conditionally including whatever file exists. something like this:
Request:

include::{reqresPath}/http-request.adoc[]

Response:
include::{reqresPath}/http-response.adoc[]

Parameters:
ifeval::[{{reqresPath}/request-parameters.adoc}.exists]
  include::{reqresPath}/request-parameters.adoc[]
endif::[]
ifeval::[{{reqresPath}/request-parameters.adoc}.exists]
  include::{reqresPath}/request-parameters.adoc[]
endif::[]
or at least exclude warnings in case of a missing file. But I could not figure out how to suppress these. thanks for any help


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/conditional-include-in-asciidoc-tp5155.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Loading...