From a668f08f0321dc770692b8c0137ba5bf8c4b80cf Mon Sep 17 00:00:00 2001 From: Ylva Selling Date: Wed, 26 Apr 2023 13:33:39 -0400 Subject: [PATCH] Make documentation file use camelCase for the keys --- src/engine/openspaceengine.cpp | 3 ++- src/interaction/keybindingmanager.cpp | 2 +- src/properties/propertyowner.cpp | 26 +++++++++--------- src/scene/scenelicensewriter.cpp | 8 +++--- src/util/factorymanager.cpp | 38 ++++++++++++++------------- 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index e2b653aff7..910548f138 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1056,8 +1056,9 @@ void OpenSpaceEngine::writeDocumentation() { nlohmann::json sceneProperties = settings.get(); nlohmann::json sceneGraph = scene.get(); - sceneProperties["data"] = "Settings"; + sceneProperties["name"] = "Settings"; sceneGraph["name"] = "Scene"; + scripting["name"] = "Scripting API"; nlohmann::json documentation = { sceneGraph, sceneProperties, keybindings, license, scripting, factory diff --git a/src/interaction/keybindingmanager.cpp b/src/interaction/keybindingmanager.cpp index cd1a1c4119..2d7eb659a3 100644 --- a/src/interaction/keybindingmanager.cpp +++ b/src/interaction/keybindingmanager.cpp @@ -146,7 +146,7 @@ nlohmann::json KeybindingManager::generateJsonJson() const { sortJson(json, "name"); nlohmann::json result; - result["name"] = "keybindings"; + result["name"] = "Keybindings"; result["keybindings"] = json; return result; } diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index d7fdc84982..418a6607d3 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -46,30 +46,30 @@ namespace { using namespace openspace; nlohmann::json json; - json["Name"] = owner->identifier(); + json["name"] = owner->identifier(); - json["Description"] = owner->description(); - json["Properties"] = nlohmann::json::array(); - json["PropertyOwners"] = nlohmann::json::array(); - json["Type"] = owner->type(); - json["Tags"] = owner->tags(); + json["description"] = owner->description(); + json["properties"] = nlohmann::json::array(); + json["propertyOwners"] = nlohmann::json::array(); + json["type"] = owner->type(); + json["tags"] = owner->tags(); const std::vector& properties = owner->properties(); for (properties::Property* p : properties) { nlohmann::json propertyJson; - propertyJson["Name"] = p->identifier(); - propertyJson["Type"] = p->className(); - propertyJson["URI"] = p->fullyQualifiedIdentifier(); - propertyJson["Gui Name"] = p->guiName(); - propertyJson["Description"] = p->description(); + propertyJson["name"] = p->identifier(); + propertyJson["type"] = p->className(); + propertyJson["uri"] = p->fullyQualifiedIdentifier(); + propertyJson["guiName"] = p->guiName(); + propertyJson["description"] = p->description(); - json["Properties"].push_back(propertyJson); + json["properties"].push_back(propertyJson); } auto propertyOwners = owner->propertySubOwners(); for (properties::PropertyOwner* o : propertyOwners) { nlohmann::json propertyOwner; - json["PropertyOwners"].push_back(createJson(o)); + json["propertyOwners"].push_back(createJson(o)); } return json; diff --git a/src/scene/scenelicensewriter.cpp b/src/scene/scenelicensewriter.cpp index c4bf514df0..8ab0eb3136 100644 --- a/src/scene/scenelicensewriter.cpp +++ b/src/scene/scenelicensewriter.cpp @@ -57,7 +57,7 @@ nlohmann::json SceneLicenseWriter::generateJsonJson() const { if (global::profile->meta.has_value()) { metaTotal++; nlohmann::json metaJson; - metaJson["name"] = "profile"; + metaJson["name"] = "Profile"; metaJson["profileName"] = global::profile->meta->name.value_or(""); metaJson["version"] = global::profile->meta->version.value_or(""); metaJson["description"] = global::profile->meta->description.value_or(""); @@ -101,8 +101,8 @@ nlohmann::json SceneLicenseWriter::generateJsonJson() const { } nlohmann::json assetsJson; - assetsJson["name"] = "assets"; - assetsJson["type"] = "licenses"; + assetsJson["name"] = "Assets"; + assetsJson["type"] = "Licenses"; for (const std::pair& assetLicense : assetLicenses) { nlohmann::json entry; @@ -114,7 +114,7 @@ nlohmann::json SceneLicenseWriter::generateJsonJson() const { json.push_back(assetsJson); nlohmann::json result; - result["name"] = "licenses"; + result["name"] = "Licenses"; result["data"] = json; return result; diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index 89aec6aa44..fe4f1a6eb9 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -45,16 +45,16 @@ using namespace openspace::documentation; nlohmann::json generateJsonDocumentation(const Documentation& d) { nlohmann::json json; - json["Name"] = d.name; - json["Identifier"] = d.id; - json["Members"] = nlohmann::json::array(); + json["name"] = d.name; + json["identifier"] = d.id; + json["members"] = nlohmann::json::array(); for (const DocumentationEntry& p : d.entries) { nlohmann::json entry; - entry["Name"] = p.key; - entry["Optional"] = p.optional.value; - entry["Type"] = p.verifier->type(); - entry["Documentation"] = p.documentation; + entry["name"] = p.key; + entry["optional"] = p.optional.value; + entry["type"] = p.verifier->type(); + entry["documentation"] = p.documentation; TableVerifier* tv = dynamic_cast(p.verifier.get()); ReferencingVerifier* rv = dynamic_cast(p.verifier.get()); @@ -68,27 +68,28 @@ nlohmann::json generateJsonDocumentation(const Documentation& d) { ); if (it == documentations.end()) { - entry["Reference"]["Found"] = false; + entry["reference"]["found"] = false; } else { nlohmann::json reference; - reference["Found"] = true; - reference["Name"] = it->name; - reference["Identifier"] = rv->identifier; + reference["found"] = true; + reference["name"] = it->name; + reference["identifier"] = rv->identifier; - entry["Reference"] = reference; + entry["reference"] = reference; } } else if (tv) { nlohmann::json json = generateJsonDocumentation(tv->documentations); // We have a TableVerifier, so we need to recurse - entry["Restrictions"] = json; + entry["restrictions"] = json; } else { - entry["Description"] = p.verifier->documentation(); + entry["description"] = p.verifier->documentation(); } - json["Members"].push_back(entry); + json["members"].push_back(entry); } + sortJson(json["members"], "name"); return json; } @@ -213,18 +214,19 @@ nlohmann::json FactoryManager::generateJsonJson() const { } // Add all leftover docs nlohmann::json leftovers; - leftovers["name"] = "other"; + leftovers["name"] = "Other"; leftovers["identifier"] = "other"; for (const Documentation& doc : docs) { leftovers["classes"].push_back(generateJsonDocumentation(doc)); } - sortJson(json["classes"]["members"], "name"); + sortJson(leftovers["classes"], "name"); json.push_back(leftovers); + sortJson(json, "name"); // I did not check the output of this for correctness ---abock nlohmann::json result; - result["name"] = "assetTypes"; + result["name"] = "Asset Types"; result["data"] = json; return result;