-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and make use of jinja templates.
Signed-off-by: Adam Treat <[email protected]>
- Loading branch information
Showing
14 changed files
with
245 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,31 @@ | ||
#include "tool.h" | ||
|
||
#include <QJsonDocument> | ||
|
||
QJsonObject filterModelGeneratedProperties(const QJsonObject &inputObject) { | ||
QJsonObject filteredObject; | ||
for (const QString &key : inputObject.keys()) { | ||
QJsonObject propertyObject = inputObject.value(key).toObject(); | ||
if (!propertyObject.contains("modelGenerated") || propertyObject["modelGenerated"].toBool()) | ||
filteredObject.insert(key, propertyObject); | ||
} | ||
return filteredObject; | ||
} | ||
|
||
jinja2::Value Tool::jinjaValue() const | ||
{ | ||
QJsonDocument doc(filterModelGeneratedProperties(paramSchema())); | ||
QString p(doc.toJson(QJsonDocument::Compact)); | ||
|
||
QJsonDocument exampleDoc(exampleParams()); | ||
QString e(exampleDoc.toJson(QJsonDocument::Compact)); | ||
|
||
jinja2::ValuesMap params { | ||
{ "name", name().toStdString() }, | ||
{ "description", description().toStdString() }, | ||
{ "function", function().toStdString() }, | ||
{ "paramSchema", p.toStdString() }, | ||
{ "exampleParams", e.toStdString() } | ||
}; | ||
return params; | ||
} |
Oops, something went wrong.