Assembler Use Cases
This page shares use cases that can be accomplished with Assembler. Each section presents a different use case and the relevant configuration and commands you can use as a starting point.
Book Builder
Assembler is an ideal tool for organizing and building a book written in AsciiDoc. It provides the means for creating and incorporating exports of additional formats (e.g., PDF, EPUB, etc.) and publishing them alongside your website. Regardless of how you organize the content for your book, Assembler can help reassemble that content to create a publication.
Granularity of pages
When organizing your book, think about how granular you want the content on the website to be. That’s your starting point. For a shorter book, you might decide to make one page per chapter. For a longer book, you may want to split out the top-level sections of each chapter into separate pages.
The AsciiDoc include directive gives you the flexibility to chunk the source into even more fine-grained units without introducing additional pages. For instance, you might consider organizing the top-level sections as partials in the partials folder and include them into the appropriate chapter using the include directive.
IDs only have to be scoped to the granularity of an Antora page. Assembler automatically qualifies IDs when it merges pages. |
To produce a book, configure Assembler to fuse sections from each page with the hierarchy defined by the navigation. This ensures that all sections are represented in the table of contents (TOC) of the export. Of course, you’ll want to enable the automatic toc as well.
assembly:
section_merge_strategy: fuse
asciidoc:
attributes:
toc: ''
See the documentation for the fuse value for more details.
Here’s the component version descriptor for the book:
name: my-book
version: ~
title: My Book
nav:
- modules/ROOT/nav.adoc
Once you’ve decided on the granularity of your content, you can start setting up your pages and navigation.
Simple book
Let’s assume you’re going to make one page per chapter. Here’s how your navigation file might look:
* xref:chapter-1.adoc[]
* xref:chapter-2.adoc[]
* xref:chapter-3.adoc[]
* xref:appendix-a.adoc[]
* xref:appendix-b.adoc[]
You’d also create a start page, which should repeat the book title. This page can also define the authors and host the preface. This page is optional.
= {page-component-title}
Author Name
// You can add a preface here.
Here’s how the first chapter might begin:
= Introduction to Topic
== Life before topic
In the old days...
Notice that the chapter title is a level 0 document title. Assembler automatically shifts its section level, as well as those of its descendants, so it becomes a chapter in the assembly.
For the appendix, you’ll need to mark it in a special way.
That’s because AsciiDoc does not support using the block style (i.e., [appendix]
) on the document title.
Instead, you’ll use the assembly-style
document attribute to denote the special section style.
This attribute is only intended as metadata for Assembler and is not included in the assembly itself.
= Command Line Interface
:assembly-style: appendix
== Commands
The list of tasks...
You can use the assembly-style
attribute to designate any special section in a book, such as colophon
, dedication
, index
, etc.
You can now use an exporter extension such as @antora/pdf-extension to build the PDF for your book in addition to the website. If you need to produce other formats, register those corresponding extensions as well.
Multi-part book
Assembler also gives you the means of creating a multi-part book. In this case, you nest the chapter pages in the navigation under the part pages:
* xref:part-1.adoc[]
** xref:chapter-1.adoc[]
** xref:chapter-2.adoc[]
* xref:part-2.adoc[]
** xref:chapter-3.adoc[]
* xref:appendix-a.adoc[]
* xref:appendix-b.adoc[]
Assembler cana support a multi-part book defined in a single AsciiDoc file, but only if it’s the start page and the Assembler root level is 0. |
To instruct Assembler to make a part, you need to denote it using the assembly-style
attribute in that source file.
= Introducing Topic
:assembly-style: part
Set the stage...
To make the appendix chapters siblings of the last part instead of nested inside of it (but still act as chapters), you’ll once again need to make use of the assembly-style
attribute.
= Command Line Interface
:assembly-style: appendix-part
== Commands
The list of tasks...
The -part
suffix instructs Assembler to keep the document title as a level 0 section while also setting the style on that section.
(Assembler will automatically adjust the section levels under the document title so they conform to the AsciiDoc syntax rules).
If you want the special section to be added as a child of a part, don’t include the -part
suffix.
In the same way, if you want to add a special section at the level of a part anywhere else in the document, you append the -part
suffix to the style.
For example, let’s add a preface at the start of the book.
= Preface
:assembly-style: preface-part
Your journey begins here.
You’ll need to add this new page to the nav file.
Alternately, if you prefer to have the start page act as the preface, you can additionally specify the preface title using the preface-title
attribute.
= My Book
Author Name
:assembly-style: preface-part
:preface-title: Preface
Your journey begins here.
If you don’t specify the preface-title
attribute in this case, the preface will not have a title and thus won’t appear in the TOC.
An alternate approach is to define the preface title using the document title (i.e., page title).