Move json documentation generation from keybindings to documentation engine

This commit is contained in:
Ylva Selling
2024-02-23 16:44:22 +01:00
parent 94aa098457
commit 126c62dc3a
5 changed files with 24 additions and 23 deletions
@@ -90,6 +90,7 @@ public:
nlohmann::json generateScriptEngineJson() const;
nlohmann::json generateFactoryManagerJson() const;
nlohmann::json generateKeybindingsJson() const;
private:
/// The list of all Documentation%s that are stored by the DocumentationEngine
std::vector<Documentation> _documentations;
@@ -53,8 +53,6 @@ public:
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
nlohmann::json generateJson() const;
const std::multimap<KeyWithModifier, std::string>& keyBindings() const;
private:
@@ -53,10 +53,10 @@ void DocumentationTopic::handleJson(const nlohmann::json& json) {
response = DocEng.generateFactoryManagerJson();
}
else if (requestedType == "keyboard") {
response = global::keybindingManager->generateJson();
response = DocEng.generateKeybindingsJson();
}
else if (requestedType == "asset") {
response = global::keybindingManager->generateJson();
// TODO: Add asset documentation here
}
else if (requestedType == "meta") {
response = SceneLicenseWriter().generateJsonList();
+21
View File
@@ -281,6 +281,27 @@ nlohmann::json DocumentationEngine::generateFactoryManagerJson() const {
return result;
}
nlohmann::json DocumentationEngine::generateKeybindingsJson() const {
ZoneScoped;
nlohmann::json json;
const std::multimap<KeyWithModifier, std::string>& luaKeys =
global::keybindingManager->keyBindings();
for (const std::pair<const KeyWithModifier, std::string>& p : luaKeys) {
nlohmann::json keybind;
keybind["name"] = ghoul::to_string(p.first);
keybind["action"] = p.second;
json.push_back(std::move(keybind));
}
sortJson(json, "name");
nlohmann::json result;
result["name"] = "Keybindings";
result["keybindings"] = json;
return result;
}
void DocumentationEngine::writeDocumentation() const {
ZoneScoped;
-19
View File
@@ -115,25 +115,6 @@ const std::multimap<KeyWithModifier, std::string>& KeybindingManager::keyBinding
return _keyLua;
}
nlohmann::json KeybindingManager::generateJson() const {
ZoneScoped;
nlohmann::json json;
for (const std::pair<const KeyWithModifier, std::string>& p : _keyLua) {
nlohmann::json keybind;
keybind["name"] = ghoul::to_string(p.first);
keybind["action"] = p.second;
json.push_back(std::move(keybind));
}
sortJson(json, "name");
nlohmann::json result;
result["name"] = "Keybindings";
result["keybindings"] = json;
return result;
}
scripting::LuaLibrary KeybindingManager::luaLibrary() {
return {
"",