Created
August 14, 2012 17:02
-
-
Save softmoth/3350872 to your computer and use it in GitHub Desktop.
Somewhat improved pod-dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env perl6 | |
# vim:set ft=perl6: | |
sub print-pod(Pod::Block $pod, $level = 0) { | |
my $leading = ' ' x $level; | |
my %confs; | |
for <config name level caption type headers> { | |
my $thing = $pod.?"$_"(); | |
if $thing { | |
%confs{$_} = $thing ~~ Iterable ?? $thing.perl !! $thing.Str; | |
} | |
} | |
note $leading, $pod.^name, (%confs.perl if %confs); | |
for $pod.content.list { | |
when Pod::Block { | |
print-pod($_, $level + 2); | |
} | |
when Array { | |
note $leading, 'ARRAY ['; | |
for @$_ { | |
note $leading, " '$_',"; | |
} | |
note $leading, ']'; | |
} | |
when Str { | |
note $_.indent($level + 2); | |
} | |
default { | |
note $leading, 'UNKNOWN {{{', $_.perl, '}}}'; | |
} | |
} | |
} | |
sub MAIN($pod-file) { | |
my $pod = eval slurp($pod-file) ~ "\n\$=pod"; | |
print-pod($_) for @$pod; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment