Skip to content
Browse files

Add declarator blocks support to Pod::To::Text

  • Loading branch information...
1 parent 71df76f commit 4472ab814bdaec0311fb2652111aff888e1ee080 @tadzik tadzik committed
Showing with 20 additions and 0 deletions.
  1. +20 −0 Pod/To/Text.pm
View
20 Pod/To/Text.pm
@@ -1,11 +1,13 @@
module Pod::To::Text;
sub pod2text($pod) is export {
+ my @declarators;
given $pod {
when Pod::Heading { heading2text($pod) }
when Pod::Block::Code { code2text($pod) ~ "\n\n" }
when Pod::Block::Named { named2text($pod) ~ "\n" }
when Pod::Block::Para { para2text($pod) ~ "\n\n" }
+ when Pod::Block::Declarator { declarator2text($pod) }
when Pod::Item { item2text($pod) ~ "\n" }
when Positional { $pod.map({pod2text($_)}).join }
default { $pod.Str }
@@ -36,4 +38,22 @@ sub para2text($pod) {
$pod.content.join("\n")
}
+sub declarator2text($pod) {
+ next unless $pod.WHEREFORE.WHY;
+ do given $pod.WHEREFORE {
+ when Method {
+ 'method'
+ }
+ when Sub {
+ 'sub'
+ }
+ when nqp::p6bool(nqp::istype($_.HOW, Metamodel::ClassHOW)) {
+ 'class'
+ }
+ when nqp::p6bool(nqp::istype($_.HOW, Metamodel::ModuleHOW)) {
+ 'module'
+ }
+ } ~ ' ' ~ $pod.WHEREFORE.perl ~ ': ' ~ $pod.WHEREFORE.WHY ~ "\n"
+}
+
# vim: ft=perl6

0 comments on commit 4472ab8

Please sign in to comment.
Something went wrong with that request. Please try again.