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

1

10
#!/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?

Futuristic answered 20/3, 2023 at 21:17 Comment(2)
I don't have much time tonight but perhaps Don't show declarator blocks with p6doc is helpful?Claudicant
I know zero perl thus I can help NOT; However the first line of Your source code mandates an unvote.Marocain
F
4

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.

Futuristic answered 22/3, 2023 at 1:40 Comment(3)
I've been researching and working on an answer or comment on and off (not sure if it'll end up worth publishing), but that's a great answer, much more satisfying than mine was/is. My wip contains stuff like "It looks to me like this stuff was immature 5 years ago, and hasn't gotten much love since, so remains immature. See, for example, Pod declarator blocks cannot be attached to all declarators, and Unwanted/incorrect declarator blocks in Pod." Researching it was a downer. Your answer is a delight!Claudicant
I'm curious if the SO I linked in my comment on your question was helpful or whether you just figured stuff out?Claudicant
It was helpful, because Patrick's code made me realize I could write my own Pod::To:: filter. And somewhere I remembered something called "Pod::To::Anything"... Yes, the declarator stuff is a downer. I really like the tool - I hope it gets some attention in v6.e. Having someone on StackOverflow call my code 'a delight' just made my day!Futuristic

© 2022 - 2024 — McMap. All rights reserved.