(mkdoc) make it do a little more post-mkdoc work
This commit is contained in:
parent
cf10f7933c
commit
5d1adc63c2
121
doc/mkdoc
121
doc/mkdoc
|
@ -7,61 +7,90 @@ my $MKD = "./Markdown.pl";
|
||||||
use 5.10.0;
|
use 5.10.0;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use lib '../src/Gitolite/Test';
|
||||||
|
use Tsh;
|
||||||
|
|
||||||
chomp(@ARGV = `cat list`) if not @ARGV;
|
$ENV{TSH_ERREXIT} = 1;
|
||||||
@ARGV = grep { $_ ne 'master-toc.mkd' and /./ } @ARGV;
|
|
||||||
my @save = @ARGV;
|
|
||||||
my $css = join("", <DATA>);
|
|
||||||
|
|
||||||
my $mt = "# gitolite master table of contents/index\n";
|
try "
|
||||||
my $mf = '';
|
mkdir ../html; ok
|
||||||
my $fh;
|
git status -s -uno; !/./
|
||||||
|
git log --oneline -1
|
||||||
|
" or die 1;
|
||||||
|
|
||||||
while (<>) {
|
my $head = (lines())[0];
|
||||||
$ARGV =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
|
|
||||||
my $b = $1;
|
|
||||||
|
|
||||||
if (/^(#+) (?:#(\S+) )?(.*)/) {
|
main();
|
||||||
if ( length($1) == 1 ) {
|
|
||||||
$mt .= "\n";
|
try "
|
||||||
$mt .= " * [$3][$b]\n";
|
git checkout gh-pages; ok
|
||||||
$mf .= "[$b]: $b.html\n";
|
git reset --hard github/gh-pages; ok
|
||||||
} else {
|
cd ..; ok
|
||||||
$mt .= " " x ( 4 * ( length($1) - 1 ) );
|
git rm g3/*.html; ok
|
||||||
$mt .= " * ";
|
mkdir g3; ok
|
||||||
$mt .= (
|
mv html/*.html g3; ok
|
||||||
$2
|
git add g3; ok
|
||||||
? "[$3][$2]"
|
git commit -m '$head'; ok
|
||||||
: "$3"
|
git checkout g3; ok
|
||||||
);
|
rmdir html; ok
|
||||||
$mt .= "\n";
|
" or die 2;
|
||||||
$mf .= "[$2]: $b.html" . ($2 ne $b ? "#$2" : "") . "\n" if $2;
|
|
||||||
|
sub main {
|
||||||
|
chomp(@ARGV = `cat list`) if not @ARGV;
|
||||||
|
@ARGV = grep { $_ ne 'master-toc.mkd' and /./ } @ARGV;
|
||||||
|
my @save = @ARGV;
|
||||||
|
my $css = join("", <DATA>);
|
||||||
|
|
||||||
|
my $mt = "# gitolite master table of contents/index\n";
|
||||||
|
my $mf = '';
|
||||||
|
my $fh;
|
||||||
|
|
||||||
|
while (<>) {
|
||||||
|
$ARGV =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
|
||||||
|
my $b = $1;
|
||||||
|
|
||||||
|
if (/^(#+) (?:#(\S+) )?(.*)/) {
|
||||||
|
if ( length($1) == 1 ) {
|
||||||
|
$mt .= "\n";
|
||||||
|
$mt .= " * [$3][$b]\n";
|
||||||
|
$mf .= "[$b]: $b.html\n";
|
||||||
|
} else {
|
||||||
|
$mt .= " " x ( 4 * ( length($1) - 1 ) );
|
||||||
|
$mt .= " * ";
|
||||||
|
$mt .= (
|
||||||
|
$2
|
||||||
|
? "[$3][$2]"
|
||||||
|
: "$3"
|
||||||
|
);
|
||||||
|
$mt .= "\n";
|
||||||
|
$mf .= "[$2]: $b.html" . ($2 ne $b ? "#$2" : "") . "\n" if $2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
open($fh, ">", "master-toc.mkd")
|
open($fh, ">", "master-toc.mkd")
|
||||||
and print $fh $mt
|
and print $fh $mt
|
||||||
and close $fh;
|
|
||||||
|
|
||||||
# after this, do this for every mkd (including the master-toc.mkd)
|
|
||||||
|
|
||||||
# cat $css_block > $base.html
|
|
||||||
# cat $base.mkd $mf | $MKD >> $base.html
|
|
||||||
|
|
||||||
for my $mkd ("master-toc.mkd", @save) {
|
|
||||||
$mkd =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
|
|
||||||
my $b = $1;
|
|
||||||
|
|
||||||
open($fh, ">", "../html/$b.html")
|
|
||||||
and print $fh $css
|
|
||||||
and close $fh;
|
and close $fh;
|
||||||
|
|
||||||
my $mkt = `cat $mkd`;
|
# after this, do this for every mkd (including the master-toc.mkd)
|
||||||
$mkt =~ s/^(#+) #(\S+) /$1 <a name="$2"><\/a> /mg;
|
|
||||||
open($fh, "|-", "$MKD >> ../html/$b.html")
|
# cat $css_block > $base.html
|
||||||
and print $fh $mkt, $mf
|
# cat $base.mkd $mf | $MKD >> $base.html
|
||||||
and close $fh;
|
|
||||||
|
for my $mkd ("master-toc.mkd", @save) {
|
||||||
|
$mkd =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
|
||||||
|
my $b = $1;
|
||||||
|
|
||||||
|
open($fh, ">", "../html/$b.html")
|
||||||
|
and print $fh $css
|
||||||
|
and close $fh;
|
||||||
|
|
||||||
|
my $mkt = `cat $mkd`;
|
||||||
|
$mkt =~ s/^(#+) #(\S+) /$1 <a name="$2"><\/a> /mg;
|
||||||
|
open($fh, "|-", "$MKD >> ../html/$b.html")
|
||||||
|
and print $fh $mkt, $mf
|
||||||
|
and close $fh;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__DATA__
|
__DATA__
|
||||||
|
|
Loading…
Reference in a new issue