![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
Represents a structural block element in documentation. More...
#include <contentblock.h>
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< InlineContent > | inlineContent |
| Rich inline content. | |
| QList< ContentBlock > | children |
| Nested blocks. | |
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.
Definition at line 67 of file contentblock.h.
|
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.
|
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.
| QJsonObject IR::ContentBlock::attributes |
Type-specific metadata.
Definition at line 70 of file contentblock.h.
| QList<ContentBlock> IR::ContentBlock::children |
Nested blocks.
Definition at line 72 of file contentblock.h.
| QList<InlineContent> IR::ContentBlock::inlineContent |
Rich inline content.
Definition at line 71 of file contentblock.h.
| BlockType IR::ContentBlock::type { BlockType::Paragraph } |
Definition at line 69 of file contentblock.h.