Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created February 23, 2017 20:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gfldex/bd0e2e1aa5eb02386e1601f056953fbc to your computer and use it in GitHub Desktop.
#! /usr/bin/env perl6
use v6;
sub USAGE () {
print Q:c:to/EOH/;
Usage: {$*PROGRAM-NAME} [FILE|PATH]
Scan a single pod6 file or pod6 files under a path for method declarations,
infer the typename from the filename and output any methods name that is
found in the type but not in the pod6 file.
EOH
}
sub MAIN($source-path = './doc/Type/', Str :$exclude = ".git", :$ignore = 'util/ignored-methods.txt') {
my \exclude = none('.', '..', $exclude.split(','));
my \type-pod-files := $source-path.ends-with('.pod6')
?? ($source-path.IO,)
!! gather for $source-path {
take .IO when .IO.f && .Str.ends-with('.pod6');
.IO.dir(test => exclude)».&?BLOCK when .IO.d
}
my $prefix-length = $source-path.ends-with('.pod6') ?? ($source-path.chars - $source-path.IO.basename.chars) !! $source-path.chars;
# lazy list of (type-name, IO::PATH)
my \types := gather for type-pod-files».IO {
my $file-path = .substr($prefix-length);
my $type-name = $file-path.chop(5).subst(:g, '/', '::');
try take (::($type-name), .IO)
}
say types[*;0].grep: * ~~ Cool;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment