Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
IR::ContentBlock Struct Reference

Represents a structural block element in documentation. More...

#include <contentblock.h>

Collaboration diagram for IR::ContentBlock:

Public Member Functions

QJsonObject toJson () const
 Converts the ContentBlock to a QJsonObject for template rendering.
QString plainText () const
 Returns the concatenated plain text of this block's inline content or child blocks, recursively.

Public Attributes

BlockType type { BlockType::Paragraph }
QJsonObject attributes
 Type-specific metadata.
QList< InlineContentinlineContent
 Rich inline content.
QList< ContentBlockchildren
 Nested blocks.

Detailed Description

Represents a structural block element in documentation.

ContentBlock is a format-agnostic representation of documentation structure. Each block is either a {leaf block} (has inlineContent, no children) or a {container block} (has children, no inlineContent). This invariant is enforced by Q_ASSERT in debug builds. Typically, content-bearing blocks such as Paragraph, CodeBlock, and SectionHeading are leaves, while structural blocks such as List, Section, and callout blocks (Note, Warning, etc.) are containers.

The attributes field holds type-specific metadata as a QJsonObject. Attribute keys use camelCase for compatibility with Inja dot notation in templates (e.g., {block.attributes.listType}). Type IDs in the type field use kebab-case (e.g., {"code-block"}).

This is a pure value type with no dependencies on QDoc's core infrastructure. It belongs in QDocLib. Multiple renderers can read the same ContentBlock concurrently — the frozen IR design supports parallel rendering per output format.

See also
InlineContent, InlineType

Definition at line 67 of file contentblock.h.

Member Function Documentation

◆ plainText()

QString IR::ContentBlock::plainText ( ) const
nodiscard

Returns the concatenated plain text of this block's inline content or child blocks, recursively.

For leaf blocks with inline content (paragraphs, headings), concatenates all inline text. For container blocks (lists, sections), concatenates the plain text of child blocks separated by newlines.

Definition at line 278 of file contentblock.cpp.

◆ toJson()

QJsonObject IR::ContentBlock::toJson ( ) const
nodiscard

Converts the ContentBlock to a QJsonObject for template rendering.

The JSON uses kebab-case type IDs. A computed text key contains the concatenated plain text of all inline content or children. Empty collections (inlines, children, attributes) are omitted.

Definition at line 242 of file contentblock.cpp.

Member Data Documentation

◆ attributes

QJsonObject IR::ContentBlock::attributes

Type-specific metadata.

Definition at line 70 of file contentblock.h.

◆ children

QList<ContentBlock> IR::ContentBlock::children

Nested blocks.

Definition at line 72 of file contentblock.h.

◆ inlineContent

QList<InlineContent> IR::ContentBlock::inlineContent

Rich inline content.

Definition at line 71 of file contentblock.h.

◆ type

BlockType IR::ContentBlock::type { BlockType::Paragraph }

Definition at line 69 of file contentblock.h.


The documentation for this struct was generated from the following files: