2012-03-16 07:24:47 +05:30
#!/usr/bin/perl
2012-03-25 05:09:58 +05:30
# cd <g3 clone>/doc; ./mkdoc # --> creates ../html/*.html
2012-03-16 07:24:47 +05:30
2012-03-25 05:09:58 +05:30
my $MKD = "./Markdown.pl";
2012-03-16 07:24:47 +05:30
use 5.10.0;
use strict;
use warnings;
2012-04-06 20:29:05 +05:30
use lib '../src/lib/Gitolite/Test';
2012-03-26 05:24:21 +05:30
use Tsh;
$ENV{TSH_ERREXIT} = 1;
try "
mkdir ../html; ok
git status -s -uno; !/./
git log --oneline -1
" or die 1;
my $head = (lines())[0];
main();
try "
git checkout gh-pages; ok
git reset --hard github/gh-pages; ok
cd ..; ok
2012-04-16 10:37:45 +05:30
git rm *.html; ok
mv html/*.html .; ok
git add *.html; ok
2012-03-26 05:24:21 +05:30
git commit -m '$head'; ok
2012-04-16 10:37:45 +05:30
git checkout master; ok
2012-03-26 05:24:21 +05:30
rmdir html; ok
" or die 2;
sub main {
2012-04-05 21:31:23 +05:30
chomp(@ARGV = `find . -name "*.mkd" | cut -c3-`) if not @ARGV;
@ARGV = grep { /./ } @ARGV;
2012-03-26 05:24:21 +05:30
my @save = @ARGV;
my $css = join("", <DATA>);
2012-04-08 07:25:24 +05:30
my %ct; # chapter tocs
2012-03-26 05:24:21 +05:30
my $mf = '';
my $fh;
while (<>) {
$ARGV =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
my $b = $1;
if (/^(#+) (?:#(\S+) )?(.*)/) {
if ( length($1) == 1 ) {
2012-04-08 07:25:24 +05:30
$ct{$b} .= "\n";
$ct{$b} .= " * [$3][$b]\n";
2012-03-26 05:24:21 +05:30
$mf .= "[$b]: $b.html\n";
} else {
2012-04-08 07:25:24 +05:30
$ct{$b} .= " " x ( 4 * ( length($1) - 1 ) );
$ct{$b} .= " * ";
$ct{$b} .= (
2012-03-26 05:24:21 +05:30
$2
? "[$3][$2]"
: "$3"
);
2012-04-08 07:25:24 +05:30
$ct{$b} .= "\n";
2012-03-26 05:24:21 +05:30
$mf .= "[$2]: $b.html" . ($2 ne $b ? "#$2" : "") . "\n" if $2;
}
2012-03-16 07:24:47 +05:30
}
}
2012-04-05 21:31:23 +05:30
# open($fh, ">", "master-toc.mk2")
# and print $fh $mt
# and close $fh;
2012-03-16 07:24:47 +05:30
2012-03-26 05:24:21 +05:30
# after this, do this for every mkd (including the master-toc.mkd)
2012-03-16 07:24:47 +05:30
2012-03-26 05:24:21 +05:30
# cat $css_block > $base.html
# cat $base.mkd $mf | $MKD >> $base.html
2012-03-16 07:24:47 +05:30
2012-04-05 21:31:23 +05:30
for my $mkd (@save) {
2012-03-26 05:24:21 +05:30
$mkd =~ /^(?:.*\/)?([^\/]+)\.mkd$/;
my $b = $1;
2012-03-16 07:24:47 +05:30
2012-03-26 05:24:21 +05:30
open($fh, ">", "../html/$b.html")
and print $fh $css
and close $fh;
2012-03-16 07:24:47 +05:30
2012-03-26 05:24:21 +05:30
my $mkt = `cat $mkd`;
$mkt =~ s/^(#+) #(\S+) /$1 <a name="$2"><\/a> /mg;
2012-04-08 07:25:24 +05:30
$mkt =~ s/^\[\[TOC\]\]/$ct{$b}/mg;
2012-03-26 05:24:21 +05:30
open($fh, "|-", "$MKD >> ../html/$b.html")
2012-04-05 21:31:23 +05:30
and print $fh $mkt, "\n\n", $mf
2012-03-26 05:24:21 +05:30
and close $fh;
}
2012-03-16 07:24:47 +05:30
}
__DATA__
<head><style>
2012-04-05 18:42:40 +05:30
body { background: #fff; text-color: #000; margin-left: 40px; font-size: 0.9em; font-family: sans-serif; max-width: 800px; }
h1 { background: #ffb; text-color: #000; margin-left: -30px; border-top: 5px solid #ccc; }
h2 { background: #ffb; text-color: #000; margin-left: -20px; border-top: 3px solid #ddd; }
h3 { background: #ffb; text-color: #000; margin-left: -10px; }
h4 { background: #ffb; text-color: #000; }
code { font-size: 1.1em; background: #ddf; text-color: #000; }
pre { margin-left: 2em; background: #ddf; text-color: #000; }
pre code { font-size: 1.1em; background: #ddf; text-color: #000; }
2012-03-16 07:24:47 +05:30
</style></head>
<p style="text-align:center">
<a href="master-toc.html">master TOC</a>
|
<a href="index.html">main page</a>
|
<a href="index.html#license">license</a>
</p>
2012-04-19 06:33:36 +05:30
<p style="text-align:center">
<font color="gray">This is for gitolite "g3"; for older (v2.x) documentation click <a href="http://sitaramc.github.com/gitolite/g2/master-toc.html">here</a></font>
</p>