@@ -65,6 +65,13 @@ ($pod)
65
65
}
66
66
}
67
67
68
+ sub first-code-block (@ pod ) {
69
+ if @ pod [1 ] ~~ Pod ::Block::Code {
70
+ return @ pod [1 ]. content. grep (Str ). join ;
71
+ }
72
+ ' ' ;
73
+ }
74
+
68
75
sub MAIN (Bool : $ debug , Bool : $ typegraph = False ) {
69
76
$ * DEBUG = $ debug ;
70
77
for ' ' , < type language routine images op op/ prefix op/ postfix op/ infix
@@ -195,10 +202,24 @@ (Bool :$debug, Bool :$typegraph = False)
195
202
say " $ podname .$ name" if $ * DEBUG ;
196
203
next if $ name ~~ /\s /;
197
204
% methods-by-type {$ podname }. push : $ chunk ;
205
+ # deterimine whether it's a sub or method
206
+ my Str $ subkind ;
207
+ {
208
+ my % counter ;
209
+ for first-code-block($ chunk ). lines {
210
+ if ms/^ ' multi' ? (sub| method)»/ {
211
+ % counter {$0 }++ ;
212
+ }
213
+ }
214
+ if % counter == 1 {
215
+ ($ subkind ,) = % counter . keys ;
216
+ }
217
+ }
218
+
198
219
$ dr . add-new(
199
220
: kind<routine >,
200
- # TODO: determine subkind, ie method/sub
201
- : name( $ name ) ,
221
+ : $ subkind ,
222
+ : $ name ,
202
223
: pod($ chunk ),
203
224
:! pod-is-complete,
204
225
: origin($ d ),
@@ -372,7 +393,7 @@ (Bool :$debug, Bool :$typegraph = False)
372
393
});
373
394
my % seen ;
374
395
@ items . push : $ dr . lookup(' routine' , : by<kind >). grep ({! % seen {. name }++ }). sort (*. name ). map ({
375
- " \{ label: \" Routine: { . name } \" , value: \" { . name } \" , url: \" { fix-url(. url) } \" \} "
396
+ " \{ label: \" { ( . subkind // ' Routine' ) . tclc } : { . name } \" , value: \" { . name } \" , url: \" { fix-url(. url) } \" \} "
376
397
});
377
398
378
399
my $ items = @ items . join (" ,\n " );
@@ -467,8 +488,13 @@ (Bool :$debug, Bool :$typegraph = False)
467
488
sub write-routine-file ($ dr , $ name ) {
468
489
say " Writing html/routine/$ name .html" if $ * DEBUG ;
469
490
my @ docs = $ dr . lookup($ name , : by<name >). grep (*. kind eq ' routine' );
470
- my $ pod = pod-with-title(" Documentation for routine $ name" ,
471
- pod-block(" Documentation for routine $ name , assembled from the
491
+ my $ subkind = ' routine' ;
492
+ {
493
+ my @ subkinds = @ docs >>. subkind;
494
+ $ subkind = @ subkinds [0 ] if all (@ subkinds >>. defined ) && [eq ] @ subkinds ;
495
+ }
496
+ my $ pod = pod-with-title(" Documentation for $ subkind $ name" ,
497
+ pod-block(" Documentation for $ subkind $ name , assembled from the
472
498
following types:" ),
473
499
@ docs . map ({
474
500
pod-heading(. origin. name ~ ' .' ~ . name ),
0 commit comments