From d267bc0dadd1b29a4533c95ef623f48cdc7f13ea Mon Sep 17 00:00:00 2001 From: Ylva Selling Date: Tue, 25 Apr 2023 16:44:10 -0400 Subject: [PATCH] Remove documentation generator --- .../documentation/documentationengine.h | 4 +- .../documentation/documentationgenerator.h | 89 ------------------- .../openspace/interaction/keybindingmanager.h | 4 +- include/openspace/mission/missionmanager.h | 1 - include/openspace/properties/propertyowner.h | 6 +- include/openspace/scene/scenelicensewriter.h | 4 +- include/openspace/scripting/scriptengine.h | 3 +- include/openspace/util/factorymanager.h | 4 +- src/CMakeLists.txt | 2 - src/documentation/documentationengine.cpp | 7 +- src/documentation/documentationgenerator.cpp | 24 ----- src/engine/openspaceengine.cpp | 4 +- src/interaction/keybindingmanager.cpp | 9 +- src/properties/propertyowner.cpp | 10 +-- src/scene/scenelicensewriter.cpp | 11 +-- src/scripting/scriptengine.cpp | 13 +-- src/util/factorymanager.cpp | 11 +-- 17 files changed, 24 insertions(+), 182 deletions(-) delete mode 100644 include/openspace/documentation/documentationgenerator.h diff --git a/include/openspace/documentation/documentationengine.h b/include/openspace/documentation/documentationengine.h index 1be6497f01..88ec3042c7 100644 --- a/include/openspace/documentation/documentationengine.h +++ b/include/openspace/documentation/documentationengine.h @@ -25,8 +25,6 @@ #ifndef __OPENSPACE_CORE___DOCUMENTATIONENGINE___H__ #define __OPENSPACE_CORE___DOCUMENTATIONENGINE___H__ -#include - #include #include #include @@ -38,7 +36,7 @@ namespace openspace::documentation { * produced in the application an write them out as a documentation file for human * consumption. */ -class DocumentationEngine : public DocumentationGenerator { +class DocumentationEngine { public: /** * This exception is thrown by the addDocumentation method if a provided Documentation diff --git a/include/openspace/documentation/documentationgenerator.h b/include/openspace/documentation/documentationgenerator.h deleted file mode 100644 index 3d6e2c7b66..0000000000 --- a/include/openspace/documentation/documentationgenerator.h +++ /dev/null @@ -1,89 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2023 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_CORE___DOCUMENTATIONGENERATOR___H__ -#define __OPENSPACE_CORE___DOCUMENTATIONGENERATOR___H__ - -#include -#include -#include - -namespace openspace { - -/* - * This abstract class is used for instances when another class has the ability to - * generate a Handlebar generated documentation file that contains valuable information - * for the user. Instances of this are the DocumentationEngine results, the list of - * Property%s generated by the Scene, or the FactoryEngine results. The documentation is - * generated through the writeDocumentation method. - * - * The concrete subclass needs to overload the generateJson class that will return the - * Json that is parsed by Handlebar to generate the webpage. - * - * A list of Handlebar templates, the variable name for the result of the generateJson - * method, and the Javascript file that contains additional logic is passed in the - * constructor. - */ -class DocumentationGenerator { -public: - static const std::string NameTag; - static const std::string DataTag; - /** - * The constructor that is used to set the member variables later used in the - * writeDocumentation method. - * - * \param name The name of the written documentation - * \param jsonName The variable name of the value generated by the generateJson - * - * \pre name must not be empty - * \pre jsonName must not be empty - * \pre javascriptFilename must not be empty - */ - DocumentationGenerator(std::string name, std::string jsonName); - - /// Default constructor - virtual ~DocumentationGenerator() = default; - - //getter for identifier - std::string jsonName(); - - /** - * This abstract method is used by concrete subclasses to provide the actual data that - * is used in the documentation written by this DocumentationGenerator class. The JSON - * string returned by this function will be stored in the variable with the - * `jsonName` as passed in the constructor. - * - * \return A JSON script that is parsed and stored in the variable passed in the - * DocumentationGenerator constructor - */ - virtual std::string generateJson() const = 0; - -private: - const std::string _name; - const std::string _jsonName; -}; - -} // namespace openspace - -#endif // __OPENSPACE_CORE___DOCUMENTATIONGENERATOR___H__ diff --git a/include/openspace/interaction/keybindingmanager.h b/include/openspace/interaction/keybindingmanager.h index f036a9b3f6..55f0e3ae9e 100644 --- a/include/openspace/interaction/keybindingmanager.h +++ b/include/openspace/interaction/keybindingmanager.h @@ -25,8 +25,6 @@ #ifndef __OPENSPACE_CORE___KEYBINDINGMANAGER___H__ #define __OPENSPACE_CORE___KEYBINDINGMANAGER___H__ -#include - #include namespace openspace { @@ -38,7 +36,7 @@ namespace openspace::scripting { struct LuaLibrary; } namespace openspace::interaction { -class KeybindingManager : public DocumentationGenerator { +class KeybindingManager { public: KeybindingManager(); diff --git a/include/openspace/mission/missionmanager.h b/include/openspace/mission/missionmanager.h index 3918a4c29c..4942941853 100644 --- a/include/openspace/mission/missionmanager.h +++ b/include/openspace/mission/missionmanager.h @@ -25,7 +25,6 @@ #ifndef __OPENSPACE_CORE___MISSIONMANAGER___H__ #define __OPENSPACE_CORE___MISSIONMANAGER___H__ -#include #include #include diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index 6c4599613b..81b199808b 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -25,8 +25,6 @@ #ifndef __OPENSPACE_CORE___PROPERTYOWNER___H__ #define __OPENSPACE_CORE___PROPERTYOWNER___H__ -#include - #include #include #include @@ -49,7 +47,7 @@ class Property; * (`.`), the first name before the separator will be used as a subOwner's name and the * search will proceed recursively. */ -class PropertyOwner : public DocumentationGenerator { +class PropertyOwner { public: /// The separator that is used while accessing the properties and/or sub-owners static constexpr char URISeparator = '.'; @@ -76,7 +74,7 @@ public: * The destructor will remove all Propertys and PropertyOwners it owns along with * itself. */ - virtual ~PropertyOwner() override; + virtual ~PropertyOwner(); /** * Sets the identifier for this PropertyOwner. If the PropertyOwner does not have an diff --git a/include/openspace/scene/scenelicensewriter.h b/include/openspace/scene/scenelicensewriter.h index 9ed5af60c5..0438d7c4d0 100644 --- a/include/openspace/scene/scenelicensewriter.h +++ b/include/openspace/scene/scenelicensewriter.h @@ -25,14 +25,12 @@ #ifndef __OPENSPACE_CORE___SCENELICENSEWRITER___H__ #define __OPENSPACE_CORE___SCENELICENSEWRITER___H__ -#include - #include #include namespace openspace { -class SceneLicenseWriter : public DocumentationGenerator { +class SceneLicenseWriter { public: SceneLicenseWriter(); std::string generateJson() const; diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index 5d7602fbe8..11e3e54a1a 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -26,7 +26,6 @@ #define __OPENSPACE_CORE___SCRIPTENGINE___H__ #include -#include #include #include #include @@ -49,7 +48,7 @@ namespace openspace::scripting { * `openspace` namespace prefix in Lua. The same functions can be exposed to * other Lua states by passing them to the #initializeLuaState method. */ -class ScriptEngine : public Syncable, public DocumentationGenerator { +class ScriptEngine : public Syncable { public: using ScriptCallback = std::function; BooleanType(RemoteScripting); diff --git a/include/openspace/util/factorymanager.h b/include/openspace/util/factorymanager.h index 07a388f68a..bfb195341d 100644 --- a/include/openspace/util/factorymanager.h +++ b/include/openspace/util/factorymanager.h @@ -25,8 +25,6 @@ #ifndef __OPENSPACE_CORE___FACTORYMANAGER___H__ #define __OPENSPACE_CORE___FACTORYMANAGER___H__ -#include - #include #include #include @@ -39,7 +37,7 @@ namespace openspace { * them available through the #addFactory and #factory methods. Each * ghoul::TemplateFactory can only be added once and can be accessed by its type. */ -class FactoryManager : public DocumentationGenerator { +class FactoryManager { public: /// This exception is thrown if the ghoul::TemplateFactory could not be found in the /// #factory method diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a34c60fc2b..c54bb478af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,6 @@ set(OPENSPACE_SOURCE documentation/core_registration.cpp documentation/documentation.cpp documentation/documentationengine.cpp - documentation/documentationgenerator.cpp documentation/verifier.cpp engine/configuration.cpp engine/downloadmanager.cpp @@ -212,7 +211,6 @@ set(OPENSPACE_HEADER ${PROJECT_SOURCE_DIR}/include/openspace/documentation/core_registration.h ${PROJECT_SOURCE_DIR}/include/openspace/documentation/documentation.h ${PROJECT_SOURCE_DIR}/include/openspace/documentation/documentationengine.h - ${PROJECT_SOURCE_DIR}/include/openspace/documentation/documentationgenerator.h ${PROJECT_SOURCE_DIR}/include/openspace/documentation/verifier.h ${PROJECT_SOURCE_DIR}/include/openspace/documentation/verifier.inl ${PROJECT_SOURCE_DIR}/include/openspace/engine/configuration.h diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index c80149cb9d..d68286dcc4 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -55,12 +55,7 @@ DocumentationEngine::DuplicateDocumentationException::DuplicateDocumentationExce , documentation(std::move(doc)) {} -DocumentationEngine::DocumentationEngine() - : DocumentationGenerator( - "Top Level", - "toplevel" - ) -{} +DocumentationEngine::DocumentationEngine() {} void DocumentationEngine::initialize() { ghoul_assert(!isInitialized(), "DocumentationEngine is already initialized"); diff --git a/src/documentation/documentationgenerator.cpp b/src/documentation/documentationgenerator.cpp index 826f3a1b30..9b2bca2af2 100644 --- a/src/documentation/documentationgenerator.cpp +++ b/src/documentation/documentationgenerator.cpp @@ -22,32 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include - #include #include #include #include #include - -namespace openspace { - -const std::string DocumentationGenerator::DataTag = "Data"; -const std::string DocumentationGenerator::NameTag = "Name"; - -DocumentationGenerator::DocumentationGenerator(std::string name, - std::string jsonName) - : _name(std::move(name)) - , _jsonName(std::move(jsonName)) -{ - ghoul_precondition(!_name.empty(), "name must not be empty"); - ghoul_precondition(!_jsonName.empty(), "jsonName must not be empty"); -} - - -std::string DocumentationGenerator::jsonName() { - return _jsonName; -} - - -} // namespace openspace diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index cf2db1e7e6..5804763566 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1056,8 +1056,8 @@ void OpenSpaceEngine::writeDocumentation() { nlohmann::json sceneProperties = settings.get(); nlohmann::json sceneGraph = scene.get(); - sceneProperties[DocumentationGenerator::NameTag] = "Settings"; - sceneGraph[DocumentationGenerator::NameTag] = "Scene"; + sceneProperties["Data"] = "Settings"; + sceneGraph["Name"] = "Scene"; nlohmann::json documentation = { sceneGraph, sceneProperties, keybindings, license, scripting, factory diff --git a/src/interaction/keybindingmanager.cpp b/src/interaction/keybindingmanager.cpp index 498afeba94..6018d9d351 100644 --- a/src/interaction/keybindingmanager.cpp +++ b/src/interaction/keybindingmanager.cpp @@ -38,12 +38,7 @@ namespace openspace::interaction { -KeybindingManager::KeybindingManager() - : DocumentationGenerator( - "Keybindings", - "keybinding" - ) -{} +KeybindingManager::KeybindingManager() {} void KeybindingManager::keyboardCallback(Key key, KeyModifier modifier, KeyAction action) { @@ -151,7 +146,7 @@ nlohmann::json KeybindingManager::generateJsonJson() const { sortJson(json, "Name"); nlohmann::json result; - result[NameTag] = "Keybindings"; + result["Name"] = "Keybindings"; result["Keybindings"] = json; return result; } diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index e019dc15ef..e743a0cd01 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -79,11 +79,7 @@ namespace { namespace openspace::properties { PropertyOwner::PropertyOwner(PropertyOwnerInfo info) - : DocumentationGenerator( - "Property Owners", - "propertyOwners" - ) - , _identifier(std::move(info.identifier)) + : _identifier(std::move(info.identifier)) , _guiName(std::move(info.guiName)) , _description(std::move(info.description)) { @@ -416,8 +412,8 @@ nlohmann::json PropertyOwner::generateJsonJson() const { sortJson(json, "Name"); nlohmann::json result; - result[NameTag] = "PropertyOwner"; - result[DataTag] = json; + result["Name"] = "PropertyOwner"; + result["Data"] = json; return result; } diff --git a/src/scene/scenelicensewriter.cpp b/src/scene/scenelicensewriter.cpp index f9067692f8..85ba365d45 100644 --- a/src/scene/scenelicensewriter.cpp +++ b/src/scene/scenelicensewriter.cpp @@ -36,12 +36,7 @@ namespace openspace { -SceneLicenseWriter::SceneLicenseWriter() - : DocumentationGenerator( - "Scene Licenses", - "sceneLicense" - ) -{} +SceneLicenseWriter::SceneLicenseWriter() {} nlohmann::json SceneLicenseWriter::generateJsonJson() const { nlohmann::json json; @@ -119,8 +114,8 @@ nlohmann::json SceneLicenseWriter::generateJsonJson() const { json.push_back(assetsJson); nlohmann::json result; - result[NameTag] = "Licenses"; - result[DataTag] = json; + result["Name"] = "Licenses"; + result["Data"] = json; return result; } diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index 1d559ee7fd..ff48510f30 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -191,14 +191,7 @@ namespace { namespace openspace::scripting { -ScriptEngine::ScriptEngine() - : DocumentationGenerator( - "Script Documentation", - "scripting" - ) -{ - //tracy::LuaRegister(_state); -} +ScriptEngine::ScriptEngine() {} void ScriptEngine::initialize() { ZoneScoped; @@ -577,8 +570,8 @@ nlohmann::json ScriptEngine::generateJsonJson() const { } nlohmann::json result; - result[NameTag] = "Scripting API"; - result[DataTag] = json; + result["Name"] = "Scripting API"; + result["Data"] = json; return result; } diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp index c03c8e7d7d..e63905a94a 100644 --- a/src/util/factorymanager.cpp +++ b/src/util/factorymanager.cpp @@ -105,12 +105,7 @@ FactoryManager::FactoryNotFoundError::FactoryNotFoundError(std::string t) ghoul_assert(!type.empty(), "Type must not be empty"); } -FactoryManager::FactoryManager() - : DocumentationGenerator( - "Factory Documentation", - "factory" - ) -{} +FactoryManager::FactoryManager() {} void FactoryManager::initialize() { ghoul_assert(!_manager, "Factory Manager must not have been initialized"); @@ -229,8 +224,8 @@ nlohmann::json FactoryManager::generateJsonJson() const { // I did not check the output of this for correctness ---abock nlohmann::json result; - result[NameTag] = "Asset Types"; - result[DataTag] = json; + result["Name"] = "Asset Types"; + result["Data"] = json; return result; }