mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 18:11:01 -05:00
Create a tiny app for writing the documentation jsons (#3239)
* Add simple app for writing the documentation (only asset components and lua scripting) * Update apps/DocsWriter/CMakeLists.txt Co-authored-by: Emma Broman <emma.broman@liu.se> * Update apps/DocsWriter/main.cpp Co-authored-by: Emma Broman <emma.broman@liu.se> * Update apps/DocsWriter/main.cpp Co-authored-by: Emma Broman <emma.broman@liu.se> * Update apps/DocsWriter/main.cpp Co-authored-by: Emma Broman <emma.broman@liu.se> * Update apps/DocsWriter/CMakeLists.txt Co-authored-by: Alexander Bock <alexander.bock@liu.se> * Update apps/DocsWriter/main.cpp Co-authored-by: Alexander Bock <alexander.bock@liu.se> * Update apps/DocsWriter/main.cpp Co-authored-by: Alexander Bock <alexander.bock@liu.se> * Update apps/DocsWriter/main.cpp Co-authored-by: Alexander Bock <alexander.bock@liu.se> --------- Co-authored-by: Ylva Selling <ylva.selling@liu.se> Co-authored-by: Emma Broman <emma.broman@liu.se> Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
##########################################################################################
|
||||
# #
|
||||
# OpenSpace #
|
||||
# #
|
||||
# Copyright (c) 2014-2024 #
|
||||
# #
|
||||
# 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. #
|
||||
##########################################################################################
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/support/cmake/application_definition.cmake)
|
||||
|
||||
create_new_application(DocsWriter
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(DocsWriter PRIVATE openspace-core openspace-module-collection)
|
||||
|
||||
# Web Browser and Web gui
|
||||
# Why not put these in the module's path? Because they do not have access to the
|
||||
# target as of July 2017, which is needed.
|
||||
if (OPENSPACE_MODULE_WEBBROWSER AND CEF_ROOT)
|
||||
# wanted by CEF
|
||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "CMAKE_BUILD_TYPE")
|
||||
|
||||
if (WIN32)
|
||||
set(RESOURCE_FILE openspace.rc)
|
||||
endif ()
|
||||
|
||||
# Add the CEF binary distribution's cmake/ directory to the module path and
|
||||
# find CEF to initialize it properly.
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${WEBBROWSER_MODULE_PATH}/cmake")
|
||||
include(webbrowser_helpers)
|
||||
|
||||
set_cef_targets("${CEF_ROOT}" DocsWriter)
|
||||
run_cef_platform_config("${CEF_ROOT}" "${CEF_TARGET}" "${WEBBROWSER_MODULE_PATH}")
|
||||
elseif (OPENSPACE_MODULE_WEBBROWSER)
|
||||
message(WARNING "Web configured to be included, but no CEF_ROOT was found, please try configuring CMake again.")
|
||||
endif ()
|
||||
@@ -0,0 +1 @@
|
||||
set(DEFAULT_APPLICATION OFF)
|
||||
@@ -0,0 +1,75 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2024 *
|
||||
* *
|
||||
* 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. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/documentation/documentationengine.h>
|
||||
#include <openspace/engine/configuration.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/engine/settings.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
using namespace openspace;
|
||||
|
||||
ghoul::logging::LogManager::initialize(
|
||||
ghoul::logging::LogLevel::Debug,
|
||||
ghoul::logging::LogManager::ImmediateFlush::Yes
|
||||
);
|
||||
|
||||
ghoul::initialize();
|
||||
global::create();
|
||||
|
||||
// In order to initialize the engine, we need to specify the tokens
|
||||
// We start by registering the path of the executable,
|
||||
// to make it possible to find other files in the same directory
|
||||
FileSys.registerPathToken(
|
||||
"${BIN}",
|
||||
std::filesystem::path(argv[0]).parent_path(),
|
||||
ghoul::filesystem::FileSystem::Override::Yes
|
||||
);
|
||||
|
||||
std::filesystem::path configFile = findConfiguration();
|
||||
|
||||
// Register the base path as the directory where the configuration file lives
|
||||
std::filesystem::path base = configFile.parent_path();
|
||||
FileSys.registerPathToken("${BASE}", base);
|
||||
|
||||
*global::configuration = loadConfigurationFromFile(
|
||||
configFile.string(),
|
||||
"",
|
||||
glm::ivec2(0)
|
||||
);
|
||||
openspace::global::openSpaceEngine->registerPathTokens();
|
||||
|
||||
// Now that we have the tokens we can initialize the engine
|
||||
global::openSpaceEngine->initialize();
|
||||
|
||||
// Print out the documentation to the documentation folder
|
||||
// @TODO (ylvse, 2024-05-02) change this directory when integrating with jenkins?
|
||||
DocEng.writeJsonDocumentation();
|
||||
|
||||
return 0;
|
||||
};
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
static DocumentationEngine& ref();
|
||||
|
||||
void writeJavascriptDocumentation() const;
|
||||
void writeJsonDocumentation() const;
|
||||
void writeJsonDocumentation(std::string folderName = "${DOCUMENTATION}") const;
|
||||
|
||||
nlohmann::json generateScriptEngineJson() const;
|
||||
nlohmann::json generateFactoryManagerJson() const;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
|
||||
<!--The compatibility section will be merged from build/win/compatibility.manifest -->
|
||||
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
</assembly>
|
||||
@@ -646,17 +646,22 @@ void DocumentationEngine::writeJavascriptDocumentation() const {
|
||||
out.close();
|
||||
}
|
||||
|
||||
void DocumentationEngine::writeJsonDocumentation() const {
|
||||
void DocumentationEngine::writeJsonDocumentation(std::string folderName) const {
|
||||
nlohmann::json factory = generateFactoryManagerJson();
|
||||
nlohmann::json scripting = generateScriptEngineJson();
|
||||
|
||||
// Write two json files for the static docs page - asset components and scripting api
|
||||
std::ofstream out = std::ofstream(absPath("${DOCUMENTATION}/assetComponents.json"));
|
||||
std::ofstream out = std::ofstream(absPath(
|
||||
std::format("{}/assetComponents.json", folderName)
|
||||
));
|
||||
if (out) {
|
||||
out << factory.dump();
|
||||
}
|
||||
out.close();
|
||||
out.open(absPath("${DOCUMENTATION}/scriptingApi.json"));
|
||||
|
||||
out.open(absPath(
|
||||
std::format("{}/scriptingApi.json", folderName)
|
||||
));
|
||||
if (out) {
|
||||
out << scripting.dump();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user