Purpose
This page explains the Ceradoc Document Model - the Ruby object representation of AsciiDoc documents. You’ll learn about the model classes, their relationships, and how to work with them programmatically.
Overview
The Document Model represents AsciiDoc structure as Ruby objects. Every element in an AsciiDoc document has a corresponding model class. All model classes inherit from Ceradoc::Model::Base.
Core Model Classes
Document
The root container for all document content.
Ceradoc::Model::Document
├── header: Header
├── document_attributes: DocumentAttributes
└── sections: Array<Section>doc = Ceradoc.parse("= Title\n\nContent")
doc.class # => Ceradoc::Model::DocumentHeader
Document metadata including title, author, and revision information.
Ceradoc::Model::Header
├── title: String
├── author: Array<Author>
└── revision: Revisiondoc.header.title # Document title
doc.header.author&.first # First author, if present
doc.header.revision # Revision informationSection
Hierarchical sections organizing document content.
Ceradoc::Model::Section
├── title: Title
├── sections: Array<Section> # Nested sections
├── paragraphs: Array<Paragraph>
└── blocks: Array<Block>section = Ceradoc::Model::Section.new
section.title = Ceradoc::Model::Title.new
section.title.level_int = 2
section.title.content = ["Chapter 1"]
# Add paragraphs
para = Ceradoc::Model::Paragraph.new
para.content = [Ceradoc::Model::TextElement.new("Content here")]
section.blocks = [para]Title
Section or block title with level information.
Ceradoc::Model::Title
├── level_int: Integer
└── content: Array<String>Paragraph
Text paragraph containing inline elements.
Ceradoc::Model::Paragraph
├── content: Array<TextElement | Inline>
└── attributes: AttributeListpara = Ceradoc::Model::Paragraph.new
# Add mixed content
para.content = [
Ceradoc::Model::TextElement.new("Regular text"),
Ceradoc::Model::Inline::Bold.new,
Ceradoc::Model::Inline::Link.new(path: "https://example.com"),
]
# Add attributes
para.attributes = Ceradoc::Model::AttributeList.new
para.attributes.add_named("id", "para1")Block Classes
Blocks are delimited content sections like code listings and quotes.
Block::Core
Base class for all delimited blocks.
Ceradoc::Model::Block::Core
├── delimiter_char: String
├── delimiter_len: Integer
├── lines: Array<String>
└── attributes: AttributeListBlock Types
-
Block::Listing- Code listing block -
Block::Literal- Literal text block -
Block::Example- Example block -
Block::Quote- Quoted text block -
Block::Pass- Pass-through content
# Create a listing block
listing = Ceradoc::Model::Block::Listing.new
listing.lines = ["def hello", " puts 'world'", "end"]
listing.attributes = Ceradoc::Model::AttributeList.new
listing.attributes.add_positional("ruby")List Classes
Lists organize items hierarchically.
List Types
-
List::Unordered- Bulleted list (*) -
List::Ordered- Numbered list (.) -
List::Definition- Definition list (::)
# Unordered list
list = Ceradoc::Model::List::Unordered.new
item = Ceradoc::Model::ListItem.new
item.content = [Ceradoc::Model::TextElement.new("First item")]
list.items << item
# Ordered list
ordered = Ceradoc::Model::List::Ordered.new
item = Ceradoc::Model::ListItem.new
item.content = [Ceradoc::Model::TextElement.new("Step one")]
ordered.items << item
# Definition list
definition = Ceradoc::Model::List::Definition.new
def_item = Ceradoc::Model::List::DefinitionItem.new
def_item.terms = [Ceradoc::Model::Term.new(term: "Ruby", type: "language")]
def_item.contents = [Ceradoc::Model::TextElement.new("A programming language")]
definition.items << def_itemTable Classes
Tables represent tabular data.
Ceradoc::Model::Table
├── rows: Array<TableRow>
└── attributes: AttributeList
Ceradoc::Model::TableRow
└── columns: Array<TableCell>
Ceradoc::Model::TableCell
└── content: Array<TextElement | Inline>table = Ceradoc::Model::Table.new
row = Ceradoc::Model::TableRow.new
cell = Ceradoc::Model::TableCell.new
cell.content = [Ceradoc::Model::TextElement.new("Cell content")]
row.columns << cell
table.rows << rowInline Classes
Inline elements represent text formatting within blocks.
Inline Types
-
Inline::Bold- Bold text (text) -
Inline::Italic- Italic text (text) -
Inline::Monospace- Monospace text ()text -
Inline::Link- Hyperlink (label)
# Bold text
bold = Ceradoc::Model::Inline::Bold.new
bold.content = "Important text"
# Links
link = Ceradoc::Model::Inline::Link.new
link.path = "https://example.com"
link.name = "Example"
# Anchors (cross-reference targets)
anchor = Ceradoc::Model::Inline::Anchor.new
anchor.id = "section1"Helper Classes
Working with the Model
Related Documentation
-
Architecture - Model hierarchy diagrams
-
Model Classes Reference - Complete catalog
-
Document Modeling Tutorial - Hands-on examples
-
API Reference - Model class API
Bibliography
-
lutaml-model - Model definition framework