asciidoc - 有条件地包含在 asciidoc 中

标签 asciidoc asciidoctor spring-restdocs

我正在使用 Spring RestDoc 和 AsciiDoc 来描述我的 rest api。 RestDoc 根据是否有描述的请求参数/响应字段等生成不同的文件。我希望有一个模板有条件地包括任何存在的文件。

像这样:

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

或者至少在丢失文件的情况下排除警告。但我不知道如何抑制这些。

最佳答案

截至今天,no operator在哪里?为 ifeval可用,可用于检查文件是否存在。
我要走的路是写一个 extension for Asciidoctor ,这也可以通过使用 Java 来完成。如果您的项目足够大,我建议您采用此解决方案。

关于asciidoc - 有条件地包含在 asciidoc 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41159343/

相关文章:

asciidoc - Asciidoc 标记是否可以编程方式扩展(通过现有实现,如 RST)?

asciidoc - 如何在asciidoc上添加样式表CDN?

spring-boot - 如何使用 spring restdocs 记录包含 JSON 对象的请求正文

spring - 在 Spring Rest 文档中记录 byte[] 响应

latex - 将 Asciidoc 转换为 LaTeX

reference - 有没有办法将引用文献/文献列表添加到 ASCII-DOC(或 Markdown)?

asciidoctor - Asciidoctor 可以为每一章渲染一个单独的 HTML 页面吗?

python - 如何在 Python 中使用 AsciiDoc?

html - asciidoctor 是否有设置从它输出的源中删除 <paragraph> 和 <p> 标签?

java - 如何使用有条件地返回响应的 Spring REST Docs 记录 REST 服务?