Skip to content

Instantly share code, notes, and snippets.

@uzluisf
Created December 2, 2018 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uzluisf/fe0c282ce3321908e6c03bcce2d92e3f to your computer and use it in GitHub Desktop.
Save uzluisf/fe0c282ce3321908e6c03bcce2d92e3f to your computer and use it in GitHub Desktop.

Let's say I have the following module:

module Simple-Mod;

#| Calculate the nth fibonacci number.
multi fib( 0 ) { 1 }
multi fib( 1 ) { 1 }
multi fib( Int $n where * > 1 ) {
    fib($n - 2 ) + fib($n - 1);
}

#| Say hello to  a person.
sub hello( $person ) { say "Hello, $person!" }

=begin pod
=head1 SYNOPSIS

A really simple module.

=head1 Example
=begin code
use Simple-Mod;

say fib(3);    #=> 2
hello("Gina"); #=> Hello, Gina!

=end code

=head1 Subroutines

=end pod

At the moment, when I extract the Pod from this module, I obtain this:

sub fib(
        Int $ where { ... }, 
)
Calculate the nth fibonacci number.

sub hello(
        $person, 
)
Say hello to a person.

SYNOPSIS

A really simple module.

Example

    use Simple-Mod;

    say fib(3);    #=> 2
    hello("Gina"); #=> Hello, Gina!

Subroutines

Is it posible to instruct the Pod parsing process to place the subroutine definitions and comments after the Subroutines header? Like this:

SYNOPSIS

A really simple module.

Example

    use Simple-Mod;

    say fib(3);    #=> 2
    hello("Gina"); #=> Hello, Gina!

Subroutines

sub fib(
        Int $ where { ... }, 
)
Calculate the nth fibonacci number.

sub hello(
        $person, 
)
Say hello to a person.

@JJ
Copy link

JJ commented Dec 2, 2018

It would be great if it did, right? But no, that's not possible unless you create your own Pod parser. Shouldn't be hard, though...

@JJ
Copy link

JJ commented Dec 2, 2018

You can also put the =pod in front. It can go anywhere indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment