Remove generateJson function from the DocumentationGenerator and move sortJson function to json_helper

This commit is contained in:
Ylva Selling
2023-04-25 16:32:04 -04:00
parent b8b2867a20
commit 948fdd024b
15 changed files with 51 additions and 39 deletions

View File

@@ -89,7 +89,7 @@ public:
*/
static DocumentationEngine& ref();
std::string generateJson() const override;
std::string generateJson() const;
nlohmann::json generateJsonJson() const;

View File

@@ -79,7 +79,6 @@ public:
*/
virtual std::string generateJson() const = 0;
void sortJson(nlohmann::json& json) const;
private:
const std::string _name;
const std::string _jsonName;

View File

@@ -55,7 +55,7 @@ public:
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
std::string generateJson() const override;
std::string generateJson() const;
nlohmann::json generateJsonJson() const;
const std::multimap<KeyWithModifier, std::string>& keyBindings() const;

View File

@@ -297,7 +297,7 @@ public:
void removeTag(const std::string& tag);
// Generate JSON for documentation
std::string generateJson() const override;
std::string generateJson() const;
nlohmann::json generateJsonJson() const;

View File

@@ -35,7 +35,7 @@ namespace openspace {
class SceneLicenseWriter : public DocumentationGenerator {
public:
SceneLicenseWriter();
std::string generateJson() const override;
std::string generateJson() const;
nlohmann::json generateJsonJson() const;
};

View File

@@ -95,7 +95,7 @@ public:
std::vector<std::string> allLuaFunctions() const;
std::string generateJson() const override;
std::string generateJson() const;
nlohmann::json generateJsonJson() const;
private:

View File

@@ -109,7 +109,7 @@ public:
template <class T>
ghoul::TemplateFactory<T>* factory() const;
std::string generateJson() const override;
std::string generateJson() const;
nlohmann::json generateJsonJson() const;
private:

View File

@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___JSON_HELPER___H__
#include <string>
#include <openspace/json.h>
namespace openspace {
@@ -65,6 +66,16 @@ std::string formatJsonNumber(double d);
template <typename T>
std::string formatJson(T value);
/**
* Sort a json object that is an array of objects with the structure
* [ key = {}, key = {} ...]. Sorts it by the provided key
*
* \param json The json to sort
* \param key The key the json should be sorted by
* \return The sorted JSON
*/
void sortJson(nlohmann::json& json, const std::string& key);
} // namespace openspace
#include "json_helper.inl"