@@ -11,6 +11,7 @@ use lib 'lib';
11
11
use Perl6::TypeGraph;
12
12
use Perl6::TypeGraph::Viz;
13
13
use Perl6::Documentable::Registry;
14
+ use Pod ::Convenience;
14
15
15
16
my $ * DEBUG = False ;
16
17
@@ -78,36 +79,6 @@ sub p2h($pod, $selection = 'nothing selected') {
78
79
pod2html($ pod , : url(& url-munge ), : $ head , : header(header-html $ selection ), : $ footer );
79
80
}
80
81
81
- sub pod-gist (Pod ::Block $ pod , $ level = 0 ) {
82
- my $ leading = ' ' x $ level ;
83
- my % confs ;
84
- my @ chunks ;
85
- for <config name level caption type > {
86
- my $ thing = $ pod .? " $ _" ();
87
- if $ thing {
88
- % confs {$ _ } = $ thing ~~ Iterable ?? $ thing . perl !! $ thing . Str ;
89
- }
90
- }
91
- @ chunks = $ leading , $ pod .^ name , (% confs . perl if % confs ), " \n " ;
92
- for $ pod . content. list -> $ c {
93
- if $ c ~~ Pod ::Block {
94
- @ chunks . push : pod-gist($ c , $ level + 2 );
95
- }
96
- elsif $ c ~~ Str {
97
- @ chunks . push : $ c . indent($ level + 2 ), " \n " ;
98
- } elsif $ c ~~ Positional {
99
- @ chunks . push : $ c . map : {
100
- if $ _ ~~ Pod ::Block {
101
- *. & pod-gist
102
- } elsif $ _ ~~ Str {
103
- $ _
104
- }
105
- }
106
- }
107
- }
108
- @ chunks . join ;
109
- }
110
-
111
82
sub recursive-dir ($ dir ) {
112
83
my @ todo = $ dir ;
113
84
gather while @ todo {
@@ -123,13 +94,6 @@ sub recursive-dir($dir) {
123
94
}
124
95
}
125
96
126
- sub first-code-block (@ pod ) {
127
- if @ pod [1 ] ~~ Pod ::Block::Code {
128
- return @ pod [1 ]. content. grep (Str ). join ;
129
- }
130
- ' ' ;
131
- }
132
-
133
97
sub MAIN (Bool : $ debug , Bool : $ typegraph = False ) {
134
98
$ * DEBUG = $ debug ;
135
99
@@ -182,7 +146,7 @@ sub process-pod-dir($dir, :$dr, :&sorted-by = &[cmp]) {
182
146
my $ total = + @ pod-sources ;
183
147
my $ what = $ dir . lc ;
184
148
for @ pod-sources . kv -> $ num , (: key($ podname ), : value($ file )) {
185
- printf " % 4d/% d : % -40s => % s\n " , $ num , $ total , $ file . path , " $ what /$ podname" ;
149
+ printf " % 4d/% d : % -40s => % s\n " , $ num + 1 , $ total , $ file . path , " $ what /$ podname" ;
186
150
my $ pod = EVAL (slurp ($ file . path ) ~ " \n \$=pod" )[0 ];
187
151
process-pod-source $ what , : $ dr , : what($ what ), : $ pod , : $ podname ;
188
152
}
@@ -340,73 +304,6 @@ sub find-definitions (:$pod, :$origin, :$dr) {
340
304
}
341
305
}
342
306
343
- sub chunks-grep (: $ from ! , : & to ! , * @ elems ) {
344
- my @ current ;
345
-
346
- gather {
347
- for @ elems -> $ c {
348
- if @ current && ($ c ~~ $ from || to (@ current [0 ], $ c )) {
349
- take [@ current ];
350
- @ current = ();
351
- @ current . push : $ c if $ c ~~ $ from ;
352
- }
353
- elsif @ current or $ c ~~ $ from {
354
- @ current . push : $ c ;
355
- }
356
- }
357
- take [@ current ] if @ current ;
358
- }
359
- }
360
-
361
- sub pod-with-title ($ title , * @ blocks ) {
362
- Pod ::Block::Named. new (
363
- name => " pod" ,
364
- content => [
365
- Pod ::Block::Named. new (
366
- name => " TITLE" ,
367
- content => Array . new (
368
- Pod ::Block::Para. new (
369
- content => [$ title ],
370
- )
371
- )
372
- ),
373
- @ blocks . flat ,
374
- ]
375
- );
376
- }
377
-
378
- sub pod-block (* @ content ) {
379
- Pod ::Block::Para. new (: @ content );
380
- }
381
-
382
- sub pod-link ($ text , $ url ) {
383
- Pod ::FormattingCode. new (
384
- type => ' L' ,
385
- content => [$ text ],
386
- meta => [$ url ],
387
- );
388
- }
389
-
390
- sub pod-item (* @ content , : $ level = 1 ) {
391
- Pod ::Item. new (
392
- : $ level ,
393
- : @ content ,
394
- );
395
- }
396
-
397
- sub pod-heading ($ name , : $ level = 1 ) {
398
- Pod ::Heading. new (
399
- : $ level ,
400
- : content[pod-block($ name )],
401
- );
402
- }
403
-
404
- sub pod-table (@ content ) {
405
- Pod ::Block::Table. new (
406
- : @ content
407
- )
408
- }
409
-
410
307
sub write-type-graph-images (: $ force ) {
411
308
unless $ force {
412
309
my $ dest = ' html/images/type-graph-Any.svg' . path ;
@@ -564,40 +461,56 @@ sub write-index-files($dr) {
564
461
})
565
462
), ' language' );
566
463
567
- sub list-of-all ($ what ) {
568
- pod-block ' This is a list of ' , Pod ::FormattingCode. new (: type<B >: content[' all' ]),
569
- " built-in { $ what } s that are documented here as part of the the Perl 6 language. " ,
570
- " Use the above menu to narrow it down topically."
571
- }
464
+ write-main-index : $ dr : kind<type >;
572
465
573
- sub write-main-index ($ kind ) {
574
- say " Writing html/$ kind .html ..." ;
575
- spurt " html/$ kind .html" , p2h(pod-with-title(
576
- " Perl 6 { $ kind . tc} s" ,
577
- list-of-all($ kind ),
578
- pod-table($ dr . lookup($ kind , : by<kind >). categorize (*. name ). sort (*. key )>>. value . map ({
579
- [set(. map : {. subkinds // Nil }). list. join (' , ' ), pod-link(. [0 ]. name , . [0 ]. url), . [0 ]. summary]
580
- }))
581
- ), $ kind );
466
+ my & summary = {
467
+ pod-block(" (From " , $ _ >>. origin. map ({
468
+ pod-link(. name , . url)," , "
469
+ })," )" )
582
470
}
583
471
584
- # XXX: Only handles normal routines, not types nor operators
585
- sub write-sub-index ($ kind , $ category ) {
586
- say " Writing html/$ kind -$ category .html ..." ;
587
- spurt " html/$ kind -$ category .html" , p2h(pod-with-title(
588
- " Perl 6 { $ category . tc} { $ kind . tc} s" ,
589
- pod-table($ dr . lookup($ kind , : by<kind >)\
590
- . grep ({$ category ⊆ . categories})\ # XXX
591
- . categorize (*. name ). sort (*. key )>>. value \
592
- . map ({
593
- [set(. map : {. subkinds // Nil }). list. join (' , ' ), pod-link(. [0 ]. name , . [0 ]. url), . [0 ]. summary]
594
- })
595
- )
596
- ), $ kind );
472
+ write-main-index : $ dr : kind<routine > : & summary ;
473
+
474
+ for <sub method term operator > -> $ category {
475
+ write-sub-index : $ dr : kind<routine > : $ category : & summary ;
597
476
}
477
+ }
478
+
479
+ sub write-main-index (: $ dr , : $ kind , : & summary = {Nil }) {
480
+ say " Writing html/$ kind .html ..." ;
481
+ spurt " html/$ kind .html" , p2h(pod-with-title(
482
+ " Perl 6 { $ kind . tc} s" ,
483
+ pod-block(
484
+ ' This is a list of ' , pod-bold(' all' ), ' built-in ' ~ $ kind . tc ~
485
+ " s that are documented here as part of the the Perl 6 language. " ~
486
+ " Use the above menu to narrow it down topically."
487
+ ),
488
+ pod-table($ dr . lookup($ kind , : by<kind >)\
489
+ . categorize (*. name ). sort (*. key )>>. value \
490
+ . map ({[
491
+ set(. map : {. subkinds // Nil }). list. join (' , ' ),
492
+ pod-link(. [0 ]. name , . [0 ]. url),
493
+ . & summary
494
+ ]})
495
+ )
496
+ ), $ kind );
497
+ }
598
498
599
- . & write-main-index for <type routine >;
600
- write-sub-index ' routine' , $ _ for <sub method term operator >;
499
+ # XXX: Only handles normal routines, not types nor operators
500
+ sub write-sub-index (: $ dr , : $ kind , : $ category , : & summary = {Nil }) {
501
+ say " Writing html/$ kind -$ category .html ..." ;
502
+ spurt " html/$ kind -$ category .html" , p2h(pod-with-title(
503
+ " Perl 6 { $ category . tc} { $ kind . tc} s" ,
504
+ pod-table($ dr . lookup($ kind , : by<kind >)\
505
+ . grep ({$ category ⊆ . categories})\ # XXX
506
+ . categorize (*. name ). sort (*. key )>>. value \
507
+ . map ({[
508
+ set(. map : {. subkinds // Nil }). list. join (' , ' ),
509
+ pod-link(. [0 ]. name , . [0 ]. url),
510
+ . & summary
511
+ ]})
512
+ )
513
+ ), $ kind );
601
514
}
602
515
603
516
sub write-routine-file ($ dr , $ name ) {
0 commit comments