@@ -29,8 +29,35 @@ use Perl6::Documentable::Registry;
29
29
use Pod ::Convenience;
30
30
use Pod ::Htmlify;
31
31
32
+ & spurt . wrap (sub (| c){
33
+ state % seen-paths ;
34
+ die " { c[0 ]} got badchar" if c[0 ]. contains (any (qw [ \ % ? & = # + " ' : ~ < > ] ));
35
+ note " duplicated path { c[0 ]} " if % seen-paths {c[0 ]}: exists ;
36
+ % seen-paths {c[0 ]}++ ;
37
+ callsame
38
+ });
39
+
40
+ my @ __URLS ;
41
+ & url-munge . wrap (sub (| c){
42
+ @ __URLS . push : uri-unescape(c[0 ]);
43
+ callsame
44
+ });
45
+
32
46
use experimental : cached;
33
47
48
+ sub escape-filename ($ s is copy ) {
49
+ return $ s if $ s ~~ m {^ <[ a..z ] >+ '://' }; # bail on external links
50
+ constant badchars = qw [ $ / \ . % ? & = # + " ' : ~ < > ] ;
51
+ constant goodnames = badchars. map : ' $' ~ *. uniname . subst (' ' , ' _' , : g);
52
+ constant length = badchars. elems ;
53
+
54
+ loop (my int $ i = 0 ;$ i < length;$ i ++ ) {
55
+ $ s = $ s . subst (badchars[$ i ], goodnames[$ i ], : g)
56
+ }
57
+
58
+ $ s
59
+ }
60
+
34
61
my $ type-graph ;
35
62
my % routines-by-type ;
36
63
my % * POD2HTML-CALLBACKS ;
@@ -178,6 +205,8 @@ sub MAIN(
178
205
if $ sparse || ! $ search-file || ! $ disambiguation {
179
206
say " This is a sparse or incomplete run. DO NOT SYNC WITH doc.perl6.org!" ;
180
207
}
208
+
209
+ spurt (' html/links.txt' , @ __URLS . sort . unique . join (" \n " ));
181
210
}
182
211
183
212
my $ precomp-store = CompUnit::PrecompilationStore::File. new (: prefix($ ? FILE . IO . parent . child (" precompiled" )));
@@ -221,14 +250,16 @@ sub process-pod-dir($dir, :&sorted-by = &[cmp], :$sparse, :$parallel) {
221
250
for @ pod-sources . kv -> $ num , (: key($ filename ), : value($ file )) {
222
251
FIRST my @ pod-files ;
223
252
224
- push @ pod-files , start {
253
+ # push @pod-files, start {
254
+ push @ pod-files , {
225
255
printf " % 4d/% d : % -40s => % s\n " , $ num + 1, $ total , $ file . path , " $ kind /$ filename" ;
226
256
my $ pod = extract-pod($ file . path );
227
257
process-pod-source : $ kind , : $ pod , : $ filename , : pod-is-complete;
228
258
}
229
259
230
260
if $ num %% $ parallel {
231
- await (@ pod-files );
261
+ # await(@pod-files);
262
+ @ pod-files >>. ();
232
263
@ pod-files = ();
233
264
}
234
265
@@ -364,7 +395,9 @@ multi write-type-source($doc) {
364
395
note " Type $ podname not found in type-graph data" ;
365
396
}
366
397
367
- my $ html-filename = " html" ~ $ doc . url ~ " .html" ;
398
+ my @ parts = $ doc . url. split (' /' , : v);
399
+ @ parts [* - 1 ] = escape-filename @ parts [* - 1 ];
400
+ my $ html-filename = " html" ~ @ parts . join (' /' ) ~ " .html" ;
368
401
my $ pod-path = pod-path-from-url($ doc . url);
369
402
spurt $ html-filename , p2h($ pod , $ what , pod-path => $ pod-path );
370
403
}
@@ -778,7 +811,8 @@ sub write-disambiguation-files() {
778
811
});
779
812
}
780
813
my $ html = p2h($ pod , ' routine' );
781
- spurt " html/$ name. subst (/<[ /\\ ] > /,' _' ,: g) .html" , $ html ;
814
+ spurt " html/{ escape-filename $ name } .html" , $ html ;
815
+ # spurt "html/$name.subst(/<[/\\]>/,'_',:g).html", $html;
782
816
}
783
817
say ' ' ;
784
818
}
@@ -896,7 +930,8 @@ sub write-kind($kind) {
896
930
})
897
931
);
898
932
print ' .' ;
899
- spurt " html/$ kind /$ name. subst (/<[ /\\ ] > /,' _' ,: g) .html" , p2h($ pod , $ kind );
933
+ # spurt "html/$kind/$name.subst(/<[/\\]>/,'_',:g).html", p2h($pod, $kind);
934
+ spurt " html/$ kind /{ escape-filename $ name } .html" , p2h($ pod , $ kind );
900
935
}
901
936
say ' ' ;
902
937
}
@@ -908,7 +943,7 @@ sub write-qualified-method-call(:$name!, :$pod!, :$type!) {
908
943
@$ pod ,
909
944
);
910
945
return if $ name ~~ / '/' /;
911
- spurt " html/routine/{ $ type } .{ $ name } .html" , p2h($ p , ' routine' );
946
+ spurt " html/routine/{ escape-filename $ type } .{ escape-filename $ name } .html" , p2h($ p , ' routine' );
912
947
}
913
948
914
949
sub highlight-code-blocks (: $ use-inline-python = True ) {
0 commit comments