From ec4cc2334ab142462b32778b0dade5ba86d5e4cd Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Tue, 28 Feb 2017 19:35:17 +0530 Subject: [PATCH] gen-docs is where mkdocs picks stuff up now --- bin/build | 28 ++++++++++++++++++---------- bin/mkdocs.pre-build.image-gen | 23 ++++++++++------------- mkdocs.yml | 1 + 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/bin/build b/bin/build index c0ba7fc..d0a3f55 100755 --- a/bin/build +++ b/bin/build @@ -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 diff --git a/bin/mkdocs.pre-build.image-gen b/bin/mkdocs.pre-build.image-gen index a6fc8ba..ae59d2f 100755 --- a/bin/mkdocs.pre-build.image-gen +++ b/bin/mkdocs.pre-build.image-gen @@ -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 #<<< @@ -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")); # ---- diff --git a/mkdocs.yml b/mkdocs.yml index fd1a645..0c0f444 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,5 @@ site_name: Gitolite +docs_dir: gen-docs # repo_url: https://github.com/sitaramc/gitolite-doc pages: