Search code examples
asciidocasciidoctor

AsciiDoc conditionally include sections depending on compiler options


I'm trying to introduce AsciiDoc at work. One of the issues that my colleagues see is that they want to hide certain sections when generating the documentation for the customer.

Basically the idea is to have a documentation that is the same for the customer and us, but we can see more.

Is there a way to include sections conditionally, e.g. by adding compile switches to the command asciidoctor doc.adoc -CUSTOMERDOC

And then have:

#ifndef CUSTOMERDOC
== INTERNAL detailed description
asdsa
#endif

Solution

  • Yes such a feature exists at least for asiidoctor. https://asciidoctor.org/docs/user-manual/#conditional-preprocessor-directives Example stolen from documentation:

    ifdef::stackoverflow[]
    This content is for stackoverflow.
    endif::[]