mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 19:39:56 -05:00
Move json documentation generation from keybindings to documentation engine
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 {
|
||||
"",
|
||||
|
||||
Reference in New Issue
Block a user