-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew-type.raku
executable file
·53 lines (38 loc) · 1.11 KB
/
new-type.raku
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env raku
# If the documentation for a type does not exist, create the skeleton of the doc
# $ raku util/new-type.raku --kind=role Some::Role
# this creates the file doc/Type/Some/Role.rakudoc
sub MAIN($typename, :$kind='class') {
my @path-chunks = $typename.split('::');
my $filename = @path-chunks.pop ~ '.rakudoc';
my $path = 'doc/Type';
for @path-chunks -> $c {
$path ~= "/$c";
unless $path.IO.d {
mkdir $path.IO.mkdir;
}
}
$path ~= "/$filename";
if $path.IO ~~ :e {
say "The file $path already exists.";
exit 1;
}
my $fh = open $path, :x;
spurt $fh, Q:s:to/HEADER/;
=begin pod
=TITLE $kind $typename
=SUBTITLE ...
$kind $typename is SuperClass { ... }
Synopsis goes here
HEADER
spurt $fh, Q:c:to/BODY/;
=head1 Methods
=head2 method flurb
method flurb({$typename}:D: *@args --> Str)
method description here
=end pod
BODY
$fh.close;
say "'$path' written";
say "(remember to 'git add $path')";
}