aboutsummaryrefslogtreecommitdiffstats
path: root/readme_generator.pl
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2011-04-18 14:24:48 +0000
committerTom Feist <shabble@metavore.org>2011-04-18 14:24:48 +0000
commit25af30751d22508bd7b89fbe2dc367ef8c657af1 (patch)
tree9d045a04fde34adaa27a0bd1908c01e64b53c44b /readme_generator.pl
parenttrying out README's in pod now, to avoid the markdown pain. (diff)
downloadirssi-scripts-25af30751d22508bd7b89fbe2dc367ef8c657af1.tar.gz
irssi-scripts-25af30751d22508bd7b89fbe2dc367ef8c657af1.zip
protecting my newly podded docs against a rogue README generator.
Diffstat (limited to '')
-rw-r--r--readme_generator.pl37
1 files changed, 18 insertions, 19 deletions
diff --git a/readme_generator.pl b/readme_generator.pl
index 2062ad1..5052afb 100644
--- a/readme_generator.pl
+++ b/readme_generator.pl
@@ -8,10 +8,12 @@ use warnings;
#
# Not sure how it's going to work with multiple files in a dir though. Sections?
+# Change of plan! Github supports POD, so we just use Pod::Select to scrape it.
use File::Find;
use File::Spec;
-use Pod::Markdown;
+use Pod::Select;
+
use feature qw/say/;
use Cwd;
@@ -32,9 +34,11 @@ find(\&wanted, @dirs);
sub wanted {
my ($file, $dir, $path) = ($_, $File::Find::dir, $File::Find::name);
return unless $file =~ m/\.pl$/;
+ return if $file =~ m/^\./;
_err("processing file: $path");
- read_input_file($dir, $file);
+ #read_input_file($dir, $file);
+ create_output_file($dir, $file);
}
sub read_input_file {
@@ -43,39 +47,34 @@ sub read_input_file {
my $filepath = File::Spec->catfile($dir, $filename);
_err("reading $filepath");
- my $parser = Pod::Markdown->new;
- $parser->parse_from_file($filepath);
-
create_output_file($dir, "README.md", $parser);
}
sub create_output_file {
- my ($dir, $filename, $parser) = @_;
-
- my $filepath = File::Spec->catfile($dir, $filename);
-
- my $markdown = $parser->as_markdown;
+ my ($dir, $in_file) = @_;
- return unless length chomp($markdown);
- return if $markdown =~ m/^\s*$/;
+ my $parser = Pod::Select->new;
+ my $out_file = "README.pod";
+ my $in_file_path = File::Spec->catfile($dir, $in_file);
+ my $out_file_path = File::Spec->catfile($dir, $out_file);
my $sec_sep = '';
- if (-f $filepath and not $overwrite) {
- _err("$filepath already exists, going to append") unless $overwrite;
- $sec_sep = "\n\n* * * *\n\n";
+ if (-f $out_file_path and not $overwrite) {
+ _err("$out_file_path already exists, going to append") unless $overwrite;
+ $sec_sep = "\n\n=for html <br />\n\n";
}
my $mode = $overwrite ? '>' : '>>';
_err("Writing to $mode $filepath");
- open my $wfh, $mode, $filepath
- or die "Couldn't open $filepath for $mode output: $!";
+ open my $wfh, $mode, $out_file_path
+ or die "Couldn't open $out_file_path for $mode output: $!";
+
+ $parser->parse_from_file($in_file_path, $wfh);
- print $wfh $sec_sep;
- print $wfh $parser->as_markdown; # fetch it again since we chomped $markdown.
close $wfh;
}