![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
Adapter for converting Qt JSON types to Inja template engine format. More...
#include <injabridge.h>
Static Public Member Functions | |
| static nlohmann::json | toInjaJson (const QJsonValue &value) |
| Converts a QJsonValue, value, to nlohmann::json. | |
| static nlohmann::json | toInjaJson (const QJsonObject &obj) |
| Converts a QJsonObject, obj, to nlohmann::json. | |
| static nlohmann::json | toInjaJson (const QJsonArray &array) |
| Converts a QJsonArray, array, to nlohmann::json. | |
| static QString | render (const QString &templateStr, const QJsonObject &data) |
| Renders a template string, templateStr, with provided data. | |
| static QString | renderFile (const QString &templatePath, const QJsonObject &data) |
| Renders a template file with provided data. | |
Adapter for converting Qt JSON types to Inja template engine format.
InjaBridge provides static methods to convert between Qt's native JSON types (QJsonObject, QJsonArray, QJsonValue) and nlohmann::json, which is the data format expected by the Inja template engine.
This adapter allows QDoc to maintain its Qt-native API while leveraging Inja for template-based documentation generation. All JSON data in QDoc's intermediate representation (IR) uses Qt types, and InjaBridge handles the conversion when rendering templates.
{-fno-exceptions}), so such errors are treated as fatal and will terminate the process. This is consistent with Qt's no-exception policy for command-line tools.Definition at line 16 of file injabridge.h.
|
static |
Renders a template string, templateStr, with provided data.
Uses Inja to render the template with the given JSON data. The data is automatically converted from QJsonObject to nlohmann::json.
The Inja template string, templateStr, supports Jinja2 syntax. data is the JSON data to use for rendering.
Returns the rendered template as a QString.
Definition at line 109 of file injabridge.cpp.
|
static |
Renders a template file with provided data.
Loads and renders a template from the filesystem, using templatePath which holds the absolute path to the template file. The file should use Inja/Jinja2 syntax. data is the JSON data to use for rendering.
Returns the rendered template as a QString.
Definition at line 129 of file injabridge.cpp.
|
static |
Converts a QJsonArray, array, to nlohmann::json.
Recursively converts all elements in the array, preserving order. Mixed-type arrays are supported.
Returns the equivalent nlohmann::json array.
Definition at line 88 of file injabridge.cpp.
|
static |
Converts a QJsonObject, obj, to nlohmann::json.
Recursively converts all values in the object, preserving the key-value structure. Nested objects and arrays are handled correctly.
Returns the equivalent nlohmann::json object.
Definition at line 70 of file injabridge.cpp.
|
static |
Converts a QJsonValue, value, to nlohmann::json.
Handles all QJsonValue types: Null, Bool, Double, String, Array, Object, and Undefined. Undefined values are treated as null.
Returns the equivalent nlohmann::json representation.
Definition at line 41 of file injabridge.cpp.