In Raku, how can I get Pod::To modules to recognize a Pod::Block::Declarator POD element?

79 views Asked by At
#!/usr/bin/env raku
use v6.d;

sub MAIN (
    :$foo = 42, #= A test
) {
    run $*EXECUTABLE, '--doc', $*PROGRAM;
}

=begin pod

=head1 Bar

blah, blah, blah

=head2 Baz

yadda, yadda, yadda

=end pod

Output:

class Mu $
A test

Bar

blah, blah, blah

  Baz

yadda, yadda, yadda

What is that class Mu $\nA test doing there?

This also happens with doc=HTML and doc=Markdown. doc=Man gives this error:

Unknown POD element of type 'Pod::Block::Declarator': Pod::Block::Declarator.new(WHEREFORE => Mu $, config => {}, contents => [])
  in method pod-node at /usr/local/Cellar/rakudo-star/2023.02/share/perl6/site/sources/12D9BFFD82AD93CF4CA5996422D1B5A175300329 (Pod::To::Man) line 134
  in block  at /usr/local/Cellar/rakudo-star/2023.02/share/perl6/site/sources/12D9BFFD82AD93CF4CA5996422D1B5A175300329 (Pod::To::Man) line 71
  in method para-ctx at /usr/local/Cellar/rakudo-star/2023.02/share/perl6/site/sources/12D9BFFD82AD93CF4CA5996422D1B5A175300329 (Pod::To::Man) line 55
  in method pod-node at /usr/local/Cellar/rakudo-star/2023.02/share/perl6/site/sources/12D9BFFD82AD93CF4CA5996422D1B5A175300329 (Pod::To::Man) line 64
  in method pod2man at /usr/local/Cellar/rakudo-star/2023.02/share/perl6/site/sources/12D9BFFD82AD93CF4CA5996422D1B5A175300329 (Pod::To::Man) line 140
  in method render at /usr/local/Cellar/rakudo-star/2023.02/share/perl6/site/sources/12D9BFFD82AD93CF4CA5996422D1B5A175300329 (Pod::To::Man) line 148
  in block <unit> at ./usage-pod.raku line 21

The spawned command '/usr/local/Cellar/rakudo-star/2023.02/bin/rakudo' exited unsuccessfully (exit code: 1, signal: 0)
  in block <unit> at ./usage-pod.raku line 1

How can I get these Pod::To modules to recognize a Pod::Block::Declarator?

1

There are 1 answers

4
Jim Bollinger On BEST ANSWER

Thanks, @raiph, I should have searched first.

Using Pod::To::Anything, I created Pod::To::Markdown::No-declarators

use v6.d;

use Pod::To::Anything;
use Pod::To::Anything::Subsets;
use Pod::To::Markdown;

unit class Pod::To::Markdown::No-Declarators
        is Pod::To::Markdown
        does Pod::To::Anything;

multi method render (Pod::Block::Declarator:D $declarator --> Str) {
    ;
}

multi method render (Pod::Block::Code:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Named::Author:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Named::Name:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Named::Subtitle:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Named::Title:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Named::Version:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Named::Pod:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Para:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Block::Table:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::B:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::C:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::E:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::I:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::K:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::L:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::N:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::P:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::R:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::T:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::U:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::V:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::FormattingCode::X:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Heading:D $t --> Str) {  return Pod::To::Markdown.render: $t }
multi method render (Pod::Item:D $t --> Str) {  return Pod::To::Markdown.render: $t }

I haven't rigorously tested it, but it passes a smoke test.