Skip to content

Commit

Permalink
gen-docs is where mkdocs picks stuff up now
Browse files Browse the repository at this point in the history
  • Loading branch information
sitaramc committed Mar 8, 2017
1 parent aa29fac commit ec4cc23
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
28 changes: 18 additions & 10 deletions bin/build
Expand Up @@ -7,21 +7,29 @@ die() { echo "$@"; exit 1; }

[ -f mkdocs.yml ] || die "are you sure you're in the right directory?"

# generate images
bin/mkdocs.pre-build.image-gen `find . -name "*.gv" -o -name "*.aa"`
[ "$1" = "clean" ] && rm -rf gen-docs
mkdir -p gen-docs

cd docs

# check for dirty tree
x="`git -c color.ui=always status -suno`"
echo "$x"
[ -z "$x" ] || die "dirty tree?"
# generate images
for f in `find . -name "*.gv"; find . -name "*.aa"`
do
new=${f/%aa/png}
new=${f/%gv/png}
[ -f ../gen-docs/$new ] && [ ../gen-docs/$new -nt $f ] && continue
echo -n >&2 $f...
../bin/mkdocs.pre-build.image-gen $f ../gen-docs/$new
echo >&2 "done"
done

# generate mkd with vim-syntax; this step is slow, but this is the simplest
# way to support gitolite syntax highlighting in arbitrary markdown.
for i in `find docs -name "*.mkd" -type f`
for f in `find . -name "*.mkd"`
do
echo -n >&2 $i...
[ -f $i ] || { echo >&2 "skipping $i"; continue; }
bin/mkdocs.pre-build.mkd-filter < $i > i && mv i $i
[ -f ../gen-docs/$f ] && [ ../gen-docs/$f -nt $f ] && continue
echo -n >&2 $f...
bin/mkdocs.pre-build.mkd-filter < $f > ../gen-docs/$f
echo >&2 "done"
done

Expand Down
23 changes: 10 additions & 13 deletions bin/mkdocs.pre-build.image-gen
Expand Up @@ -5,12 +5,14 @@ use 5.10.0;
use Data::Dumper;

# input:
# a list of files whose names end in ".gv" or ".aa"
# input file: a file whose name ends in ".aa" or ".gv"
# output file: a file whose name should end in ".png" but we don't check
# output:
# each of those files converted to corresponding ".png" with the same base
# name (and in the same directory).
# the output file, duh!

my @list = @ARGV; @ARGV = ();
my $in = shift;
my $out = shift;
@ARGV = ();

# GV:: color codes to be used later
#<<<
Expand All @@ -28,16 +30,11 @@ my %colors = (
);
#>>>

for my $file (@list) {
next unless -r $file;
next unless $file =~ s/\.(gv|aa)$//;
my $type = $1;
print STDERR "image-gen: $file.$type...";

fig($type, "$file.png", slurp("$file.$type"));
print STDERR "\n";
}
next unless -r $in;
next unless $in =~ /\.(gv|aa)$/;
my $type = $1;

fig($type, $out, slurp("$in"));

# ----

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
@@ -1,4 +1,5 @@
site_name: Gitolite
docs_dir: gen-docs
# repo_url: https://github.com/sitaramc/gitolite-doc

pages:
Expand Down

0 comments on commit ec4cc23

Please sign in to comment.