-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev-bin-generate-readme
executable file
·40 lines (27 loc) · 1.08 KB
/
dev-bin-generate-readme
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
#!/usr/bin/env perl
# Generate README with descriptions for bin scripts
use strict;
use warnings;
no warnings 'uninitialized';
use Path::Tiny;
use Text::Wrap;
$Text::Wrap::columns = 72;
die "Current dir not called bin" if !path(".")->basename eq "bin";
my $readme = path("README.md");
my ($preamble) = $readme->slurp =~ /(.*## Descriptions)/igms;
$readme->spew("$preamble\n\n");
foreach my $app (sort(path(".")->children)) {
next if $app->is_dir;
next
if $app->basename =~ /^\.|^readme.md$|^package.*json$|^authorized_keys$/i;
my ($description) = $app->slurp =~ /^=head1 NAME\s+(.+)/m;
($description) = $app->slurp =~ /^# (.+?)\n/m if !$description;
($description) = $app->slurp =~ /^\/\/ (.+?)\n/m if !$description;
$description =~ s/^$app[\s-]*//g;
# $description = wrap(' ', ' ', $description) if $description;
print STDERR "Description ends with a dot app: $app\n"
if $description =~ /\.$/;
print STDERR "No description found for app: $app\n" if !$description;
$description ||= " TODO";
$readme->append("* [$app](./$app): $description\n");
}