Skip to content

Commit 8000e26

Browse files
committed
Add a util for generating a stub doc for a new type
1 parent 6b46eaf commit 8000e26

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

util/new-type.p6

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use v6;
2+
3+
sub MAIN($typename, :$kind='class') {
4+
my @path-chunks = $typename.split('::');
5+
my $filename = @path-chunks.pop ~ '.pod';
6+
my $path = 'lib/Type';
7+
for @path-chunks -> $c {
8+
$path ~= "/$c";
9+
unless $path.IO.d {
10+
mkdir $path.IO.mkdir;
11+
}
12+
}
13+
14+
$path ~= "/$filename";
15+
16+
spurt $path.IO, Q:s:to/TEMPLATE/;
17+
=begin pod
18+
19+
=TITLE $kind $typename
20+
21+
=SUBTITLE ...
22+
23+
$kind $typename is SuperClass { ... }
24+
25+
Synopsis goes here
26+
27+
=head1 Methods
28+
29+
=head2 method flurb
30+
31+
method flurb($typename:D: *@args --> Str)
32+
33+
method description here
34+
35+
=end pod
36+
TEMPLATE
37+
38+
say "'$path' written";
39+
say "(remeber to 'git add $path')";
40+
}

0 commit comments

Comments
 (0)