Assembler Use Cases
This page shares use cases that can be accomplished using 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, compiling, and publishing a book written in AsciiDoc. It provides the means for creating and incorporating downloadable export formats (e.g., PDF, EPUB, etc.) and publishing them alongside your website.
Regardless of how you choose to partition the content for your book, Assembler can help reassemble that content to create a publication while still being able to publish it as a website.
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. Assembler can handle it either way.
As a rule of thumb, any top-level section in the assembly should be a page. Therefore, if your book has parts, then each part (or part-like section) should be a page (and tagged as a part). If your book does not have parts, then each chapter (or chapter-like section) should be a page.
Assembler can support a book defined in a single AsciiDoc file, but only if it’s the root page, the root level of the assembly is 0, the nav file is empty, and the assembly-style attribute is unset.
(You can use an assembly profile to define an empty nav file if you still want navigation in the site).
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 each export. Of course, you’ll want to enable the automatic toc as well.
assembly:
section_merge_strategy: fuse
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 can optionally create a root page (typically the start page) to define assembly header attributes (such as authors) and/or the preface. In the simplest case, the start page repeats the book title.
= {page-component-title}
Author Name
If the start page serves as the preface, and you want the preface to have a title, then set the preface-title (or assembly-navtitle) attribute.
= {page-component-title}
Author Name
:preface-title: The Preface Title
The text for the preface.
The assembly style of the root page of a root level 0 assembly with fused sections defaults to preface unless otherwise specified by the assembly-style attribute.
If the root page is a preface, the preface will not have a title unless the preface-title or assembly-navtitle attribute is set.
The preface-title attribute can have an empty value.
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.
| If you’re making an index section, you’re encouraged to name the file of the page something other than index.adoc, such as book-index.adoc or index.adoc_. That’s because the filename index.adoc has special meaning in web publishing. |
Any roles and options on the document are propagated to the section in the assembly, so you can use them in the normal way.
[.reference%nonfacing]
= Command Line Interface
:assembly-style: appendix
== Commands
The list of tasks...
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:preface.adoc[]
* 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[]
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 uncomment the reference to this new page in the nav file provided earlier.
If you prefer to have the root page act as the preface, you can additionally specify the preface title using the preface-title attribute.
= {page-component-title}
Author Name
:assembly-style: preface-part
:preface-title: Preface
Your journey begins here.
The assembly style of the root page of a root level 0 assembly with fused sections defaults to preface unless otherwise specified by the assembly-style attribute.
If the root page is a preface, the preface will not have a title unless the preface-title or assembly-navtitle attribute is set.
The preface-title attribute can have an empty value.