@@ -304,17 +304,19 @@ multi write-type-source($doc) {
304
304
spurt " html/$ what /$ podname .html" , p2h($ pod , $ what );
305
305
}
306
306
307
+ # | A one-pass-parser for pod headers that define something documentable.
307
308
sub find-definitions (: $ pod , : $ origin , : $ min-level = -1 ) {
308
- # Run through the pod content, and look for headings.
309
- # If a heading is a definition, like "class FooBar", process
310
- # the class and give the rest of the pod to find-definitions,
309
+ # Runs through the pod content, and looks for headings.
310
+ # If a heading is a definition, like "class FooBar", processes
311
+ # the class and gives the rest of the pod to find-definitions,
311
312
# which will return how far the definition of "class FooBar" extends.
312
- my @ all-pod-elements := $ pod ~~ Positional ?? @$ pod !! $ pod . contents;
313
+ # We then continue parsing from after that point.
314
+ my @ pod-section := $ pod ~~ Positional ?? @$ pod !! $ pod . contents;
313
315
my int $ i = 0 ;
314
- my int $ len = + @ all- pod-elements ;
316
+ my int $ len = + @ pod-section ;
315
317
while $ i < $ len {
316
318
NEXT {$ i = $ i + 1 }
317
- my $ pod-element := @ all- pod-elements [$ i ];
319
+ my $ pod-element := @ pod-section [$ i ];
318
320
next unless $ pod-element ~~ Pod ::Heading;
319
321
return $ i if $ pod-element . level <= $ min-level ;
320
322
@@ -368,8 +370,8 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
368
370
}
369
371
when ' class' | ' role' | ' enum' {
370
372
my $ summary = ' ' ;
371
- if @ all- pod-elements [$ i + 1] ~~ {$ _ ~~ Pod ::Block::Named and . name eq " SUBTITLE" } {
372
- $ summary = @ all- pod-elements [$ i + 1]. contents[0 ]. contents[0 ];
373
+ if @ pod-section [$ i + 1] ~~ {$ _ ~~ Pod ::Block::Named and . name eq " SUBTITLE" } {
374
+ $ summary = @ pod-section [$ i + 1]. contents[0 ]. contents[0 ];
373
375
} else {
374
376
note " $ name does not have an =SUBTITLE" ;
375
377
}
@@ -407,18 +409,18 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
407
409
# And updating $i to be after the places we've already searched
408
410
once {
409
411
$ new-i = $ i + find-definitions
410
- : pod(@ all- pod-elements [$ i + 1.. * ]),
412
+ : pod(@ pod-section [$ i + 1.. * ]),
411
413
: origin($ created ),
412
- : min-level(@ all- pod-elements [$ i ]. level);
414
+ : min-level(@ pod-section [$ i ]. level);
413
415
}
414
416
415
417
my $ new-head = Pod ::Heading. new (
416
- : level(@ all- pod-elements [$ i ]. level),
418
+ : level(@ pod-section [$ i ]. level),
417
419
: contents[pod-link " $ subkinds $ name" ,
418
420
$ created . url ~ " #$ origin. human-kind () $ origin. name ()" . subst (: g, /\s + /, ' _' )
419
421
]
420
422
);
421
- my @ orig-chunk = $ new-head , @ all- pod-elements [$ i ^.. $ new-i ];
423
+ my @ orig-chunk = $ new-head , @ pod-section [$ i ^.. $ new-i ];
422
424
my $ chunk = $ created . pod. push : pod-lower-headings(@ orig-chunk , : to(% attr <kind > eq ' type' ?? 0 !! 2 ));
423
425
424
426
if $ subkinds eq ' routine' {
0 commit comments