5
5
#include < fstream>
6
6
#include < iostream>
7
7
#include < sstream>
8
+ #include < regex>
8
9
#include < unordered_map>
9
10
10
11
static constexpr int imageSizeX = 256 ;
@@ -136,12 +137,26 @@ bool CreateImage( const FastNoise::Metadata* metadata, const std::string& outDir
136
137
return false ;
137
138
}
138
139
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
+
139
154
void DoNode ( std::stringstream& output, const FastNoise::Metadata* metadata, const std::string& outDir )
140
155
{
141
156
std::string nodeName = FastNoise::Metadata::FormatMetadataNodeName ( metadata, false );
142
157
143
158
output << " ## " << nodeName << ' \n ' ;
144
- output << metadata->description << " \n\n " ;
159
+ output << FormatDescription ( metadata->description ) << " \n\n " ;
145
160
146
161
if ( CreateImage ( metadata, outDir, nodeName ) )
147
162
{
@@ -150,26 +165,26 @@ void DoNode( std::stringstream& output, const FastNoise::Metadata* metadata, con
150
165
151
166
for ( auto & node_lookup : metadata->memberNodeLookups )
152
167
{
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 ' ;
154
169
}
155
170
156
171
for ( auto & hybrid_lookup : metadata->memberHybrids )
157
172
{
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 ' ;
159
174
}
160
175
161
176
for ( auto & variable : metadata->memberVariables )
162
177
{
163
178
switch ( variable.type )
164
179
{
165
180
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 ' ;
167
182
break ;
168
183
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 ' ;
170
185
break ;
171
186
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 ' ;
173
188
for ( size_t i = 0 ; i < variable.enumNames .size (); i++ )
174
189
{
175
190
output << " * " << variable.enumNames [i] << (variable.valueDefault .i == i ? " (Default)\n " : " \n " );
0 commit comments