aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2011-04-18 08:43:58 +0000
committerTom Feist <shabble@metavore.org>2011-04-18 08:43:58 +0000
commit04e9b16d8f414d60bb53a270c38ed1ac8a1b6629 (patch)
tree474ab85f914b586f11b624d9ac6e70e75fd6c382
parentadded vim-mode genereated readme (diff)
downloadirssi-scripts-04e9b16d8f414d60bb53a270c38ed1ac8a1b6629.tar.gz
irssi-scripts-04e9b16d8f414d60bb53a270c38ed1ac8a1b6629.zip
fixed readme_generator again to append to files, rather than trying to create
different ones for each script in a dir. Needs a way to force it to completely regen though, otherwise it'll just keep appending each tiem.
-rw-r--r--readme_generator.pl23
1 files changed, 17 insertions, 6 deletions
diff --git a/readme_generator.pl b/readme_generator.pl
index dc3b277..67da7ac 100644
--- a/readme_generator.pl
+++ b/readme_generator.pl
@@ -45,12 +45,12 @@ sub read_input_file {
my @other_files = glob($dir . "/*.pl");
- if (@other_files > 1) {
- $filename =~ s/\.pl$//;
- create_output_file($dir, "README-$filename.md", $parser);
- } else {
+ # if (@other_files > 1) {
+ # $filename =~ s/\.pl$//;
+ # create_output_file($dir, "README-$filename.md", $parser);
+ # } else {
create_output_file($dir, "README.md", $parser);
- }
+ # }
}
sub create_output_file {
@@ -58,9 +58,20 @@ sub create_output_file {
my $filepath = File::Spec->catfile($dir, $filename);
+ my $markdown = $parser->as_markdown;
+ return unless length chomp($markdown);
+ return if $markdown =~ m/^\s*$/;
+
_err("Writing to $filepath");
- open my $wfh, '>', $filepath or die "Couldn't open $filepath for output: $!";
+ my $sec_sep = '';
+ if (-f $filepath) {
+ _err("$filepath already exists, going to append");
+ $sec_sep = "\n\n* * * *\n\n";
+ }
+
+ open my $wfh, '>>', $filepath or die "Couldn't open $filepath for output: $!";
+ print $wfh $sec_sep;
print $wfh $parser->as_markdown;
close $wfh;
}