mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-07 12:00:05 -05:00
Ability for LuaDocumentationFile, PropertyDocumentationFile, and KeyboardMapping to write HTML output
Adding those html files to the gitignore
This commit is contained in:
@@ -117,3 +117,6 @@ data/scene/rosetta/rosetta/obj/Rosetta.obj
|
||||
data/scene/rosetta/rosetta/rosetta/
|
||||
data/scene/rosetta/rosetta/textures/
|
||||
data/spice/Rosetta/
|
||||
KeyboardMapping.html
|
||||
LuaScripting.html
|
||||
Properties.html
|
||||
|
||||
@@ -951,13 +951,33 @@ void InteractionHandler::bindKey(Key key, KeyModifier modifier, std::string lua)
|
||||
void InteractionHandler::writeKeyboardDocumentation(const std::string& type, const std::string& file)
|
||||
{
|
||||
if (type == "text") {
|
||||
std::ofstream f(absPath(file));
|
||||
std::ofstream f;
|
||||
f.exceptions(~std::ofstream::goodbit);
|
||||
f.open(file);
|
||||
|
||||
for (const auto& p : _keyLua) {
|
||||
f << std::to_string(p.first) << ": " <<
|
||||
p.second << std::endl;
|
||||
}
|
||||
}
|
||||
else if (type == "html") {
|
||||
std::ofstream f;
|
||||
f.exceptions(~std::ofstream::goodbit);
|
||||
f.open(absPath(file));
|
||||
|
||||
std::stringstream json;
|
||||
json << "[";
|
||||
for (const auto& p : _keyLua) {
|
||||
json << "{";
|
||||
json << "\"key\": \"" << std::to_string(p.first) << "\",";
|
||||
json << "\"script\": \"" << p.second << "\",";
|
||||
json << "},";
|
||||
}
|
||||
json << "]";
|
||||
|
||||
std::string jsonText = json.str();
|
||||
|
||||
}
|
||||
else {
|
||||
throw ghoul::RuntimeError(
|
||||
"Unsupported keyboard documentation type '" + type + "'",
|
||||
|
||||
+51
-7
@@ -414,13 +414,11 @@ SceneGraph& Scene::sceneGraph() {
|
||||
}
|
||||
|
||||
void Scene::writePropertyDocumentation(const std::string& filename, const std::string& type) {
|
||||
LDEBUG("Writing documentation for properties");
|
||||
if (type == "text") {
|
||||
LDEBUG("Writing documentation for properties");
|
||||
std::ofstream file(filename);
|
||||
if (!file.good()) {
|
||||
LERROR("Could not open file '" << filename << "' for writing property documentation");
|
||||
return;
|
||||
}
|
||||
std::ofstream file;
|
||||
file.exceptions(~std::ofstream::goodbit);
|
||||
file.open(filename);
|
||||
|
||||
using properties::Property;
|
||||
for (SceneGraphNode* node : _graph.nodes()) {
|
||||
@@ -429,13 +427,59 @@ void Scene::writePropertyDocumentation(const std::string& filename, const std::s
|
||||
file << node->name() << std::endl;
|
||||
|
||||
for (Property* p : properties) {
|
||||
file << p->fullyQualifiedIdentifier() << ": " << p->guiName() << std::endl;
|
||||
file << p->fullyQualifiedIdentifier() << ": " <<
|
||||
p->guiName() << std::endl;
|
||||
}
|
||||
|
||||
file << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == "html") {
|
||||
std::ofstream file;
|
||||
file.exceptions(~std::ofstream::goodbit);
|
||||
file.open(filename);
|
||||
|
||||
// Create JSON
|
||||
std::function<std::string(properties::PropertyOwner*)> createJson =
|
||||
[&createJson](properties::PropertyOwner* owner) -> std::string
|
||||
{
|
||||
std::stringstream json;
|
||||
json << "{";
|
||||
json << "\"name\": \"" << owner->name() << "\",";
|
||||
|
||||
json << "\"properties\": [";
|
||||
for (properties::Property* p : owner->properties()) {
|
||||
json << "{";
|
||||
json << "\"id\": \"" << p->identifier() << "\",";
|
||||
json << "\"fullyQualifiedId\": \"" << p->fullyQualifiedIdentifier() << "\",";
|
||||
json << "\"guiName\": \"" << p->guiName() << "\",";
|
||||
json << "},";
|
||||
}
|
||||
json << "],";
|
||||
|
||||
json << "\"propertyOwner\": [";
|
||||
for (properties::PropertyOwner* o : owner->propertySubOwners()) {
|
||||
json << createJson(o);
|
||||
}
|
||||
json << "],";
|
||||
json << "},";
|
||||
|
||||
return json.str();
|
||||
};
|
||||
|
||||
|
||||
std::stringstream json;
|
||||
json << "[";
|
||||
for (SceneGraphNode* node : _graph.nodes()) {
|
||||
json << createJson(node);
|
||||
}
|
||||
|
||||
json << "]";
|
||||
|
||||
std::string jsonText = json.str();
|
||||
|
||||
}
|
||||
else
|
||||
LERROR("Undefined type '" << type << "' for Property documentation");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user