Gradle/AsciiDoctor: Combining all AsciiDoc files in one?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Gradle/AsciiDoctor: Combining all AsciiDoc files in one?

bodiam
Hi all,

I'm using the Gradle AsciiDoctor plugin, and I have a setup like the Griffon setup, where I have one AsciiDoc file, called index.adoc, and I use the include directive to import all other adoc files individually. However I create a couple of new AsciiDoc files every day for this project, and having to manually add them to the index.adoc is getting a bit cumbersome, especially since I also sometimes forget to add them. To fix this, I have a bash script in place to generate the index.adoc, but, while it works, it doesn't feel like the right approach.

So, I was wondering if there is a way to combine all adoc files in a directory without having to use explicit includes? Either with some AsciiDoc directive or with the Gradle support?

Thanks,

Erik
Reply | Threaded
Open this post in threaded view
|

Re: Gradle/AsciiDoctor: Combining all AsciiDoc files in one?

mojavelinux
Administrator

On Thu, Jul 30, 2015 at 6:33 AM, bodiam [via Asciidoctor :: Discussion] <[hidden email]> wrote:
So, I was wondering if there is a way to combine all adoc files in a directory without having to use explicit includes? Either with some AsciiDoc directive or with the Gradle support?

Sounds to me like a good case for a preprocessor. A preprocessor takes and input document (which can be blank) and returns a new reader which may contain any content you feed it. You could scan for files, read them and aggregate them into the reader. In particular, you'll be interested in the "push_include" method which emulates the behavior of an include directive.

What you need is an example. See:


Cheers,

-Dan
Reply | Threaded
Open this post in threaded view
|

Re: Gradle/AsciiDoctor: Combining all AsciiDoc files in one?

mojavelinux
Administrator
In reply to this post by bodiam
You can write extensions inline in your Gradle build, btw.


You'll want "preprocessor" as the DSL stanza.

For example:

extensions {
  preprocessor { doc, reader ->
    // do stuff
    reader
  }
}

You'll have to work around some issues until AsciidoctorJ 1.6.0...or you could try a snapshot (which is now available).

Cheers,

-Dan

On Thu, Jul 30, 2015 at 4:55 PM, Dan Allen <[hidden email]> wrote:

On Thu, Jul 30, 2015 at 6:33 AM, bodiam [via Asciidoctor :: Discussion] <[hidden email]> wrote:
So, I was wondering if there is a way to combine all adoc files in a directory without having to use explicit includes? Either with some AsciiDoc directive or with the Gradle support?

Sounds to me like a good case for a preprocessor. A preprocessor takes and input document (which can be blank) and returns a new reader which may contain any content you feed it. You could scan for files, read them and aggregate them into the reader. In particular, you'll be interested in the "push_include" method which emulates the behavior of an include directive.

What you need is an example. See:


Cheers,

-Dan



--