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::InlineContent Struct Reference

Represents inline content within a documentation block. More...

#include <contentblock.h>

Collaboration diagram for IR::InlineContent:

Public Member Functions

QJsonObject toJson () const
 Converts the InlineContent to a QJsonObject for template rendering.
QString plainText () const
 Returns the concatenated plain text of this inline element and all its children, recursively.

Public Attributes

InlineType type { InlineType::Text }
QString text
 Text content.
QString href
 Link target or image source.
QString title
 Link tooltip or image alt text.
QList< InlineContentchildren
 Nested inline content.

Detailed Description

Represents inline content within a documentation block.

InlineContent is a format-agnostic representation of inline content such as text, code, links, and formatting. Instances nest recursively to represent formatting like bold text containing a link.

Each element is either a leaf (has text, no children) or a container (has children, no text). This invariant is enforced by Q_ASSERT in debug builds. Typically, content-bearing types such as Text, Code, and Image are leaves, while formatting types such as Bold, Italic, and Link are containers whose children carry the text.

The href and title fields are metadata that can be set on either leaf or container elements (e.g., Link uses href with children; Image uses href as a leaf).

This is a pure value type with no dependencies on QDoc's core infrastructure. It belongs in QDocLib.

See also
ContentBlock, BlockType

Definition at line 33 of file contentblock.h.

Member Function Documentation

◆ plainText()

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

Returns the concatenated plain text of this inline element and all its children, recursively.

For leaf elements (Text, Code, Keyword, Target, Parameter, Image), returns the text field. For LineBreak, returns a newline character. For container elements (Bold, Italic, Link, etc.), concatenates the plain text of all children.

Definition at line 218 of file contentblock.cpp.

◆ toJson()

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

Converts the InlineContent to a QJsonObject for template rendering.

The JSON uses kebab-case type IDs matching the convention in IR::Document classification. Leaf elements (no children) include a text key with their text content. Container elements (with children) omit text to avoid redundancy — the text is available in their children.

Optional fields (href, title) are omitted when empty. The children array is omitted when empty.

Definition at line 184 of file contentblock.cpp.

Member Data Documentation

◆ children

QList<InlineContent> IR::InlineContent::children

Nested inline content.

Definition at line 39 of file contentblock.h.

◆ href

QString IR::InlineContent::href

Link target or image source.

Definition at line 37 of file contentblock.h.

◆ text

QString IR::InlineContent::text

Text content.

Definition at line 36 of file contentblock.h.

◆ title

QString IR::InlineContent::title

Link tooltip or image alt text.

Definition at line 38 of file contentblock.h.

◆ type

InlineType IR::InlineContent::type { InlineType::Text }

Definition at line 35 of file contentblock.h.


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