diff --git a/include/openspace/documentation/documentationengine.h b/include/openspace/documentation/documentationengine.h index 17a9bb0991..cf9dbeff45 100644 --- a/include/openspace/documentation/documentationengine.h +++ b/include/openspace/documentation/documentationengine.h @@ -87,7 +87,8 @@ public: */ static DocumentationEngine& ref(); - void writeDocumentation() const; + void writeJavascriptDocumentation() const; + void writeJsonDocumentation() const; nlohmann::json generateScriptEngineJson() const; nlohmann::json generateFactoryManagerJson() const; diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index 5c69c9ba3e..904582cfa6 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -552,12 +552,7 @@ nlohmann::json DocumentationEngine::generateFactoryManagerJson() const { json.push_back(leftovers); sortJson(json, NameKey); - // I did not check the output of this for correctness ---abock - nlohmann::json result; - result[NameKey] = FactoryTitle; - result[DataKey] = json; - - return result; + return json; } nlohmann::json DocumentationEngine::generateKeybindingsJson() const { @@ -606,7 +601,7 @@ nlohmann::json DocumentationEngine::generatePropertyOwnerJson( return result; } -void DocumentationEngine::writeDocumentation() const { +void DocumentationEngine::writeJavascriptDocumentation() const { ZoneScoped; // Write documentation to json files if config file supplies path for doc files @@ -628,8 +623,6 @@ void DocumentationEngine::writeDocumentation() const { global::renderEngine->scene() ); - nlohmann::json scripting = generateScriptEngineJson(); - nlohmann::json factory = generateFactoryManagerJson(); nlohmann::json keybindings = generateKeybindingsJson(); nlohmann::json license = generateLicenseGroupsJson(); nlohmann::json sceneProperties = settings.get(); @@ -640,12 +633,6 @@ void DocumentationEngine::writeDocumentation() const { sceneProperties[NameKey] = SettingsTitle; sceneGraph[NameKey] = SceneTitle; - // Add this here so that the generateJson function is the same as before to ensure - // backwards compatibility - nlohmann::json scriptingResult; - scriptingResult[NameKey] = ScriptingTitle; - scriptingResult[DataKey] = scripting; - nlohmann::json documentation = { sceneGraph, sceneProperties, actions, events, keybindings, license }; @@ -657,16 +644,21 @@ void DocumentationEngine::writeDocumentation() const { std::ofstream out = std::ofstream(absPath("${DOCUMENTATION}/documentationData.js")); out << "var data = " << result.dump(); out.close(); +} + +void DocumentationEngine::writeJsonDocumentation() const { + nlohmann::json factory = generateFactoryManagerJson(); + nlohmann::json scripting = generateScriptEngineJson(); // Write two json files for the static docs page - asset components and scripting api - out.open(absPath("${DOCUMENTATION}/assetComponents.json")); + std::ofstream out = std::ofstream(absPath("${DOCUMENTATION}/assetComponents.json")); if (out) { out << factory.dump(); } out.close(); out.open(absPath("${DOCUMENTATION}/scriptingApi.json")); if (out) { - out << scriptingResult.dump(); + out << scripting.dump(); } out.close(); } diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index cf91a8cf1c..04a5021b09 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -806,7 +806,7 @@ void OpenSpaceEngine::loadAssets() { runGlobalCustomizationScripts(); _writeDocumentationTask = std::async( - &documentation::DocumentationEngine::writeDocumentation, + &documentation::DocumentationEngine::writeJavascriptDocumentation, DocEng ); diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index 031eaa5193..616e64446b 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -39,7 +39,7 @@ namespace { * Writes out documentation files */ [[codegen::luawrap]] void writeDocumentation() { - DocEng.writeDocumentation(); + DocEng.writeJavascriptDocumentation(); } // Sets the folder used for storing screenshots or session recording frames