Skip to content

Commit 9b07085

Browse files
committed
More node descriptions, fancier wiki generator
1 parent e257d4d commit 9b07085

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

include/FastNoise/Generators/BasicGenerators.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ namespace FastNoise
8181
{
8282
groups.push_back( "Basic Generators" );
8383
this->AddVariable( { "Value", "Constant output" }, 1.0f, &Constant::SetValue );
84+
85+
description =
86+
"Outputs a constant value";
8487
}
8588
};
8689
#endif
@@ -123,7 +126,8 @@ namespace FastNoise
123126
{
124127
groups.push_back( "Basic Generators" );
125128
description =
126-
"Outputs checkerboard pattern";
129+
"Outputs a checkerboard pattern\n"
130+
"Each checkerboard cell is \"Feature Scale\" sized in each dimension";
127131
}
128132
};
129133
#endif
@@ -184,7 +188,7 @@ namespace FastNoise
184188

185189
description =
186190
"Takes the input position and does the following per dimension\n"
187-
"(input + offset) * multiplier\n"
191+
"`(input + offset) * multiplier`\n"
188192
"The output is the sum of all results";
189193
}
190194
};

util/WikiGenerator/main.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <fstream>
66
#include <iostream>
77
#include <sstream>
8+
#include <regex>
89
#include <unordered_map>
910

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

140+
std::string FormatDescription( const char* description )
141+
{
142+
std::string formatted = description;
143+
size_t pos = 0;
144+
145+
while( (pos = formatted.find( '\n', pos )) != std::string::npos )
146+
{
147+
formatted.insert( pos, "<br/>" );
148+
pos += 6; // Length of "\n<br/>"
149+
}
150+
151+
return formatted;
152+
}
153+
139154
void DoNode( std::stringstream& output, const FastNoise::Metadata* metadata, const std::string& outDir )
140155
{
141156
std::string nodeName = FastNoise::Metadata::FormatMetadataNodeName( metadata, false );
142157

143158
output << "## " << nodeName << '\n';
144-
output << metadata->description << "\n\n";
159+
output << FormatDescription( metadata->description ) << "\n\n";
145160

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

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

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

161176
for( auto& variable : metadata->memberVariables )
162177
{
163178
switch( variable.type )
164179
{
165180
case FastNoise::Metadata::MemberVariable::EFloat:
166-
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.f << "f`\n" << variable.description << '\n';
181+
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.f << "f`\n" << FormatDescription( variable.description ) << '\n';
167182
break;
168183
case FastNoise::Metadata::MemberVariable::EInt:
169-
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.i << "`\n" << variable.description << '\n';
184+
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.valueDefault.i << "`\n" << FormatDescription( variable.description ) << '\n';
170185
break;
171186
case FastNoise::Metadata::MemberVariable::EEnum:
172-
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.enumNames[variable.valueDefault.i] << "`\n" << variable.description << '\n';
187+
output << "### " << FastNoise::Metadata::FormatMetadataMemberName( variable ) << " `= " << variable.enumNames[variable.valueDefault.i] << "` _- Enum_\n" << FormatDescription( variable.description ) << '\n';
173188
for( size_t i = 0; i < variable.enumNames.size(); i++ )
174189
{
175190
output << "* " << variable.enumNames[i] << (variable.valueDefault.i == i ? " (Default)\n" : "\n");

0 commit comments

Comments
 (0)