@@ -163,37 +163,33 @@ class Website is export {
163
163
my $ category-key = $ category . key ;
164
164
say " Creating example files for category: $ category-key" ;
165
165
my $ html-dir = $ ! base-html-dir ~ " /categories/$ category-key /" ;
166
- my @ files = files-in-category($ category-key , base-dir => $ ! base-categories-dir );
167
- for @ files -> $ file {
168
- next unless $ file . IO . e ;
169
- my $ example = $ category . examples{$ file . IO . basename };
170
- my $ pod = format-author-heading($ example );
171
- $ pod . push : source-reference($ file , $ category-key );
172
- my $ html-file = $ file . IO . basename . subst (/\. p(l| 6)$ /, " .html" );
173
- $ html-file = $ html-dir ~ $ html-file ;
174
- spurt $ html-file , self . p2h($ pod );
175
- }
166
+ self . write-example-html($ category , $ ! base-categories-dir , $ html-dir );
176
167
if $ category . subcategories {
177
168
for $ category . subcategories. categories-list -> $ subcategory {
178
169
my $ subcategory-key = $ subcategory . key ;
179
170
say " Creating example files for subcategory: $ subcategory-key" ;
180
171
my $ base-dir = $ ! base-categories-dir ~ " /" ~ $ category-key ;
181
- my @ files = files-in-category($ subcategory-key , base-dir => $ base-dir );
182
172
my $ html-dir = $ ! base-html-dir ~ " /categories/$ category-key /$ subcategory-key /" ;
183
- for @ files -> $ file {
184
- next unless $ file . IO . e ;
185
- my $ example = $ subcategory . examples{$ file . IO . basename };
186
- my $ pod = format-author-heading($ example );
187
- $ pod . push : source-reference($ file , $ subcategory-key );
188
- my $ html-file = $ file . IO . basename . subst (/\. p(l| 6)$ /, " .html" );
189
- $ html-file = $ html-dir ~ $ html-file ;
190
- spurt $ html-file , self . p2h($ pod );
191
- }
173
+ self . write-example-html($ subcategory , $ base-dir , $ html-dir );
192
174
}
193
175
}
194
176
}
195
177
}
196
178
179
+ # | write example html to file
180
+ method write-example-html ($ category , $ category-dir , $ html-dir ) {
181
+ my @ files = files-in-category($ category . key , base-dir => $ category-dir );
182
+ for @ files -> $ file {
183
+ next unless $ file . IO . e ;
184
+ my $ example = $ category . examples{$ file . IO . basename };
185
+ my $ pod = format-author-heading($ example );
186
+ $ pod . push : source-reference($ file , $ category . key );
187
+ my $ html-file = $ file . IO . basename . subst (/\. p(l| 6)$ /, " .html" );
188
+ $ html-file = $ html-dir ~ $ html-file ;
189
+ spurt $ html-file , self . p2h($ pod );
190
+ }
191
+ }
192
+
197
193
# | convert the POD into html
198
194
method p2h ($ pod ) {
199
195
my $ head = slurp ' template/head.html' ;
0 commit comments