Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically hide asciidoc element

I use org.asciidoctor.convert plugin for gradle to generate API documentation for my team. I include files:

include::{snippets}/index/curl-request.adoc[] 

and want to place it's content into spoiler or anything like that. Is there any way to somehow hide dynamicaly asciidoc elements? I try to use

pass:[<details open>  
include::{snippets}/index/curl-request.adoc[]
</details>]

but it is not processed include inside it. Any ideas will be higly appreciated. Without hiding snippets my documentation have almost unlimited scrol :). If no such way with ascii doc, suggestions of other documentation formats, where i can include files content and place it into the spoiler is also appreciated.

like image 899
cynepnaxa Avatar asked Dec 17 '15 03:12

cynepnaxa


2 Answers

As Guillaume Grossetie has mentioned here

Using passthrough to include raw HTML is not recommended because now your document is tightly coupled with the output.

and it is deprecated. The new syntax for collapsible/foldable sections is

.some description
[%collapsible]
====
this
is
going
to be
folded
====
like image 166
Foad S. Farimani Avatar answered Nov 07 '22 10:11

Foad S. Farimani


As this was so helpful for me - I added here the solution from Robin's comment.

No CSS and Javascript needed!

Here is an example:

+++ <details><summary> +++
Check `reference.conf`:
+++ </summary><div> +++
----
play {
  http {
    secret.key = asdf
    secret.key = ${?SECRET_KEY}
    ...
  }
  ...
}
----
+++ </div></details> +++

This creates a collapsed element:

enter image description here

..and this expanded image:

enter image description here

Update

As Foad's answer looks more elegant, I tried his proposed solution for a ReDoc Markup with no success.

like image 13
pme Avatar answered Nov 07 '22 09:11

pme