MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / getScriptingDocs

Method getScriptingDocs

app/src/AI/ToolDispatcher.cpp:2366–2400  ·  view source on GitHub ↗

* @brief Returns the markdown reference body for the given scripting kind. */

Source from the content-addressed store, hash-verified

2364 * @brief Returns the markdown reference body for the given scripting kind.
2365 */
2366QJsonObject AI::ToolDispatcher::getScriptingDocs(const QString& kind) const
2367{
2368 static const QStringList kAllowed = {
2369 QStringLiteral("frame_parser_js"),
2370 QStringLiteral("frame_parser_lua"),
2371 QStringLiteral("transform_js"),
2372 QStringLiteral("transform_lua"),
2373 QStringLiteral("output_widget_js"),
2374 QStringLiteral("painter_js"),
2375 QStringLiteral("control_script_js"),
2376 };
2377
2378 QJsonObject reply;
2379 if (!kAllowed.contains(kind)) {
2380 reply[QStringLiteral("ok")] = false;
2381 reply[QStringLiteral("error")] = QStringLiteral("unknown_kind");
2382 reply[QStringLiteral("known")] = QJsonArray::fromStringList(kAllowed);
2383 return reply;
2384 }
2385
2386 QFile file(QStringLiteral(":/ai/docs/%1.md").arg(kind));
2387 if (!file.open(QIODevice::ReadOnly)) {
2388 reply[QStringLiteral("ok")] = false;
2389 reply[QStringLiteral("error")] = QStringLiteral("doc_not_found");
2390 return reply;
2391 }
2392
2393 const auto body = QString::fromUtf8(file.readAll());
2394 file.close();
2395
2396 reply[QStringLiteral("ok")] = true;
2397 reply[QStringLiteral("kind")] = kind;
2398 reply[QStringLiteral("body")] = body;
2399 return reply;
2400}

Callers

nothing calls this directly

Calls 3

containsMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected