Skip to content

Commit

Permalink
More node descriptions, fancier wiki generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Auburn committed Dec 15, 2024
1 parent e257d4d commit 9b07085
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
8 changes: 6 additions & 2 deletions include/FastNoise/Generators/BasicGenerators.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ namespace FastNoise
{
groups.push_back( "Basic Generators" );
this->AddVariable( { "Value", "Constant output" }, 1.0f, &Constant::SetValue );

description =
"Outputs a constant value";
}
};
#endif
Expand Down Expand Up @@ -123,7 +126,8 @@ namespace FastNoise
{
groups.push_back( "Basic Generators" );
description =
"Outputs checkerboard pattern";
"Outputs a checkerboard pattern\n"
"Each checkerboard cell is \"Feature Scale\" sized in each dimension";
}
};
#endif
Expand Down Expand Up @@ -184,7 +188,7 @@ namespace FastNoise

description =
"Takes the input position and does the following per dimension\n"
"(input + offset) * multiplier\n"
"`(input + offset) * multiplier`\n"
"The output is the sum of all results";
}
};
Expand Down
27 changes: 21 additions & 6 deletions util/WikiGenerator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <regex>
#include <unordered_map>

static constexpr int imageSizeX = 256;
Expand Down Expand Up @@ -136,12 +137,26 @@ bool CreateImage( const FastNoise::Metadata* metadata, const std::string& outDir
return false;
}

std::string FormatDescription( const char* description )
{
std::string formatted = description;
size_t pos = 0;

while( (pos = formatted.find( '\n', pos )) != std::string::npos )
{
formatted.insert( pos, "<br/>" );
pos += 6; // Length of "\n<br/>"
}

return formatted;
}

void DoNode( std::stringstream& output, const FastNoise::Metadata* metadata, const std::string& outDir )
{
std::string nodeName = FastNoise::Metadata::FormatMetadataNodeName( metadata, false );

output << "## " << nodeName << '\n';
output << metadata->description << "\n\n";
output << FormatDescription( metadata->description ) << "\n\n";

if( CreateImage( metadata, outDir, nodeName ) )
{
Expand All @@ -150,26 +165,26 @@ void DoNode( std::stringstream& output, const FastNoise::Metadata* metadata, con

for( auto& node_lookup : metadata->memberNodeLookups )
{
output << "### " << node_lookup.name << " - Node Lookup\n" << node_lookup.description << '\n';
output << "### " << node_lookup.name << " _- Node Lookup_\n" << FormatDescription( node_lookup.description ) << '\n';
}

for( auto& hybrid_lookup : metadata->memberHybrids )
{
output << "### " << hybrid_lookup.name << " - Hybrid Lookup '= " << hybrid_lookup.valueDefault << "f`\n" << hybrid_lookup.description << '\n';
output << "### " << hybrid_lookup.name << " `= " << hybrid_lookup.valueDefault << "f` _- Hybrid Lookup_\n" << FormatDescription( hybrid_lookup.description ) << '\n';
}

for( auto& variable : metadata->memberVariables )
{
switch( variable.type )
{
case FastNoise::Metadata::MemberVariable::EFloat:
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.f << "f`\n" << variable.description << '\n';
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.f << "f`\n" << FormatDescription( variable.description ) << '\n';
break;
case FastNoise::Metadata::MemberVariable::EInt:
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.i << "`\n" << variable.description << '\n';
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.i << "`\n" << FormatDescription( variable.description ) << '\n';
break;
case FastNoise::Metadata::MemberVariable::EEnum:
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.enumNames[variable.valueDefault.i] << "`\n" << variable.description << '\n';
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.enumNames[variable.valueDefault.i] << "` _- Enum_\n" << FormatDescription( variable.description ) << '\n';
for( size_t i = 0; i < variable.enumNames.size(); i++ )
{
output << "* " << variable.enumNames[i] << (variable.valueDefault.i == i ? " (Default)\n" : "\n");
Expand Down

0 comments on commit 9b07085

Please sign in to comment.